Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question for Advanced CR Designers

Status
Not open for further replies.

MSGCR

Technical User
Sep 16, 2004
16
US
Need help with formula for array. For example:
Given a string like this,
"1;1500;3804^^0.757;2200;2880"
I'd like to stuff 3804 and 2880 in the array and then sum those numbers.

I want to split the string by the '^^' character, then split the element by the ';' and take the 3rd element. There could be more than two elements when splitting by '^^', but always only 3 ';' within that element.

Sorry if this is confusing. Thanks for the help.
 
Fun stuff...
[tt]
StringVar str := "1;1500;3804^^0.757;2200;2880";
StringVar Array splitter := Split(str, "^^");
NumberVar summary := 0;
NumberVar i;

for i := 1 to Count(Splitter) do(
summary := summary + Val(Split(Splitter, ";")[3]);
);

summary;
[/tt]
-dave
 
That works. You are a bad ass. Thanks a million!
 
I like working with formulas, so here is my condensed take on it:

Code:
stringvar array nums := split(replace("1;1500;3804^^0.757;2200;2880","^^",";"),";");

val(nums[3]) + val(nums[6])

~Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top