Page 1 of 1

Static variables in JS scripts

Posted: 25 May 2016 09:30
by rjbill
Is it possible to have a static variable that retains its value between script executions?

Re: Static variables in JS scripts

Posted: 25 May 2016 10:17
by Rickard Johansson
You could save something to disk, maybe using a file stream or a string list...

Re: Static variables in JS scripts

Posted: 25 May 2016 10:45
by rjbill
It would be SO NICE if we had a simple variable scheme
in Quick Macros for Power Users so we could use them
for advanced text manipulation.

At least numeric. String would be a plus.

Even if we only got, say, 9 variables. (I'd settle for ONE; or two for dual-processing)
So we could set a variable to a value, and on each
iteration of the macro we could add or subtract a value from it.
And then be able to insert that value into the buffer at the cursor.
Character padding would be nice, left or right.

Like right now I have a text file (PHP file) that has
786 of these array items:

Code: Select all

      000 => array (
         0 => "000",
         1 => "/watch?v=ZbQTD7QOanE",
         2 => "https://i.ytimg.com/vi/ZbQTD7QOanE/hqdefault.jpg",
         3 => "0:49",
         4 => "description",
         5 => "3 days ago",
         6 => "category",
      ),
And I want to go down through them and change the two instances of
"000" to a zero left padded number starting from 786 and decrementing to 1.

To have to try to write a script to do it is irritating, especially since the
scripting system isn't particularly easy to use.

So I'll probably end up writing a JS or PHP program to manipulate the text.
At least I know those programming languages, so it is easier to do it that way.

But it would be MUCH easier if we had the simple Quick Macro variable(s).