[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference iosg::all-in-1_v30

Title:*OLD* ALL-IN-1 (tm) Support Conference
Notice:Closed - See Note 4331.l to move to IOSG::ALL-IN-1
Moderator:IOSG::PYE
Created:Thu Jan 30 1992
Last Modified:Tue Jan 23 1996
Last Successful Update:Fri Jun 06 1997
Number of topics:4343
Total number of notes:18308

1154.0. "Get next record " by SWETSC::WESTERBACK (Mimsy were the borogroves) Fri Jul 31 1992 13:42

    ALL-IN-1 2.4:
    
    Programming question, maybe simple but since I haven't much experience
    of programming I thought that perhaps someone more knowledgeable could
    come up with something:
    
    A customer have made an entry form and a data file to go with it.
    Only one field on this form. Using SEARCH she can get list of all the
    records in the data file.
    
    Now she wants to use a GET function to get the next record of the file.
    She has tried
    
    GET FORMNAME.%NEXT[""]   and
    
    GET FORMNAME.FIELDNAME[""]
    
    but then gets a message symbol can't be found.
    
    She's a lot more experienced than I in programming, so I can't tell
    if she's on the right track.... 
    
    Any ideas?
    
    Thanks,
    Hans Westerback
    TSC, Stockholm
T.RTitleUserPersonal
Name
DateLines
1154.1What was the _exact_ message?HYTIDE::CREAMERFri Jul 31 1992 15:0515
    
    Hans,
    
    If she starts off with #KEY = "", then 
	GET #KEY = FORMNAME.%NEXT[#KEY] 
    will load the key of the first record into the symbol #key.  
    On successive calls, the value of the next record after #key willbe
    loaded into #key.  When she reaches the end of the file, #key will
    be blank.
    
    HTH,
    
    Jack
    
    
1154.2ThanksSWETSC::WESTERBACKMimsy were the borogrovesFri Jul 31 1992 15:155
    Thanks Jack,
    
    This seems to be what she was looking for. Easy enough...
    
    Hans
1154.3%NEXT or %SEQ_NEXTSHALOT::NICODEMAvoid traffic; leave work at noonFri Jul 31 1992 15:4129
	Using the special field name %NEXT should get her what she wants.  But
she will have to remember that %NEXT requires a valid key supplied, or a null
string.  In other words, to get the key of the first record, she can do:

	GET #KEY = FORMNAME.%NEXT[""]

	Then, successive records can be found using:

	GET #KEY = FORMNAME.%NEXT[#KEY]

	But %NEXT does have a limitation that if the supplied key is not for an
existing record, it works the same as null string.  Therefore,

	GET #KEY = FORMNAME.%NEXT["G"]

*may not* get the next record starting with "G"; if there is no record whose key
is "G" (exactly), then this statement will be the same as the first one above.

	And of course when there is no next record (i.e., you've reached end-of-
file), %NEXT returns a null string.

	The alternative would be to use %SEQ_NEXT, which is almost identical to
%NEXT, except that it does not do a Rewind -- that is, it will *always* get the
next record.  Where this becomes important is when you are 'Next'ing through a
key that has duplicates.  %NEXT cannot handle this, since it will always do a
rewind, and get "stuck" at the point that it hits a duplicate key.  %SEQ_NEXT
will work as it should -- it will process every key once, even duplicates.

	F