| www.ClassicTW.com https://mail.black-squirrel.com/ |
|
| How-to Passing Parameters to a goSub https://mail.black-squirrel.com/viewtopic.php?f=15&t=32434 |
Page 1 of 1 |
| Author: | Promethius [ Sun Oct 23, 2011 2:16 pm ] |
| Post subject: | How-to Passing Parameters to a goSub |
One of the issues I deal with is the inability to pass parameters for certain scripts to a goSub. An example of a workaround is below, but it is just typed in and not tested. It is a simple right side padding gosub, and does have a limitation in that you must know how many words are in it - this version anyway There are scripts out that do this already, most bots for instance, but for a new scripter writing their first scripts w/o coding knowledge this might help. Feel free to post improvements to this and alternate ways of doing it such as making it a pad routine for left and right and center. Code: // I want the gosub, padR to be reusable so // I pass it the variable to be padded and a second entry as the length. // So to pad a sector number to a length of 5, the following would work // |- var to pad // | |- length to pad // v v setVar $padR $firstHit[$sect] & " 5" goSub :padR setVar $gType[$lineCnt] $padR & " -- Some information" // goSubs :padR // get the length of padding from our variable getword $padR $padding 2 // get the actual word in the variable to pad getword $padR $padR 1 // get the vars length getLength $padR $len // do it setVar $i 1 while ($i <= $padding) setVar $padR $padR & " " add $i 1 end return |
|
| Page 1 of 1 | All times are UTC - 5 hours |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|