Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing a file from a procomm script 1

Status
Not open for further replies.

Matta25

Technical User
Jan 6, 2004
82
US
Is there a command in procomm to printing a file from a procomm script after i download it?
thanks.
 
i have two .txt file that i need printed. i put the sample script in a loop to print the 2 file but get an error. it prints the first .txt file then errors on the second one. i seem to try to print the second file to fast and the script is not ready. any ideas
thanks
 
Here is the part of the script that prints the multiple files. the error i get is: Error 5: Invalid Identifier and the source line text: While not Feof 1
Thanks.


; zip response files up
While Findfirst RespFile2
strfmt DosCmd "pkzip25 -add %c%s%c %s" 34 RespFile3 34 $filename
dos DosCmd minimized TaskId
while taskexists TaskId
yield
endwhile
RespFile1 = $filename

AddFileName sPath $filename
fetch print device sPrinter
;* CHANGE SOME FONT AND OTHER PRINTER SETTINGS
If Printer OPEN ; Printer Setup
printfont "Courier New" 10 ; Set Font.
printalign LEFT ; Left Justified
printmargin .5 .5 .5 .5 ; Set Margins.
;Prints the file
Fopen 1 sPath READ
While Not Feof 1
Fgets 1 sLine
Printstr sLine
Endwhile
Fclose 1
Endif
Printer Close
pause 10
delfile $filename
Endwhile
 
Without seeing the rest of your script this is just a guess (but I think a pretty good one), but what I bet is happening is that you are not resetting the value of sPath before the addfilename command. If true, this means you'll have a file to open that looks something like c:\path\file1.txtfile2.txt in that variable, which does not exist and the fopen command fails. To see if this is the case, you could add usermsg "%s" sPath just before the fopen command and see if it displays the expected value.


aspect@aspectscripting.com
 
here is the whole script:
thanks

proc main
; declare variables
integer Year, Month, Day, Hour, Minute, Second, TaskId
string Now, SBFileName, DosCmd, NegEmail, PosEmail1, PosEmail2, ComPortRes
string ErrMsg1, ErrMsg3, ErrMsg6, WarnMsg1, GoodMsg1, DefaDir = "D:\EdiFiles\FlBcHo"
string ClaimFile1, RespFile0, RespFile1, RespFile2, RespFile3,RespFile4, RespFile5, RespFile6, RespFile7, RespFile8
string sLine, sPrinter, sPath = "d:\EdiFiles\FlBcHo"

; settings
set aspect rgetchar 13 strip
set cdinxfer on
set dnldpath "D:\EDIFiles\FlBcHo\"
set statusline on
set terminal sbpages 1000
set xferyield 3
call SetTitleBar
chdir DefaDir

; initialize variables
ltimeints $ltime Year, Month, Day, Hour, Minute, Second
strfmt Now "%04d%02d%02d%02d%02d%02d" Year Month Day Hour Minute Second
ClaimFile1 = "D:\EdiFiles\FlBcHo\Claims.837"
RespFile0 = "D:\EdiFiles\FlBcHo\*.ack"
RespFile1 = "D:\EdiFiles\FlBcHo\ULResp.dat"
RespFile2 = "D:\EdiFiles\FlBcHo\*.txt"
RespFile3 = "D:\EdiFiles\FlBcHo\Resp.zip"
RespFile4 = "D:\EdiFiles\FlBcHo\997.zip"
strfmt RespFile5 "D:\DataArch\FlBcHo\Resp %s.zip" Now
strfmt RespFile6 "D:\DataArch\FlBcHo\997 %s.zip" Now
RespFile7 = "F:\BbsTrans\File\CliData\EDYq997.zip"
RespFile8 = "F:\BbsTrans\File\CliData\EDYqULR.zip"
NegEmail = "F:\Automail\MailBox\grpEdiIssues.Transmission FlBcHoR.1"
PosEmail1 = "F:\Automail\MailBox\grpEdiTrans.Transmission FlBcHoR.1"
PosEmail2 = "F:\Automail\MailBox\grpEdiTrans.Transmission FlBcHoR.2"
WarnMsg1 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.warn1"
GoodMsg1 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.good1"
ErrMsg1 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.err1"
ErrMsg3 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.err3"
ErrMsg6 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.err6"
strfmt SBFileName "D:\DataArch\FlBcHo\ProComm %s.log" Now

