Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, 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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ How can i implement a stack in a script?

How can i implement a stack in a script?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Smokin711   (2 posts)  Bio
Date Wed 26 Apr 2006 02:58 PM (UTC)
Message
I am trying to figure out how to implement stack functionality...push and pop...to use in my scripts.

It seems that mushclient uses vbscript 5.6 and i'm not really familiar with it...

also, if I want to define a class for use with my scripts, can that be done? or is this sounding more like a plugin?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 27 Apr 2006 05:56 AM (UTC)
Message
Do you particularly want to use VBscript? These days we are recommending Lua as the preferred scripting language.

In any case, any language can be used to implement a stack. Basically you want:


  • An array in which you store the things you want to stack

  • A counter which indicates how many things are in the array


To push something you add it to the array at the "stack top" position, and add 1 to that counter.

To pop something you remove it from the "stack top" position, and subtract 1 from that counter.

In VBscript variables are variants, which means elements can be of any type. The same applies to Lua, where a table can consist of elements of any type, including other tables.




I'm not sure what you mean by "define a class". You don't necessarily have to use plugins, the main advantage of them is that they are modular, but do not offer particular advantages over normal scripting, excepting the plugin callback routines, which MUSHclient looks for.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


11,485 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.