|
miegorengman Wanderer
Joined: 05 Sep 2008 Posts: 51
|
Posted: Sat Jul 23, 2022 6:35 am
temporary variable |
is there a way to make a temporary variable within a script? I have a looooooooooooooooooong #sw that is already pretty bad, and instead of including a computation in each ifthen, I would like to run the calc once, assign the value to a temp variable, and then have the #sw refer to the temp variable.
what I hope to achieve
Code: |
tempvar=%right(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),%match(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),"="))
#SW (tempvar>0)AND(tempvar<4) {Unskilled} (tempvar>3)AND(tempvar<10) {A tyro} (tempvar>9)AND(tempvar<18) {A novice}........ |
this is what I could end up with if I don't
Code: |
#SW (%right(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),%match(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),"="))>0)AND(%right(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),%match(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),"="))<4) {Unskilled} (%right(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),%match(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),"="))>3)AND(%right(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),%match(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),"="))<10) {A tyro} (%right(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),%match(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),"="))>9)AND(%right(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),%match(%item(%exec("%countlist(@sniffsRawCounter)"),@petsRowNumber),"="))<18) {A novice}........ |
Thank you for reading |
|
|
|
Tarn GURU
Joined: 10 Oct 2000 Posts: 873 Location: USA
|
Posted: Sat Jul 23, 2022 6:18 pm |
If you mean that you want to get rid of it when you're done using it,
#UNVAR
Or, you can create one that has only local scope within the script:
#LOCAL |
|
|
|
chaossdragon Apprentice
Joined: 09 Apr 2008 Posts: 168
|
Posted: Sat Jul 23, 2022 11:07 pm |
As Tarn said. Use "#LOCAL {tempVar}" then reference it with $tempVar
if you don't define it with #LOCAL it will dump the tempVar once the inital {script} is closed, so any further calls on it will be a 'new' tempVar and have no value. |
|
|
|
miegorengman Wanderer
Joined: 05 Sep 2008 Posts: 51
|
Posted: Sun Jul 24, 2022 4:15 am |
thank you both, local worked great!
|
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|