Replacing variables with numbers from a list

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
happyuser
Posts: 2
Joined: Mon Jun 13, 2005 3:20 am

Replacing variables with numbers from a list

Post 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?
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post 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.
happyuser
Posts: 2
Joined: Mon Jun 13, 2005 3:20 am

Post by happyuser »

All the VBScript subfilter does is place consecutive numbers at the end of each of my lines.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

Try changing the VBScript code to suit the task at hand.
Post Reply