@STDFILE
@FILENAME

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, June 23, 2005 02:15 PM
To: [email protected]
Subject: RE: [U2] Custom Functions


Wendy;

I tend not to use a FUNCTION unless I really need it for the syntax. It
helps me to remember that even when calling a function you can change
any of the passed variables - not just the return variable (just like a
subroutine). For some reason I didn't think a function could do that,
I'm not sure if I saw that in the documentation or was just the way I
thought it should work.

In any case, I don't know how to give it a "default" file to use. If you
call it from UniQuery you have the @ID and @RECORD variables to use but
nothing really for a file. What I did - that made a HUGE difference -
was to put the filevar into named common. Since the program could be
called from multiple accounts I also put the path into common as well.
E.g.:

SUBROUTINE TESTSUB(RET_DATA, FILENAME, ID, FIELDNUM)
COMMON /TESTSUB/ PATH, FILEVAR
RET_DATA = ''
IF UNASSIGNED(PATH) THEN PATH = 'Some path that will not exist on any
system'
IF PATH # @PATH THEN
  OPEN FILENAME TO FILEVAR THEN
    PATH = @PATH
  END ELSE
    RETURN
  END
END
READV RET_DATA FROM FILEVAR, ID, FIELDNUM ELSE RET_DATA = ''
RETURN

This will help if you call it from UniQuery or multiple times from
another subroutine; I'm not sure how well it will work if you called it
multiple times from UniObjects. 

Colin Alfke
>From Calgary, AB where I can't believe we've been flooded for a week....

>-----Original Message-----
>From: Wendy Smoak
>
>From: "Ray Wurlod" <[EMAIL PROTECTED]>
>>
>> Try using the SUBR() function, as I mentioned in another post.
>>
>
>Ouch.  Granted my function opens a file and [currently, for 
>debug] prints to the screen, but attempting to call it with 
>SUBR from an I-Descriptor caused... '25945 Bus error' and left 
>the session unresponsive.
>
>Leaving aside the I-Descriptor issue for a moment...
>
>Is there a way for it a function to "assume" that the last 
>file opened is the one I want to use?  I thought there might 
>be an @FILE or something, the way there is @ID and you can 
>have a 'default' file for READ.
>
>http://www.pickwiki.com/cgi-bin/wiki.pl?TreeTraversal
>
>I thought of opening the file in the calling program, and 
>passing a file handle instead of the filename.  But I need 
>this to work when called [indirectly] from UOJ also, and 
>historically I've seen 'Error 30102' if I attempt to pass file 
>handles around in any code called from UOJ.
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to