; zip response files up
While Findfirst RespFile2
strfmt DosCmd "pkzip25 -add %c%s%c %s" 34 RespFile3 34 $filename
dos DosCmd minimized TaskId
while taskexists TaskId
yield
endwhile
RespFile1 = $filename

AddFileName sPath $filename
fetch print device sPrinter
;* CHANGE SOME FONT AND OTHER PRINTER SETTINGS
If Printer OPEN ; Printer in Setup
printfont "Courier New" 10 ; Set Font.
printalign LEFT ; Left Justified
printmargin .5 .5 .5 .5 ; Set Margins.
;Prints the file
Fopen 1 sPath READ
While Not Feof 1
Fgets 1 sLine
Printstr sLine
Endwhile
Fclose 1
Endif
Printer Close
pause 10
delfile $filename
Endwhile
While FindFirst RespFile0
strfmt DosCmd "pkzip25 -add %c%s%c %s" 34 RespFile4 34 $Filename
dos DosCmd minimized TaskId
while taskexists TaskId
yield
endwhile
delfile $filename
Endwhile
While FindFirst "*.ebr"
delfile $filename
EndWhile

; archive response files
Rename RespFile3 RespFile5
Rename RespFile4 RespFile6
;copyfile RespFile5 "D:\Webreports\FLORIDABLUECROSS\hospital\"
copyfile GoodMsg1 PosEmail2

; Delete Claim file
delfile ClaimFile1


;CLEANUP:
sbsave file SBFileName
delfile ComPortRes
pwexit
endproc

; ------------------------------ SET TITLE BAR ------------------------------
proc SetTitleBar
; Includes script name in ProComm's title bar
string TitleBar, fndrive, fnpath, fnname, fnext
splitpath $scriptfile fndrive fnpath fnname fnext
strfmt TitleBar "Procomm - %s transmission" fnname
pwtitlebar TitleBar permanent
endproc
 
Yep, looks to me like you will be appending the second file to the value in sPath, thereby creating an invalid file that will cause the fopen command to fail. I would recomend using strfmt to hold the path and filename to the file you wish to open, similar to what you did with several variables at the beginning of your script.


aspect@aspectscripting.com
 
Hello Knob,
First off thank for all your help. Second do you know where i would put the strfmt in this script?
thanks again.
 
the sPath is the folder where these file are but the filenames are different. so the script goes into a loop and generates a file name $filename. how do i have the sPath also include a $filename variable from the loop that get the txt files.
thanks.
 
What I would recommend doing is creating a new variable, say called sFile, which will hold the fully-qualified path and name of the file. Then I would replace the addfilename call with this line:

strfmt sFile "%s\%s" sPath $filename

What this does is create a value for sFile that is based on the path in the sPath variable and the $filename system variable returned by the findfirst command.

Finally, you would need to modify the fopen command to access sFile instead of sPath.

aspect@aspectscripting.com
 
thank you very much Knob. that did it. i used procomm some time ago and i'm just getting back into it. thank you again for all your help.
 
one more question. the script is working great now. when it prints at the top of each the page is print "d:\edifiles\flbcho\*.txt". i have changed the sPath to a different folder but it still prints "d:\edifiles\flbcho\*.txt".
is this a different variable i need to reset?
thanks again.
 
I see in the last version of your script that you posted that RespFile2 is set to that value. Is this value in the file pointed to by sPath? You might need to post the current version of your script before I can have a better idea where that is coming from.


aspect@aspectscripting.com
 
here is the final script. I don't see how respfile2 string is getting printing at the top of every report when that value is change from script to script.
thanks

proc main
; declare variables
integer Year, Month, Day, Hour, Minute, Second, TaskId
string Now, SBFileName, DosCmd, NegEmail, PosEmail1, PosEmail2, ComPortRes
string ErrMsg1, ErrMsg3, ErrMsg6, WarnMsg1, GoodMsg1, DefaDir = "D:\EdiFiles\FlBcHo"
string ClaimFile1, RespFile0, RespFile1, RespFile2, RespFile3,RespFile4, RespFile5, RespFile6, RespFile7, RespFile8
string sLine, sPrinter, sPath = "d:\EdiFiles\FlBcHo", sFile

