HP3000-L Archives

June 2004, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Emerson, Tom" <[log in to unmask]>
Reply To:
Emerson, Tom
Date:
Thu, 24 Jun 2004 12:16:05 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (33 lines)
> -----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 *

ATOM RSS1 RSS2