Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Bug reports
➜ Possible SetVariable/DeleteVariable bug
Possible SetVariable/DeleteVariable bug
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Mon 24 May 2004 10:47 AM (UTC) |
Message
| It has been a long time since I did this, and it could be my fault, but I thought I'd tell you to check it out in case it was a bug, can't hurt anyway :)
A few weeks ago I was making a plugin to store an array in variables. What I did was this:
Dim intCounter
For intCounter = 1 to 10
DeleteVariable "World_Variable_" & intCounter
Next
SetVariable "World_Variable_1", "stuff"
The state file had 3 variables in it, "World_Variable_1" to 3. The script deleted them and added the variable 1, but they weren't deleted from the state file. No matter how many times I ran it, it always had 3 variables in it. I even did World.Note to see if they were deleted, and it clearly showed that it deleted the 3 variables and inserted the other one, but when I ran it again, it still deleted 3 variables. I just deleted the state file and it runs fine now, but it struck me as odd... Maybe Nick could look into it? |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #1 on Mon 24 May 2004 11:37 PM (UTC) |
Message
| I can't reproduce that. You need to save the state file (eg. remove the plugin) first, the state file is not saved moment-by-moment.
However my test plugin works - once the variables are deleted, and the plugin closed and re-opened, the variables are gone. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #2 on Tue 25 May 2004 10:30 AM (UTC) |
Message
| This script was run on OnPluginInstall, and I was reloading the plugin... Reloading saves the variables, doesn't it? |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #3 on Tue 25 May 2004 09:54 PM (UTC) |
Message
| Reloading should save the variables, yes.
Are the variables also in the plugin itself? Not that it should matter. Are you sure the OnPluginInstall script runs?
Try putting in a note, like I did:
sub OnPluginInstall
Dim intCounter
Note "in OnPluginInstall"
For intCounter = 1 to 10
Note "delete = " & DeleteVariable ("World_Variable_" & intCounter)
Next
SetVariable "World_Variable_1", "stuff"
end sub
That confirms that the script ran, and shows the results of the deletion. You should see either of these cases:
in OnPluginInstall
delete = 0
delete = 0
delete = 0
delete = 0
delete = 0
delete = 0
delete = 0
delete = 0
delete = 0
delete = 0
in OnPluginInstall
delete = 0
delete = 30019
delete = 30019
delete = 30019
delete = 30019
delete = 30019
delete = 30019
delete = 30019
delete = 30019
delete = 30019
The first variable is always there (hence the result 0) because of the line:
SetVariable "World_Variable_1", "stuff"
... which is done after the deletes.
Try doing: world.debug "plugins" just before closing the plugin, to confirm that the variables are really deleted. Maybe the plugin puts them back.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Poromenos
Greece (1,037 posts) Bio
|
Date
| Reply #4 on Wed 26 May 2004 10:21 AM (UTC) Amended on Wed 26 May 2004 10:22 AM (UTC) by Poromenos
|
Message
| I did, that's what surprised me. I put the notes just under the deletes/inserts, so I know they ran, but they were recreated every time I loaded the plugin... I didn't think to return the result of the DeleteVariable though, so maybe that failed. Now I can't test it, it doesn't do it any more. :( The variables were not in the file, because I deleted the state file and it runs ok now... I guess I should have reported it back then, but I thought I must be doing something wrong, and since it worked I didn't see any more trouble with it. :/ |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,974 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top