; settings
set aspect rgetchar 13 strip
set cdinxfer on
set dnldpath "D:\EDIFiles\FlBcHo\"
set statusline on
set terminal sbpages 1000
set xferyield 3
call SetTitleBar
chdir DefaDir

; initialize variables
ltimeints $ltime Year, Month, Day, Hour, Minute, Second
strfmt Now "%04d%02d%02d%02d%02d%02d" Year Month Day Hour Minute Second
ClaimFile1 = "D:\EdiFiles\FlBcHo\Claims.837"
RespFile0 = "D:\EdiFiles\FlBcHo\*.ack"
RespFile1 = "D:\EdiFiles\FlBcHo\ULResp.dat"
RespFile2 = "D:\EdiFiles\FlBcHo\*.txt"
RespFile3 = "D:\EdiFiles\FlBcHo\Resp.zip"
RespFile4 = "D:\EdiFiles\FlBcHo\997.zip"
strfmt RespFile5 "D:\DataArch\FlBcHo\Resp %s.zip" Now
strfmt RespFile6 "D:\DataArch\FlBcHo\997 %s.zip" Now
RespFile7 = "F:\BbsTrans\File\CliData\EDYq997.zip"
RespFile8 = "F:\BbsTrans\File\CliData\EDYqULR.zip"
NegEmail = "F:\Automail\MailBox\grpEdiIssues.Transmission FlBcHoR.1"
PosEmail1 = "F:\Automail\MailBox\grpEdiTrans.Transmission FlBcHoR.1"
PosEmail2 = "F:\Automail\MailBox\grpEdiTrans.Transmission FlBcHoR.2"
WarnMsg1 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.warn1"
GoodMsg1 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.good1"
ErrMsg1 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.err1"
ErrMsg3 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.err3"
ErrMsg6 = "C:\Program Files\ProComm Plus\Aspect\FlBcHoR.err6"
strfmt SBFileName "D:\DataArch\FlBcHo\ProComm %s.log" Now

; zip response files up
While Findfirst RespFile2
strfmt DosCmd "pkzip25 -add %c%s%c %s" 34 RespFile3 34 $filename
dos DosCmd minimized TaskId
while taskexists TaskId
yield
endwhile
RespFile1 = $filename

strfmt sFile "%s\%s" sPath $filename
fetch print device sPrinter
;* CHANGE SOME FONT AND OTHER PRINTER SETTINGS
If Printer OPEN ; Printer in Setup
printfont "Courier New" 8 ; Set Font.
printalign LEFT ; Left Justified
printmargin .5 .5 .5 .5 ; Set Margins.
;Prints the file
Fopen 1 sFile READ
While Not Feof 1
Fgets 1 sLine
Printstr sLine
Endwhile
Fclose 1
Endif
Printer Close
delfile $filename
Endwhile
While FindFirst RespFile0
strfmt DosCmd "pkzip25 -add %c%s%c %s" 34 RespFile4 34 $Filename
dos DosCmd minimized TaskId
while taskexists TaskId
yield
endwhile
delfile $filename
Endwhile
While FindFirst "*.ebr"
delfile $filename
EndWhile

; archive response files
Rename RespFile3 RespFile5
Rename RespFile4 RespFile6
;copyfile RespFile5 "D:\Webreports\FLORIDABLUECROSS\hospital\"
copyfile GoodMsg1 PosEmail2

; Delete Claim file
delfile ClaimFile1


;CLEANUP:
sbsave file SBFileName
delfile ComPortRes
pwexit
endproc

; ------------------------------ SET TITLE BAR ------------------------------
proc SetTitleBar
; Includes script name in ProComm's title bar
string TitleBar, fndrive, fnpath, fnname, fnext
splitpath $scriptfile fndrive fnpath fnname fnext
strfmt TitleBar "Procomm - %s transmission" fnname
pwtitlebar TitleBar permanent
endproc
 
I take it this value as appearing at the very top of the file as if it were a header and not like it was a line in the file? If you select the File | Print Setup menu item in Procomm and the click on the Page Setup button, does the header value look correct?


aspect@aspectscripting.com
 
that did it. Let me thank you one more time for all your help. thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top