Page 1 of 1

Replacing variables with numbers from a list

Posted: Mon Jun 13, 2005 3:30 am
by happyuser
I'm wondering if it would be possible to replace a variable with a value from a list of numbers. The catch being that as each new 'Find' is found the 'replacement' will be the next value on a list. This is what I want to do.

Turning this:

Code: Select all

 elsif ($item_total_weight <=XX) {
$ship_total_1 = A;
$ship_total_2 = B;
$ship_total_3 = C;
$ship_total_4 = D;
} elsif ($item_total_weight <=XX) {
$ship_total_1 = A;
$ship_total_2 = B;
$ship_total_3 = C;
$ship_total_4 = D;
}
To this:

Code: Select all

 elsif ($item_total_weight <=1) {
$ship_total_1 = 1;
$ship_total_2 = 11;
$ship_total_3 = 22;
$ship_total_4 = 33;
} elsif ($item_total_weight <=2) {
$ship_total_1 = 2;
$ship_total_2 = 12;
$ship_total_3 = 23;
$ship_total_4 = 34;
}
I want the XX variable to change from 1 to 2 to 3 etc. as each new 'find' occurs. And I want the A,B,C and D variables to be 'replaced' by a number from a NotePad file that would be formated as a list. I have to do this 150 times. That would take time. That would be 600 numbers I have to manually insert. I don't want to do that all manually. Is this possible using this program?

Posted: Mon Jun 13, 2005 10:26 am
by DataMystic Support
Yes - use a VBScript subfilter inside a search/replace for 'XX' to count how many replacements have been made, and then return the appropriate text.

You can also get it to read values from a text file.

Posted: Mon Jun 13, 2005 12:02 pm
by happyuser
All the VBScript subfilter does is place consecutive numbers at the end of each of my lines.

Posted: Tue Jun 14, 2005 8:53 am
by DataMystic Support
Try changing the VBScript code to suit the task at hand.