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:
Robert Mills <[log in to unmask]>
Reply To:
Robert Mills <[log in to unmask]>
Date:
Thu, 9 Nov 2006 09:11:44 -0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (152 lines)
Jeff,

Functions are functions whether they are user or predefined.
We are all used to the rules when using predefined functions.
Why have user functions work differently?


regards, 
  
Robert W.Mills 
MIS Systems Development Manager 
Pinnacle Arvato 
+44 (0)20 8309 3604 


-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On
Behalf Of okappert
Sent: 08 November 2006 21:37
To: [log in to unmask]
Subject: Re: [HP3000-L] opinion on CI User function parameters

Jeff:

In my opinion, the programmer should code according to the generally
accepted methods of programming using equations. 

The syntax for: !p1*(!p1-1) should be (!p1)*((!p1)-1).

This method would standardize both types of uses.

Just my 2 cents worth.

Olav.


Vance, Jeff H (Cupertino) wrote:

>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 *
>
>
>  
>

* 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 *

ATOM RSS1 RSS2