String-Stack - Include

Started by Theo Gottwald, January 10, 2011, 09:24:47 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

Again we have an Stack. This time you can not only add numbers, but add Strings of any lenght.
PUSH them on the Stack, and POP them off the Stack.
Just include this Library and it will work.

How do you use this?
Just declare a String, for Example:

QuoteGLOBAL MyStri$
Global MyElem$

Now you are ready to go. Put something on your String-Stack like this:

MyElem$="Here is the first Element!")

' and POP it off


'You can also just take it off without having it removed:


' Using


You'll get the number of Elements on your String-Stack.

Note: that AddTOS (Add to Top-Of-Stack) currently wants the String BYREF because thats faster. If you want to Add like that:

you need to change it to "BYVAL".

Here is what you can do:

D_Init_Stack_A ' Clear the Stack
D_AddTos_A ' Add one Element
D_GetRemTOS_A ' POP one Element
D_GetTOS_A ' just get a Copy of the upper element
D_RemLast_A ' Remove the TopMost Element
D_GetAnz_A ' See how many Elements are on your Stack

As you can use it with any String, you can have an unlimited number of Stacks!