Replacing variables with numbers from a list

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Replacing variables with numbers from a list

Postby happyuser » Mon Jun 13, 2005 3:30 am

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: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Mon Jun 13, 2005 10:26 am

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

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

Postby happyuser » Mon Jun 13, 2005 12:02 pm

All the VBScript subfilter does is place consecutive numbers at the end of each of my lines.

User avatar
DataMystic Support
Site Admin
Posts: 2136
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Postby DataMystic Support » Tue Jun 14, 2005 8:53 am

Try changing the VBScript code to suit the task at hand.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot] and 1 guest