forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Is there any way to test if LIST is OPEN(or CREATEd)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Mar 12, 2004 2:54 am    Post subject: Is there any way to test if LIST is OPEN(or CREATEd) Reply with quote

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
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Mar 12, 2004 3:53 am    Post subject: Reply with quote

I just need it to do something like this:


Code:
IF @open(LIST1)
LIST CLOSE,1
END
Back to top
View user's profile Send private message Visit poster's website
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1566

PostPosted: Fri Mar 12, 2004 3:57 am    Post subject: Reply with quote

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
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Mar 12, 2004 4:00 am    Post subject: Reply with quote

You could set a var each time you open/close a list... Wink

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 Smile

_________________
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
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Mar 12, 2004 4:01 am    Post subject: Reply with quote

OOPS... I'm too slow PK. Embarassed

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Mar 12, 2004 4:02 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Visit poster's website
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1566

PostPosted: Fri Mar 12, 2004 4:36 am    Post subject: Reply with quote

Mac must be my long lost twin, we came up with the very similar solution with similar variable names Wink
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Mar 12, 2004 4:51 am    Post subject: Reply with quote

LOL Laughing

Cheers, Mac Smile

_________________
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
View user's profile Send private message Send e-mail
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Mar 12, 2004 5:23 am    Post subject: Reply with quote

Maybe your both toward the end of VDS technolgy tree Laughing

You guys are great, what would we do without your help Very Happy
Back to top
View user's profile Send private message Visit poster's website
Protected
Valued Contributor
Valued Contributor


Joined: 02 Jan 2001
Posts: 228
Location: Portugal

PostPosted: Fri Mar 12, 2004 9:37 am    Post subject: Reply with quote

You don't need to be in the end of the technology to figure, this Very Happy (hey, did you know prakash was the VDS support guy in the past? Wink ) 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 Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Fri Mar 12, 2004 10:29 am    Post subject: Reply with quote

I agree, Protected. Having a function to check if a list is open would seem
like a very nice feature. Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Fri Mar 12, 2004 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Mar 12, 2004 12:03 pm    Post subject: Reply with quote

That indeed can be nice, especially when you make DSU files. That way, you can check which list to use, without clearing an existing one... Smile
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Fri Mar 12, 2004 1:30 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Fri Mar 12, 2004 1:44 pm    Post subject: Reply with quote

Here is a DSU for checking it a List Exists of is Empty. Thanks Tommy Smile

Code:

#-----------------------------------------------------------------------------#
#                                                                             #
# Author: Chris Gingerich [Thanks to Tommy for the Idea Smile ]                 #
#                                                                             #
# 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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group