| View previous topic :: View next topic |
| Author |
Message |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Fri Mar 12, 2004 2:54 am Post subject: Is there any way to test if LIST is OPEN(or CREATEd) |
|
|
I have many LIST that are on and off in multi module program, it would be much easier to test if a LIST is allready closed that amother part of the program to have to close quickly and then a ERROR because of close LIST that not opened yet.
(Subj: Is there any way to test if LIST is OPEN(or CREATEd)) |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Fri Mar 12, 2004 3:53 am Post subject: |
|
|
I just need it to do something like this:
| Code: | IF @open(LIST1)
LIST CLOSE,1
END |
|
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1566
|
Posted: Fri Mar 12, 2004 3:57 am Post subject: |
|
|
Why not use a variable?
%%List1 = 1
LIST CREATE,1
and when you want to close/free the list:
%%List1 = 0
LIST CLOSE,1
Then you can check if %%List1 is @equal to 1 or 0 (opened, closed).
Last edited by PGWARE on Fri Mar 12, 2004 4:36 am; edited 1 time in total |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Mar 12, 2004 4:00 am Post subject: |
|
|
You could set a var each time you open/close a list...
| Code: |
LIST CREATE, 1
%%list1 = 1
LIST CLOSE, 1
%%list1 = ""
if %%list1
INFO List 1 is open
else
INFO List 1 is closed
end
|
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Mar 12, 2004 4:01 am Post subject: |
|
|
OOPS... I'm too slow PK.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Fri Mar 12, 2004 4:02 am Post subject: |
|
|
I was gonna write to INI %%list_one_statis = YES or something, but wondered if there was an easier way, your way sounds pritty easy though.
Thanks PGWARE  |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1566
|
Posted: Fri Mar 12, 2004 4:36 am Post subject: |
|
|
Mac must be my long lost twin, we came up with the very similar solution with similar variable names  |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Mar 12, 2004 4:51 am Post subject: |
|
|
LOL
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Fri Mar 12, 2004 5:23 am Post subject: |
|
|
Maybe your both toward the end of VDS technolgy tree
You guys are great, what would we do without your help  |
|
| Back to top |
|
 |
Protected Valued Contributor


Joined: 02 Jan 2001 Posts: 228 Location: Portugal
|
Posted: Fri Mar 12, 2004 9:37 am Post subject: |
|
|
You don't need to be in the end of the technology to figure, this (hey, did you know prakash was the VDS support guy in the past? ) I also think it would be nice to have a function that would test the status of a list! @lopen returning null for closed, 1 for empty, 2 for not empty... Anyway, another method for this would be using ANOTHER list whose positions would have the control flags for the status of each list. If you're using a lot of lists it would make it much easier to apply batch operations to all values  |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Fri Mar 12, 2004 10:29 am Post subject: |
|
|
I agree, Protected. Having a function to check if a list is open would seem
like a very nice feature.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Fri Mar 12, 2004 12:00 pm Post subject: |
|
|
If you really need to do this, you could do something like this:
| Code: | list create,1
%%_list = 1
gosub listexists
info List exists status: %%_exists
list close,1
%%_list = 1
gosub listexists
info List exists status: %%_exists
exit
:listexists
%%_exists = 1
option errortrap,listerror
list create,%%_list
%%_exists =
:listcontinue
option errortrap
exit
:listerror
goto listcontinue |
Or if you just want to ensure that the list is created, no matter whether it already existed:
| Code: | list create,1
%%_list = 1
gosub listcreate
list close,1
%%_list = 1
gosub listcreate
exit
:listcreate
option errortrap,listcreateerror
list create,%%_list
:listcreatecontinue
option errortrap
exit
:listcreateerror
goto listcreatecontinue |
Edit: I changed that last example, I forgot to clear the temporary errortrap there
after setting it.
Tommy
Last edited by Tommy on Fri Mar 12, 2004 3:52 pm; edited 1 time in total |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Fri Mar 12, 2004 1:30 pm Post subject: |
|
|
Is there any way of telling what the old error trap was? If someome sets a new errortrap in a DSU file, it will overwrite the old errortrap (if any) that the user created. Anyway of putting it back to the previous errortrap? _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Fri Mar 12, 2004 1:44 pm Post subject: |
|
|
Here is a DSU for checking it a List Exists of is Empty. Thanks Tommy
| Code: |
#-----------------------------------------------------------------------------#
# #
# Author: Chris Gingerich [Thanks to Tommy for the Idea ] #
# #
# Copyright: Chris Gingerich #
# #
#-----------------------------------------------------------------------------#
# This DSU does redefine the error trap so you will need to reset your
# old one if needed.
# %t = @list(Exist,[List])
# Return 1 if exist or nil if not
#
# %t = @list(Empty,[List])
# Return 1 [Empty] Nil [Not Empty]
#Define function,List
info ListOpen: @List(Exist,1)
list create,1
info ListOpen: @list(Exist,1)
info ListEmpty: @list(Empty,1)
List add,1,test
info ListEmpty: @list(Empty,1)
Stop
:List
if %1
Goto %1
end
Error -1
Exit
:Empty
if %2
if @greater(@count(%2),0)
%3 = 1
else
error -1
end
exit %3
:Exist
Option Errortrap,ListIsOpenError
%3 = @text(%2)
%3 = 1
:ListIsOpenOK
Exit %3
:ListIsOpenError
%3 =
Goto ListIsOpenOK
|
_________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
|