[email protected] said the following on 8/20/2009 7:58 PM:
The message's content type was not explicitly allowed
------------------------------------------------------------------------
Subject:
Re: [U2] UD: Executing small part of subroutine code once from
dictionary call
From:
Bill Haskett <[email protected]>
Date:
Thu, 20 Aug 2009 19:58:11 -0700
To:
U2 Users List <[email protected]>
To:
U2 Users List <[email protected]>
Andy:
The interesting thing about this is that in UD, this variable, or the
"@ITEM.COUNT" virtual attribute variable, is set by the original pass
before the sort. Thus, the 1st item through the subroutine may be the
315th item in the original pass, but the 1st item in the sort. I
can't guarantee the item order being passed to the called subroutine.
It's wierd to think one has to remember which dictionary subroutines
have this problem so the original query first does the SSELECT before
the SORT or LIST.
Id D3 the a COMMON variable (not named common) is kept throughout a
query. I think mvBASE and others were also like that. One can't
expect the developer to know which dictionaries have this problem so
that every query has to be a combination of SELECT then SORT/LIST.
Thanks,
Bill
------------------------------------------------------------------------
andy baum said the following on 8/20/2009 3:09 PM:
Bill,
Does Unidata have the @NI variable this will be set to 1 for the first record
of any new LIST or SELECT so you should be able to change
IF comDbiUserArray = NULL$ OR comDbiUserArray = 0 THEN
To
IF comDbiUserArray = NULL$ OR comDbiUserArray = 0 OR @NI = 1 THEN
HTH
Andy
----- Original Message ----
From: Bill Haskett <[email protected]>
To: U2 Mail List <[email protected]>
Sent: Thursday, 20 August, 2009 22:28:44
Subject: [U2] UD: Executing small part of subroutine code once from dictionary
call
I have a UD dictionary that calls a subroutine. The subroutine selects a small
file and saves the data into a reformatted array, which is returned as a passed
variable.
I want to only execute this select code once in the subroutine then continue with the
reset of the subroutines business rule(s) for subsequent items processed. When I create
a "named" common variable for the built data array the array is set once and
when I alter the data in the selected file (small) it never is updated when I run a
subsequent selects or sorts.
UniData doesn't seem to be able to inform me when the first item is processed,
in order to initialize, read, and build the configuration array. How is this
done?
E.g. I want to know what accounts a user has access to (we run an ASP with
50-100 accounts on it and our users file is global). The dictionary builds an
array of users on our system as follows:
001 mv'd list of user names
002 mv'd list of upper-cased user names
003 mv'd list of account paths each user has access to
A user can have access to multiple account paths. When I do the following (in
PICK mode):
:sort SECUSERS BY USERID ID-SUPP USERID ACCTUSER AUTHACCTS
...I get the following list of users and account paths they have access to:
UserId......... C.. AuthAccts.....................
PUBLICUSER 1 E:\UDAccounts\AsiPublic
E:\DataTrust\Dev
E:\DataTrust\Demo
DOTNETUSER 1 E:\DataTrust\Demo
E:\Advantos\Intel
E:\DataTrust\Dev
MYUSER 1 E:\DataTrust\Dev
E:\DataTrust\Demo
E:\Advantos\Intel
The dictionary of "AUTHACCTS" looks like:
Top of "AUTHACCTS" in "DICT SECUSERS", 6 lines, 113 characters.
*--: P
001: I The authorized accounts this user has access to (a DBIUSERS value)
002: SUBR( "D.AUTHACCTS", @ID )
003:
004: AuthAccts
005: 30L
006: M
Bottom.
*--:
...and the subroutine looks like:
*
** Initialize common program variables
$INCLUDE DTABP,INCLUDES SET.COMMON
*
** Initialize local common
COMMON /dbUserc/ comDbiUserArray
*
** Initialize null because we're calling from a dictionary and SET.INIT
** hasn't run yet (besides NULL$ isn't named common).
NULL$ = ''
*
** Initialize return value
OutValue = NULL$
*
** Make sure we're dealing with a user record key
IF UserID = NULL$ THEN GOTO END.OF.PROGRAM
*
** Get the list of DB users
IF comDbiUserArray = NULL$ OR comDbiUserArray = 0 THEN
CALL GET.DBIUSERS ( DbiUserArray )
comDbiUserArray = DbiUserArray
END
*
**-------------------------------------------------------------------**
** **
** R U N P R O G R A M **
** **
**-------------------------------------------------------------------**
*
** Assign the names Id & intialize variable to pass back
UCDbiUserList = comDbiUserArray<2>
DbiUserPaths = comDbiUserArray<3>
UserID = OCONV(UserID, 'MCU')
LOCATE(UserID, UCDbiUserList, 1; Pos) THEN
OutValue = RAISE(DbiUserPaths<1,Pos>)
END
The problem is once I run the query the contents of the array "comDbiUserArray"
will never change until I log off. How can I force the array to be initialized without
logging off?
Any help would be appreciated.
Thanks,
Bill Haskett
Advantos Systems, Inc.
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users