Need advice on setting up the logic for script

9 posts in this topic

Bert 1,127

I have a 4 tab GUI with 64 input controls on each tab laid out in a grid. They are named "yesterday", Today", Month to date", and "Year to date"

I have a button that is called "transfer data". When this button is pressed the following will happen:

All data from the 64 input controls in "Today" will be moved to "Yesterday".

All data from "Today" will be added to the "Month to date", unless it is the first of the Month. If it is the first, the data will be erased from "Month to date", then replaced by the data from "Today"

All data from "Today" will be added to the "Year to date", unless it is the first of the year. If it is the first, the data will be erased from "Year to date", then replaced by the data from "Today"

Normally they will be populated with numbers. In that scenario, it is easy to do. However they hit me with a requirement that has me puzzled. Here is my problem.

My client plans to use %, . , and other characters in the fields. I figure I can use stringinstr, along with other things to do it, but I'm stumped as far as the best way to go.

Some examples of what they might enter:

90%

%90

14 sec

13.9

They may put the % in different places, and may use letters. I need to be able to add the numbers, but keep the rest intact when the information is handled from one field to another.

Share this post

Link to post

Share on other sites

seandisanti 1

I have a 4 tab GUI with 64 input controls on each tab laid out in a grid. They are named "yesterday", Today", Month to date", and "Year to date"

I have a button that is called "transfer data". When this button is pressed the following will happen:

All data from the 64 input controls in "Today" will be moved to "Yesterday".

All data from "Today" will be added to the "Month to date", unless it is the first of the Month. If it is the first, the data will be erased from "Month to date", then replaced by the data from "Today"

All data from "Today" will be added to the "Year to date", unless it is the first of the year. If it is the first, the data will be erased from "Year to date", then replaced by the data from "Today"

Normally they will be populated with numbers. In that scenario, it is easy to do. However they hit me with a requirement that has me puzzled. Here is my problem.

My client plans to use %, . , and other characters in the fields. I figure I can use stringinstr, along with other things to do it, but I'm stumped as far as the best way to go.

Some examples of what they might enter:

90%

%90

14 sec

13.9

They may put the % in different places, and may use letters. I need to be able to add the numbers, but keep the rest intact when the information is handled from one field to another.

Thoughts?

you could use a regular expression test to identify the non numeric (except decimal) characters, and one that grabs the numeric/decimal characters. do the math on the numbers obviously, then do a stringinstr() to find out where to replace the rest... if the stringinstr() returns a 1, put them at the beginning, anything greater, concatenate to the end of the result...

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post

Link to post

Share on other sites

Zedna 134

you could use a regular expression test to identify the non numeric (except decimal) characters, and one that grabs the numeric/decimal characters. do the math on the numbers obviously, then do a stringinstr() to find out where to replace the rest... if the stringinstr() returns a 1, put them at the beginning, anything greater, concatenate to the end of the result...

actually, i don't think the OP wants to eliminate the non-numeric, just identify them, and then replace them after necessary additions etc. there's a tutorial in the help file (i'm sorry i don't remember who wrote it) that's a very good one on using regular expressions, that can help with building the expressions for my suggestion

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post

Link to post

Share on other sites

Bert 1,127

actually, i don't think the OP wants to eliminate the non-numeric, just identify them, and then replace them after necessary additions etc. there's a tutorial in the help file (i'm sorry i don't remember who wrote it) that's a very good one on using regular expressions, that can help with building the expressions for my suggestion

Share this post

Link to post

Share on other sites

Valik 467

This doesn't sound that hard if I understand you correctly. What I'd suggest is using StringRegExp() to pull out the numbers. Once you have the numbers, add them or do whatever it is you need to do to them. Then use StringReplace() or something to replace the original number in the string with the newly calclated number.