Static variables in JS scripts

Ask questions about how to create a script or swap scripts with other users.
Post Reply
User avatar
rjbill
Posts: 832
Joined: 13 Jun 2011 06:36

Static variables in JS scripts

Post by rjbill »

Is it possible to have a static variable that retains its value between script executions?
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

User avatar
Rickard Johansson
Site Admin
Posts: 6001
Joined: 19 Jul 2006 14:29

Re: Static variables in JS scripts

Post by Rickard Johansson »

You could save something to disk, maybe using a file stream or a string list...

User avatar
rjbill
Posts: 832
Joined: 13 Jun 2011 06:36

Re: Static variables in JS scripts

Post 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).
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

Post Reply