HP3000-L Archives

May 1998, Week 1

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:
"Michael D. Hensley" <[log in to unmask]>
Reply To:
Date:
Wed, 6 May 1998 10:39:10 +8
Content-Type:
text/plain
Parts/Attachments:
text/plain (50 lines)
Tony Furnival wrote:
> Eg given a script randval thaty returns the random value in the variable
> rand_val, how about a syntax that said:
>
> setvar myvar randval()
>  or whatever the calling sequence was.

Hmm, did you see the other posts?  Jeff Vances script seems to do this, but
putting the expression into a variable.  Also, the setvar(varname,expr) [NOT
the :SETVAR command] returns the value of varname as well as setting it.

So,

:setvar x 0
:setvar incrementx "setvar(x,x+1)"
:setvar y !incrementx
[x and y now both equal 1]

You could store your global functions in variables via a logon udc/command
file, or have a GLOBFUNC command file that you execute at the beginning of
any command files that need those functions.

Stan Sieler improved on the original command file even further:

How about:
   setvar gen_rand_vowel "str('aeiou', (hpcpumsecs mod 5) + 1, 1)"

(removing need for extra variable)

Or, to be more general (and accomodate foreign languages):

setvar vowels "aeiou"
setvar gen_rand_vowel "str(vowels, (hpcpumsecs mod len (vowels)) + 1, 1)"


Time to evalue 1000 times
    (no var) & 5     4039
    var & 5          4180
    (no var) & len   4189
    var & len        4487

Looks like 150 milliseconds for variable lookup, and another 150
milliseconds for len().


---
Michael D. Hensley       | mailto:[log in to unmask]
Allegro Consultants Inc. |
408/252-2330             | Visit scenic http://www.allegro.com

ATOM RSS1 RSS2