HP3000-L Archives

November 2006, Week 2

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:
"Vance, Jeff H (Cupertino)" <[log in to unmask]>
Reply To:
Vance, Jeff H (Cupertino)
Date:
Wed, 8 Nov 2006 14:31:27 -0600
Content-Type:
text/plain
Parts/Attachments:
text/plain (102 lines)
Hi all,

I am seeking your opinions on an aspect of a recent SIB CI enhancement
called "User Functions". 

Background:
-----------
User functions are basically UDCs or scripts which return a value via
their name, when invoked. For example, a simple user function named ADD
returns the sum of two numbers:
  PARM n1,n2
  return !n1+!n2

ADD could be invoked as:
  if add(3,myvar) < 4 then ...

See Jazz at
http://jazz.external.hp.com/papers/Communicator/7.5/UserFunctions.txt
for more info on User Functions.


Parameters:
-----------
In fixing a defect in our user function code, we realized that we are
making an assumption about how to treat user function parameters.
Consider these examples:

Filename 1 = SCRIPT.PUB.SYS
---------------------------
PARM p1
echo p1=!p1
setvar result !p1*(!p1-1)
showvar result

Filename 2 = FUNC.PUB.SYS 
-------------------------
PARM p1
echo p1=!p1
return !p1*(!p1-1)


Execute the script:
===================
:script 4
p1=4
RESULT = 12

:script 5-1
p1=5-1
RESULT = 2

:script (5-1)
p1=(5-1)
RESULT = 12

From above you can see that we treat all parameter values for UDCs and
scripts as unevaluated string literals. The middle example appears not
to work because the expression becomes: 
   setvar result 5-1*(5-1-1)
               = 5-1*(3)
               = 5-3 = 2


Execute the user function:
==========================
:calc func(4)
p1=4
12, $C, %14

:calc func(5-1)
p1=4
12, $C, %14

:calc func((5-1))
p1=4
12, $C, %14

The middle example here appears to work as one would expect, but is
inconsistent with how the very similar UDC/script behaves. Note that the
user function parameters are evaluated prior to being stored.
(This parameter evaluation has a defect regarding certain string values
and that's why we are looking at the code.)

We need to decide to either treat user function parameters like the
other predefined function parameters, or like UDC/script parameters.
Parameters for almost* all of our predefined functions, e.g.. STR,
FINFO, etc.) are evaluated before being stored as a parm value.
Parameters for scripts/UCDs are not evaluated and are simply stored as
literal string values.

I am very interested in your opinions so we can complete this fix.

thanks,
 Jeff Vance, vCSY


* WORD, SETVAR, and WORDCNT have a parameter (the name of a variable)
which is purposely not evaluated.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2