| View previous topic :: View next topic |
| Author |
Message |
dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Fri Feb 17, 2012 8:47 am Post subject: List Test |
|
|
Hi all
Does anyone know how to test if a list has been created? All the tests
I've come up with just crash the script with a list error.
I've tried, @count(), @item() and @index() but if the list has not been
created in advance the script crashes. I'm trying to test to see if the
list HAS been created.
Thanks
David.M |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Fri Feb 17, 2012 1:13 pm Post subject: |
|
|
Use @text(). If it is NULL then either the list has not been created or it is empty.
Also If you don't already know, If you are on VDS 6 you can use the @new() command to make a new list that is auto-assigned a number... if on an earlier version you can use my @list(new) function which does the same.
Hope this helps.
| Code: |
# %t = @list(new,<List options>,OldErrorTrap)
# Return Number of list created or nil if no list available
# OldErrorTrap is the label of your previous error trap if needed.
#<List Options>
#Options are:
# DROPFILES
# FILELIST|<filespec>|<attributes>
# FONTLIST
# LOADFILE|<filename>
# LOADTEXT
# MODULES|<task>
# REGKEYS|<root key>|<subkey>
# REGVALS|<root key>|<subkey>
# TASKLIST|<flags>
# WINLIST|<flags>
#Example %%tmp = @list(new,Winlist,C)
#Define function,List
:List
if %1
goto %1
end
error -1
exit
:New
option Errortrap,List_Is_Open_Error
%9 = 1
repeat
%4 = @count(%9)
%9 = @succ(%9)
until @equal(%9,33)
if @equal(%9,33)
exit
end
:ListIsOpenOK
if %3
option Errortrap,%3
else
option Errortrap
end
exit %9
:List_Is_Open_Error
%4 =
parse "%%LN1;%%LN2;%%LN3",%2
if @equal(%%LN1,SORTED)
list create,%9,sorted
elsif @equal(%%LN1,PASTE)
list create,%9
list paste,%9
elsif @equal(%%LN1,DROPFILES)
list create,%9
list dropfiles,%9
elsif @equal(%%LN1,FILELIST)
list create,%9
list filelist,%9,%%ln2,%%ln3
elsif @equal(%%LN1,FONTLIST)
list create,%9
list fontlist,%9
elsif @equal(%%LN1,LOADFILE)
list create,%9
list loadfile,%9,%%ln2
elsif @equal(%%LN1,MODULES)
list create,%9
list modules,%9,%%ln2
elsif @equal(%%LN1,REGKEYS)
list create,%9
list regkeys,%9,%%ln2,%%ln3
elsif @equal(%%LN1,REGVALS)
list create,%9
list regvals,%9,%%ln2,%%ln3
elsif @equal(%%LN1,TASKLIST)
list create,%9
list tasklist,%9,%%ln2
elsif @equal(%%LN1,WINLIST)
list create,%9
list winlist,%9,%%ln2
else
list create,%9
end
%%ln1 =
%%ln2 =
%%ln3 =
goto ListIsOpenOK
|
_________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Sun Feb 26, 2012 8:01 pm Post subject: |
|
|
| what I use to do his I would make a list to keep track of the create a list |
|
| Back to top |
|
 |
|
|
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
|
|