Scripting: repeated variable processing
Posted: 28 Aug 2008 11:16
Here's a mean little problem. Currently I first resolve user vars, then XY vars. This leads to the problem shown below (The The <clipboard> is exploding! is exploding!). In msg $a first $a is correctly resolved to "The <clipboard> is exploding!", but immediately after <clipboard> is filled with the current clipboard contents. This can be fixed by reversing the order of resolving. But as you see below, this of course leads straight to a new and analogue problem, that has not been there before.
In short, the problem is that user vars can contain XY vars, and vice versa (the same game can be played with Environment vars...), leading to repeated processing. Reordering is no solution.
Examples:
1: First resolve user vars, then XY vars
2: First resolve XY vars, then user vars
::copytext 'The <clipboard> is exploding!'; set $a, <clipboard>; msg $a
1: > The The <clipboard> is exploding! is exploding!
BAD
2: > The <clipboard> is exploding!
GOOD
::set $c, 'ROAAR!!!'; copytext '$c'; msg <clipboard>
1: > $c
GOOD
2: > ROAAR!!!
BAD
I know I solved the problem of repeated processing yesterday for user vars containing other user vars. But the solution is not good for mixed var types.
A possible (bad) solution
Drop automatic resolving of ENV and XY vars, and move the task to special commands.
Unfortunately, scripting will become a bit clumsy then...
BEFORE
::msg '%TMP% = ' . %TMP%;
::msg "The time is <date hh:nn:ss>."
AFTER
::setenv $temp, %TMP%; msg "%TMP% = $temp";
::setxy $time, <date hh:nn:ss>; msg "The time is $time."
Not so nice...
... (meditation mode) ...
Thanks for listening -- I think I know what to do now...
In short, the problem is that user vars can contain XY vars, and vice versa (the same game can be played with Environment vars...), leading to repeated processing. Reordering is no solution.
Examples:
1: First resolve user vars, then XY vars
2: First resolve XY vars, then user vars
::copytext 'The <clipboard> is exploding!'; set $a, <clipboard>; msg $a
1: > The The <clipboard> is exploding! is exploding!
BAD
2: > The <clipboard> is exploding!
GOOD
::set $c, 'ROAAR!!!'; copytext '$c'; msg <clipboard>
1: > $c
GOOD
2: > ROAAR!!!
BAD
I know I solved the problem of repeated processing yesterday for user vars containing other user vars. But the solution is not good for mixed var types.
A possible (bad) solution
Drop automatic resolving of ENV and XY vars, and move the task to special commands.
Unfortunately, scripting will become a bit clumsy then...
BEFORE
::msg '%TMP% = ' . %TMP%;
::msg "The time is <date hh:nn:ss>."
AFTER
::setenv $temp, %TMP%; msg "%TMP% = $temp";
::setxy $time, <date hh:nn:ss>; msg "The time is $time."
... (meditation mode) ...
Thanks for listening -- I think I know what to do now...