Generic scripting questions.

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Generic scripting questions.

Post by tiago »

1. If a certain condition is met, a string should be stored on a variable created by the time of the finding of this string. How?
>>String "Car" is met. By the time of script execution I have variables '$var1' and '$var2' filled with other strings. How do I store "Car" as a new variable '$var3', which for now doesn't exists and may or may not reach higher numbers like > $var40, being the limit the number of strings requiring such a thing?

2. Below example script* should have the $tim calculated each it's run but it isn't at all. Why?

Code: Select all

   $typ = rand(2, 9);
   $tim = "rand" . "(1, 9) " . "* 100," . " rand" . "(1, 9) " . "* 100";
   IF ($typ == 2) { beep $tim; beep $tim; }
   ELSEIF ($typ == 3) { beep $tim; beep $tim; beep $tim; }
   ELSEIF ($typ == 4) { beep $tim; beep $tim; beep $tim; beep $tim; }
   ELSEIF ($typ == 5) { beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; }
   ELSEIF ($typ == 6) { beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; }
   ELSEIF ($typ == 7) { beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; }
   ELSEIF ($typ == 8) { beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; }
   ELSEIF ($typ == 9) { beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; }
*sorry this was the simplest thing that came up to mind to tell what I have in mind.

3. Is there a way to shorten it?
Power-hungry user!!!

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Generic scripting questions.

Post by Stefan »

1.) not possible. Create the vars all at the beginning. Or better reduce your amount of vars.

2.) You build and want to execute an string.
$tim = "rand" . "(1, 9) " . "* 100," . " rand" . "(1, 9) " . "* 100";

Better use smtg like:

Code: Select all

 $timF = rand(1, 9) * 100; $timD = rand(1, 9) * 100;

  //test
    msg "beep $timF, $timD";
    beep $timF, $timD;

3.)

Code: Select all

ELSEIF ($typ == 9) { beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; beep $tim; }

ELSEIF ($typ == 9) {  $L=1;  while($L<=9){beep $tim; wait 1000;  $L++;} }
or even more:

Code: Select all

$typ = rand(2, 9);
 status $typ times;

 $timF = rand(1, 9) * 100; $timD = rand(1, 9) * 100;
 $L=1; while($L <= $typ) {beep $timF, $timD; wait 1000; $L++;}

 status $typ times finished;

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Generic scripting questions.

Post by tiago »

1. not possible. My problem here is that I need to auto collect files from a server storing them under alphabetized folders on different clients. Non-alphanumeric files will be collected under their initials if they exceed 20 files each check and will be redirected to different people so they can human review, rename each of those, according to the content of each file. In other words the variables must be unpredictable so to speak. New unpredictable variables will generate new corresponding predefined commands which will deal with them properly. It's a concept I'm working with to reduce the time spent on such tasks.

2. take the script as it is or fixed according to 3: I need the $tim value being resolved each time it is run, see? Otherwise it'll beep the same, multiplied by $typ. It's a common situation I face and I'd like a solution for this. As you can see I'm expecting to store commands under variables thus producing smaller, cleaner codes.

3. that's it, shorter and smarter! TY!
Power-hungry user!!!

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Generic scripting questions.

Post by Stefan »

@1
then use an ini as an array
and use "setkey xx yy;" instead of "set $var= xxx;"

The "key" in "setkey value, key, section, [INIfile]"
can be set via an incremented $var
"setkey value, $iteration, section, [INIfile]"

Something like shown there > SessionManager - Store and Load Tabs

tiago
Posts: 589
Joined: 14 Feb 2011 21:41

Re: Generic scripting questions.

Post by tiago »

Stefan wrote:@1
then use an ini as an array
and use "setkey xx yy;" instead of "set $var= xxx;"

The "key" in "setkey value, key, section, [INIfile]"
can be set via an incremented $var
"setkey value, $iteration, section, [INIfile]"

Something like shown there > SessionManager - Store and Load Tabs
That'll be enough per my first tests. The only problem is that part of the operation will be accessible to users which is why I'd like it being handled entirely on memory.

Admin, can you please give a word on case 2? IE, can you provide a way a series of commands stored on a variable being able to be resolved at any time?
Power-hungry user!!!

Post Reply