|
Tanuki Novice
Joined: 06 Nov 2008 Posts: 38
|
Posted: Mon Nov 12, 2012 7:26 pm
Stack Helper Functions |
I just thought I would give back a little and save someone some time. If this belongs somewhere else let me know and I will move it.
This first Function will take a Sentence and return a Stack or List.
Example:
#Trigger { (*) }
#VAR MyStack @CreateStack(%1)
This will turn anything into "This|will|turn|anything|into" a list
Code: |
<func name="CreateStack" id="10">
<value>$Stack = %trim(%replace( $String, " ", "|"))
#Return $Stack</value>
<arglist>$String</arglist>
</func> |
The Second Function will reverse the list.
Example
#echo @ReverseStack(@MyStack)
Will return
"into|anything|turn|will|This"
Code: |
<func name="ReverseStack" id="13">
<value>#VAR ReversedStack ""
#VAR $Count %numitems($Stack)
#LOOP $Count,1 {#ADDITEM ReversedStack %item(@Stack,%i)}
#Return @ReversedStack</value>
<arglist>$Stack</arglist>
</func> |
|
|
Last edited by Tanuki on Mon Nov 12, 2012 10:07 pm; edited 1 time in total |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Nov 12, 2012 9:48 pm |
Your first function actually already exists built-in - %list ;)
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Mon Nov 12, 2012 10:37 pm |
nevermind
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Tanuki Novice
Joined: 06 Nov 2008 Posts: 38
|
Posted: Mon Nov 12, 2012 11:27 pm |
Good to know... I keep needing it and didn't want redundant code.
|
|
|
|
|
|