Subject: | |
From: | |
Reply To: | Emerson, Tom |
Date: | Thu, 24 Jun 2004 12:16:05 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
> -----Original Message-----
> From: HP-3000 Systems Discussion [mailto:[log in to unmask]]On
>
> 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.
One way to do this that doesn't rely on having the variable pre-set nor on INPUT redirection is as follows:
1) create a file called "setseq" [setsequence] that contains the line:
setvar count 0
2) when you need this number in a job, execute the "command file"
3) to increment the value, issue this command:
:echo setvar count ![count+1] > setseq
note that this also avoids any string-to-number conversion problems [unexpected character in number]
note also that the ![] syntax here is actually optional -- when supplied as shown, the command file gets re-written as
setvar count 1
if you don't supply the square brackets, the file is written as
setvar count 0+1
which is OK because when you EXECUTE the command file, it EVALUATES "0+1" as 1 anyway!
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|