|
Dyron Apprentice
Joined: 08 Apr 2004 Posts: 103 Location: USA
|
Posted: Wed Oct 08, 2008 3:58 am
Contact/String Variables question |
Okay here's my code.
Code: |
afflictions=%concat( @afflictions, "|", @pendafflictions)
Cures=%concat( @Cures, "|", @pendCures)
pendafflictions=""
pendCures=""
|
I've got two problems I'm currently seeing..
First, if pendafflictions is empty every time it concats.. it adds a blank line to the afflictions variable.
Second, if there is something to concat, it will keep adding the same affliction.
Example:
blank line
blank line
burning
blank line
burning
blank line
blank line
blank line
burning
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Wed Oct 08, 2008 4:33 am |
Use #IF to check if the @pendaffliction is empty or null
Code: |
#IF (!%null(@pendafflictions)) { afflictions=%concat( @afflictions, "|", @pendafflictions) } |
For you second it's best to loop through @pendafflictions (assuming it's a string list) and use #ADDITEM to add them to cures.
Something like the following should do the trick.
Code: |
#FORALL @pendafflictions {#ADDITEM @Cures %i} |
Actually that second bit of code should take care of both problems. |
|
_________________ Asati di tempari! |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Oct 08, 2008 8:06 am |
Though you don't need the double negative !%null... just doing #if (@pendafflictions) will do.
But yes, the #forall and #additem is a better way to go about it. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Oct 08, 2008 5:04 pm |
You could also maybe use %additem/#additem to add the entire @pendafflictions list to the afflictions list. This, of course, will cause parentheses to be placed around this sublist, but two %replace() functions will handle that pretty effectively.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
|
|