This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Unsetting or clearing a list index (global)

Old posts that have not been replied to for several years.
Locked
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

Unsetting or clearing a list index (global)

Post by DayCuts »

I have a list index in my script. I understand that all variables/lists are cleared/unset at the end of a procedure, unless declared as a global variable. My question is, how do i then unset/clear a global list/var. The list needs to be global as it is used in several different procedures, but i wish to create a !reset command to clear several global variables and lists.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

To clear you can simply use:

Code: Select all

set myvar ""
This should give a null value.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

This should work too:

Code: Select all

unset myvar
Que?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

quite true...indeed 8)
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
D
DayCuts
Voice
Posts: 37
Joined: Tue Jun 15, 2004 8:43 am

Post by DayCuts »

I guess i could use set myvar "", i just thought there should be a proper way to unset it.

As said in original post.. 'unset myvar' was not working, possibly because it is a list index not a standard variable?
Er, correction, i forgot to mention that in original post :\
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

unset should work
Locked