dbTalk Databases Forums  

Avoiding interference with active list

comp.databases.pick comp.databases.pick


Discuss Avoiding interference with active list in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Scott Ballinger
 
Posts: n/a

Default Re: Avoiding interference with active list - 09-12-2005 , 12:48 PM






Not sure about Unidata, but the "...select svlist; return" simplified
version below does NOT return a list to the calling program in D3 (more
testing reveals that it DOES work in Universe, so likely (?) it would
also work in Unidata, and that system(11) is true in the calling program
also!). It does work (in D3) if you "select to newlist" and newlist is
in common or passed to the sub. But in that case system(11) no longer
works in the calling program to test for a list. (As far as I know, in
D3 the only way to test for an active internal select list is to
readnext from it. I suppose you could muck around in the internal list
name variable, but those things are weird and the internals tend to
change between versions of D3.) And besides, if you already have the
list assigned to an internal variable, this whole thread is probably
moot. I think the OP was about how to issue a select in a generic
subroutine, when there may be an already active list in use by the
calling program that you need to preserve.

/Scott


murthi wrote:
Quote:
Yes, you're right, I was thinking in terms of *always* using RTNLIST which
would solve the problem, but of course require you to check *all* calling
programs. I never leave the RTNLIST out, so select list0 is never active.
Scott's solution is probably the only one, it could be simplified as you
don't have to write and read the list to a file:

restore.list = 0
svlist = ""
if system(11) then
loop
readnext id else exit
svlist<-1> = id
repeat
restore.list=1
end
... whatever ...
if svlist # '' then select svlist

You also want to avoid using select list0 in [whatever], or make sure you
exhaust it, or the select svlist will not work.

Chandru Murthi
michael (AT) preece (DOT) net> wrote in message
news:1126490893.791888.134950 (AT) g49g2000cwa (DOT) googlegroups.com...

murthi wrote:


Do you mean you want to EXECUTE "S{S}ELECT ...." ?

Yes.


If so, don't see the
problem, since you can return the list to any variable via "RTNLIST var"
and
that will not interfere, by definition, with any other extant lists.

If there was a select-list active then wouldn't the S{S}ELECT I execute
attempt to return a subset of the active list?

If the calling program/subroutine had just executed a SELECT (without
specifying a list number or variable) so that list0 is currently
active, and my subroutine then executes another select on a totally
different file/directory, then wouldn't the latest select use the
already active list? Like:

.
.
.
EXECUTE "SELECT FILE1"
CALL MYSUB
.
.
.

SUBROUTINE MYSUB
.
.
.
EXECUTE "SELECT DIR1 ":SELECTCRITERIA:" ":SORTORDER:" TO ":LISTNO
* or ...RTNLIST LISTNO
LOOP
READNEXT KEY FROM LISTNO ELSE EXIT
.
.
.
REPEAT
.
.
.
RETURN

Wouldn't LISTNO always be a subset of the keys from FILE1?

The thing to bear in mind here is that I don't want to change any of
the existing program code - other than to plug in a call to my
subroutine as and when needed.


I
think Unidata probably has the SELECT file_variable TO variable syntax,
which then is the same solution as for the external list.

I'm working on UniData which differs from D3 in that it caters for
active list numbers 0-9. What that seems to mean is that, outside of
UniBasic, you can have up to 10 lists "active" at a time. That's a
little misleading though, because only select-list 0 is *really* active
as far as the system monitor is concerned. You can "SELECT..TO 1". It
will say "x records selected to list 1", but there will be no active
list as far as the system monitor is concerned. If you now "LIST
filename" it will not use the x records in list 1 - it will use
whatever was active as list 0 or, if list 0 wasn't active, list the
whole file. You can "SAVE.LIST listname FROM 1" though, which will use
the x records in list 1. It seems that the only other way, apart from
SAVE.LIST, to use lists 1-9 is in UniBasic READNEXT statements. In
UniBasic you can go ahead and "LOOP...READNEXT KEY FROM n". There is
also the ability, in UniBasic, to use list variables - as you suggest -
so you can READNEXT FROM a list number or a list variable. The thing is
though that that (the ability to specify a list variable as opposed to
a number) only seems to apply to UniBasic (internal) SELECTs - and not
EXECUTEd selects. With EXECUTEd selects you can have ...TO {listno} as
part of the EXECUTEd SELECT statement and then READNEXT FROM {listno},
or you can have ...RTNLIST {listno} as part of the UniBasic EXECUTE
statement. In both cases you have to specify a numeric list number in
the range 0-9. I therefore need to know if any or all of them are
already "active".


Is the issue more complicated? Why do you need to know what lists are
active, or suspend them?

Fwiw - what I'm trying to do is develop a generic OS file handling
subroutine; something similar to one I wrote when on a contract a few
years back (back then I just had to call a pre-existing subroutine (or
function) to get a free list number). Two of its capabilities will be
to open the next new OS file in a directory (given some rules on how
the file name is to be constructed) and/or to open the next existing OS
file in a directory. The OS files in a directory are equivalent to
UniData records in a file. I can therefore SSELECT them WITH PREFIX
LIKE whatever WITH DATE LIKE whatever BY SEQNO to get a select-list,
and then use the resulting list to find out which filename to
OPENSEQ/OSOPEN.

Mike.


Chandru Murthi

michael (AT) preece (DOT) net> wrote in message
news:1126229351.493276.290860 (AT) z14g2000cwz (DOT) googlegroups.com...

Hi

I would like, in a low level subroutine, to EXECUTE a SELECT statement
without interfering in any way with any select lists that might be
active belonging to a higher level calling program.

How do I find out whether there is a select list currently active?

How do I find out which list number it is?

How can I temporarily suspend the active list?
I am thinking along the lines of saving the list, doing what I have to
do and getting the saved list back again afterwards - but in order to
do that I have to have answers to the preceding questions so that I can
reactivate the right list number.

I'm working with UniData.

TIA,
Mike.





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.