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!

Extra Characters from Script

Status
Not open for further replies.

Magwich

Technical User
Dec 10, 2003
4
US
I have the following procedure I call from a script:

proc DATECHANGE

string Fname = "S:\WardStockPrintTime.txt" ; File name to be opened.

if fopen 0 Fname READAPPEND TEXT ; Open file
finsblock 0 64
;fputs 0 " " ; Write a blank line

fwrite 0 $DATE 12 ; Write a text string to file
fwrite 0 "`t@`t" 3 ; Write a @ sign
fputs 0 $TIME ; Write Time
fclose 0 ; Close file
else
errormsg "Couldn't open file `"%s`"." Fname
endif

endproc

I get the following output:

1/20/2005 du @ 11:04:50AM
1/27/2005 du @ 11:14:20AM
2/3/2005 odu @ 12:50:52PM
2/10/2005 du @ 10:15:24AM
2/17/2005 du @ 10:34:35AM
2/24/2005 du @ 10:51:36AM

I don't know where the du & odu come from. If I run this as a stand-alone program, I don't get those characters. Just if I run it from a script. Any ideas?
Thanks.
 
Since this works fine when you run the script by itself by not when called by another script, my hunch is that the data being written to the file contains part of the data from a variable in the calling script. Since you are using the READAPPEND flag, you shouldn't need the finsblock command. You'll also want to null any strings that may not be getting initialized with a proper value. Check out the reply I posted yesterday or the day before about a person having a similar problem for more information.

 
Thanks for the quick reply. I understand what you are saying, but I thought the variables I am using are system variables? Explicitly $DATE and $TIME. Do I need to initialize those to 0 or something?
Thanks again!
 
I don't think the problem is so much the system variables, but that you are using the finsblock command. My worry is that it might be using memory that you previously used in the calling script and so it is not "clean."

 
Also, do you have a stripped-down version of your script plus the calling script that you could post? If I could see it happening when called but not when run as a standalone script, I might be able to figure out what is happening.

 
O.K. I commented out the line:
finsblock 0 64

and it still does it i.e:
2/17/2005 du @ 10:34:35AM
2/24/2005 du @ 10:51:36AM
3/3/2005odu @ 9:00:33AM

Here is a condensed version of the script that calls it:
#COMMENT

THIS CODE PRINTS OUT THE INVENTORY SHEETS FOR THE TECHS ON THE CORRECT PRINTER IN THE HOSPITAL.
LAST UPDATED - 3/2/05

Alternative printer for Diabetic Clinic on Sunbridge (ph. 5691/5621) is FAV-SUN-I6185-16 6/16/04

#ENDCOMMENT

proc main
transmit "^|AUTOMATIC REP^M"
waitfor "Select Automatic Replenishment Option: "
transmit "PROD^M"

;//////////1A REFRIGERATOR//////////////////////

waitfor "Select Production Menu Option: "
transmit "INV^M"
waitfor "SELECT DATE/TIME FOR INVENTORY: "
transmit "N^M"
waitfor "? No// "
transmit "Y^M"
waitfor "// "
transmit "^M"
waitfor "// "
transmit "^M"
waitfor "Select AOU INVENTORY GROUP: "
transmit "MON^M"
waitfor "CHOOSE 1-5: "
transmit "1^M"
waitfor "Select AOU INVENTORY GROUP: "
transmit "^M"
waitfor "Do you wish to print the AOU Inventory Sheet: YES// "
transmit "^M"
waitfor "DEVICE: "
transmit "A137^M"
waitfor "Requested Start Time: NOW//"
transmit "^M"

CALL DATECHANGE
endproc

proc DATECHANGE

string Fname = "S:\WardStockPrintTime.txt" ; File name to be opened.

if fopen 0 Fname READAPPEND TEXT ; Open file
;finsblock 0 64
;fputs 0 " " ; Write a blank line

fwrite 0 $DATE 12 ; Write a text string to file
fwrite 0 "`t@`t" 3 ; Write an @ sign
fputs 0 $TIME ; Write Time
fclose 0 ; Close file
else
errormsg "Couldn't open file `"%s`"." Fname
endif

endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top