Oops,
Before anyone catches my mistake. I did modify the original file so the
echo statement would reference my file equation.
Here's the corrected command file.
setvar count 0
#echo 1 > myfile
input count <myfile
setvar count !count+1
echo !count >*myfile
> -----Original Message-----
> From: Larry Barnes
> Sent: Thursday, June 24, 2004 11:57 AM
> To: 'noname'; [log in to unmask]
> Subject: RE: [HP3000-L] cant increment a variable read from
> a file
>
> When you echo the count variable out to a file it is being sent to a
> temp file, unless you have set a file equation.
>
> I built a file called my file which contains 1 record. The record
> started with the number 1.
>
> I then did a file equation
>
> :file myfile,old
>
> I placed your commands
> setvar count 0
> input count <myfile
> setvar count !count+1
> echo !count >myfile
> in a file called xxx and executed the file and it seems to be working
> fine.
>
> I executed the file 'xxx' 5 times and the file, "myfile" now contains
> the number 5 instead of the number 1.
>
> Hope this helps
>
> -----Original Message-----
> From: noname [mailto:[log in to unmask]]
> Sent: Thursday, June 24, 2004 7:21 AM
> To: [log in to unmask]
> Subject: [HP3000-L] cant increment a variable read from a file
>
>
> Hi, I am writing a small script that reads a number from a file,
> increments it with one and writes it back to the file. If i write this
> as a sequence of commands in the shell
>
> setvar count 0
> input count <myfile
> setvar count !count+1
> echo !count >myfile
>
> it works. If, however I put it in a file and run the file i get:
> Variable name not found in variable table. (CIWARN 8101)
>
> if i do a setvar count 0 from the prompt and then run the script i get
> Unexpected character found in number. (CIERR 9810)
>
> why doesnt it create the variable when i do the setsvar count 0 on the
> first line of the script?! how do i make the count+1 work? i tried
> limiting it to one digit by doing setvar count
> ord('incount')-ord('0')+1 but that didnt work out.
>
> anybody?
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|