codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Pcl file  co at 21:23 on Friday, January 23, 2009
 

I am using a Perl script to open a pcl file, locate a piece of text and use it to replace other text in the same file. Then close the file and in the perl script i use a copy command to send the pcl to the printer.

The thing is that the new output file differs very slightly from the input file so therefore it does not print correctly.

Also when it goes onto the printer spool queue it has the name 'remote downlevel document' instead of the value in the pcl file.

has any one any experience doing this before or suggest a possible fix for the problem

Thanks

  Re: Pcl file  hermanningjaldsson at 22:54 on Friday, January 23, 2009
 

"The thing is that the new output file differs very slightly from the input file so therefore it does not print correctly."

How does it differ?

what's a pcl file?



  Re: Pcl file  co at 23:13 on Friday, January 23, 2009
 

a pcl file is a 'printer command language' file. basically a file made up of commands that a printer can understand, the closest thing would be a binary file. it is made up from chars like the following. there is an example at http://www.swiftview.com/tech/testfiles.htm

>=<;:9876543210/.-,+*)('&%$#"!

,°+-, FŠŠI°€b`-,°CX°+ŠŠ°+a ° PX°`Yh°+!!!!!!!Y-, °



It differs slightly in that half way through a sentance there may be an extra tab space. so in the above example it may come out as an extra tab space after the comma below

>=<;:9876543210/.-,+*)('&%$#"!

, °+-, FŠŠI°€b`-,°CX°+ŠŠ°+a ° PX°`Yh°+!!!!!!!Y-, °


  Re: Pcl file  hermanningjaldsson at 23:19 on Friday, January 23, 2009
 

That extra tab must be due to an error in the replacement method.

If you let me know the method then maybe i can see why it's producing that extra tab.



  Re: Pcl file  co at 00:22 on Saturday, January 24, 2009
 

This is the code that carries out what i mentioned above.

open (FILE, "<$file") or die "Can't open $file: $!\n";
@lines = <FILE>;

close FILE;

#Open same file for writing, reusing STDOUT
open (STDOUT, ">$file") or die "Can't open $file: $!\n";


for ( @lines ) {
chomp;
$mystring = $_;

if ($mystring =~ /s1p6/){
$mystring=~s/.*s1p6\?v=//;
$mystring=~s/.*s1p6//; #returns everthing after "$"
$batchnumber = substr($mystring,23,8);
$batchnumber = "$batchnumber";
$batchnumber =~ s/$batchnumber/"$batchnumber"/i;
}
}

for ( @lines ){
$mystring = $_;
if (($linecnt == 0) && ($mystring =~ /DISPLAY=/)){
$mystring=~s/.*DISPLAY=\?v=//;
$mystring=~s/.*DISPLAY=//; #returns everthing after "$"
$letterName = substr($mystring,0,8);
s/$letterName/$batchnumber/gi;
print "$_\n";
}
elsif ($linecnt == 1){
print "$_\n";
}
else {
print $_;
}

$linecnt ++;
}

copy ($file,$printLocn);

  Re: Pcl file  hermanningjaldsson at 07:00 on Saturday, January 24, 2009
 

#This is the code that carries out what i mentioned above.


open (FILE, "<$file") or die "Can't open $file: $!\n";
@lines = <FILE>;#lines of what?
close FILE;

#Open same file for writing, reusing STDOUT why reuse STDOUT? I would use R_FILE and W_FILE.
open (STDOUT, ">$file") or die "Can't open $file: $!\n";


#?
for(@lines)
{
chomp;
$mystring = $_; # $current_line?

if ($mystring =~ /s1p6/)
{
#$mystring =~ s/.*s1p6(\?v=)?//gi;#should do the same as the two following lines.
$mystring=~s/.*s1p6\?v=//;
$mystring=~s/.*s1p6//; #returns everything after "$"

$batchnumber = substr($mystring,23,8);
#the above line looks dangerous. u can do:
#my @someresult = map { /$somepattern/gi } $mystring;

#?
$batchnumber = "$batchnumber";
$batchnumber =~ s/$batchnumber/"$batchnumber"/i;
}
}




#?
for(@lines)
{
$mystring = $_;
if(($linecnt == 0) && ($mystring =~ /DISPLAY=/))
{
$mystring=~s/.*DISPLAY=\?v=//;
$mystring=~s/.*DISPLAY=//; #returns everything after "$" (why isn't there a "$" in the pattern then?)
$letterName = substr($mystring,0,8);
#the above line looks dangerous. u can do:
#my @someresult = map { /$somepattern/gi } $mystring;

s/$letterName/$batchnumber/gi;
print "$_\n";
}
elsif ($linecnt == 1){print "$_\n";}
else {print $_;}

$linecnt++;
}

copy ($file,$printLocn); #locn?


=pod
go through this code with a visual debugger. I'm sure that extra tab will pop up there.

the ptkdb debugger is the best for perl.
to install, do in command prompt:
ppm
install devel-ptkdb
exit

after that you can ru it on programs by typing:
perl -d:ptkdb somescript.pl
=cut


  Re: Pcl file  hermanningjaldsson at 07:00 on Saturday, January 24, 2009
 

#This is the code that carries out what i mentioned above.


open (FILE, "<$file") or die "Can't open $file: $!\n";
@lines = <FILE>;#lines of what?
close FILE;

#Open same file for writing, reusing STDOUT why reuse STDOUT? I would use R_FILE and W_FILE.
open (STDOUT, ">$file") or die "Can't open $file: $!\n";


#?
for(@lines)
{
chomp;
$mystring = $_; # $current_line?

if ($mystring =~ /s1p6/)
{
#$mystring =~ s/.*s1p6(\?v=)?//gi;#should do the same as the two following lines.
$mystring=~s/.*s1p6\?v=//;
$mystring=~s/.*s1p6//; #returns everything after "$"

$batchnumber = substr($mystring,23,8);
#the above line looks dangerous. u can do:
#my @someresult = map { /$somepattern/gi } $mystring;

#?
$batchnumber = "$batchnumber";
$batchnumber =~ s/$batchnumber/"$batchnumber"/i;
}
}




#?
for(@lines)
{
$mystring = $_;
if(($linecnt == 0) && ($mystring =~ /DISPLAY=/))
{
$mystring=~s/.*DISPLAY=\?v=//;
$mystring=~s/.*DISPLAY=//; #returns everything after "$" (why isn't there a "$" in the pattern then?)
$letterName = substr($mystring,0,8);
#the above line looks dangerous. u can do:
#my @someresult = map { /$somepattern/gi } $mystring;

s/$letterName/$batchnumber/gi;
print "$_\n";
}
elsif ($linecnt == 1){print "$_\n";}
else {print $_;}

$linecnt++;
}

copy ($file,$printLocn); #locn?


=pod
go through this code with a visual debugger. I'm sure that extra tab will pop up there.

the ptkdb debugger is the best for perl.
to install, do in command prompt:
ppm
install devel-ptkdb
exit

after that you can ru it on programs by typing:
perl -d:ptkdb somescript.pl
=cut


  Re: Pcl file  hermanningjaldsson at 07:00 on Saturday, January 24, 2009
 

#This is the code that carries out what i mentioned above.


open (FILE, "<$file") or die "Can't open $file: $!\n";
@lines = <FILE>;#lines of what?
close FILE;

#Open same file for writing, reusing STDOUT why reuse STDOUT? I would use R_FILE and W_FILE.
open (STDOUT, ">$file") or die "Can't open $file: $!\n";


#?
for(@lines)
{
chomp;
$mystring = $_; # $current_line?

if ($mystring =~ /s1p6/)
{
#$mystring =~ s/.*s1p6(\?v=)?//gi;#should do the same as the two following lines.
$mystring=~s/.*s1p6\?v=//;
$mystring=~s/.*s1p6//; #returns everything after "$"

$batchnumber = substr($mystring,23,8);
#the above line looks dangerous. u can do:
#my @someresult = map { /$somepattern/gi } $mystring;

#?
$batchnumber = "$batchnumber";
$batchnumber =~ s/$batchnumber/"$batchnumber"/i;
}
}




#?
for(@lines)
{
$mystring = $_;
if(($linecnt == 0) && ($mystring =~ /DISPLAY=/))
{
$mystring=~s/.*DISPLAY=\?v=//;
$mystring=~s/.*DISPLAY=//; #returns everything after "$" (why isn't there a "$" in the pattern then?)
$letterName = substr($mystring,0,8);
#the above line looks dangerous. u can do:
#my @someresult = map { /$somepattern/gi } $mystring;

s/$letterName/$batchnumber/gi;
print "$_\n";
}
elsif ($linecnt == 1){print "$_\n";}
else {print $_;}

$linecnt++;
}

copy ($file,$printLocn); #locn?


=pod
go through this code with a visual debugger. I'm sure that extra tab will pop up there.

the ptkdb debugger is the best for perl.
to install, do in command prompt:
ppm
install devel-ptkdb
exit

after that you can ru it on programs by typing:
perl -d:ptkdb somescript.pl
=cut


  Re: Pcl file  hermanningjaldsson at 07:02 on Saturday, January 24, 2009
 

sorry about the many replies.
i got an error every time i tried to post.

apparently the system had been posting while claiming there was an error.



  Re: Pcl file  hermanningjaldsson at 09:21 on Saturday, January 24, 2009
 

#$mystring =~ s/.*s1p6(\?v=)?//gi;#should do the same as the two following lines.

should have been without the gi.











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  somebody help me please. i becoming mad.
•  JTable in JSP page
•  Re: open excel file in html page
•  WYSIWYG Editor
•  Re: Text wrapping on C# webforms buttons
•  Re: Pcl file
•  DIV IFRAME simulation
•  Onclick does not work using input type = "button"
•  Animation works on IE but not on Firefox


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2009