I have tried different @ functions and script and yet did not find anything that will give me the right answer. I am trying to get the values of a string, my string looks like this;
apple~oranges~jus~bread what I would like to get is apple~oranges the structure of the string will always be the same… I need to create the code using script
any ideas
P.
Subject: Need to get part of a value from a sting.
does the values that you are looking for always land in the same spot of the string?
send me an e-mail and I will see what I can do to help you
Subject: Need to get part of a value from a sting.
First, you can split the string.Since you need LotusScript …
Option #1:
dim list as variant
list = Evaluate( {@Explode(“} & “your string” & {”;“~”)} )
Option #2:
— This one converts the tilde to a “:” so that the list resembles a formula list. The result is that evaluate does not need a formula and just returns the array…
dim list as variant
dim s as string
s = Replace( “yourstring”, “~”, {“:”} )
list = Evaluate( {“} & s & {”} )
Then loop through your string and collect the values you need.
Subject: RE: Need to get part of a value from a sting.
But why invoke the formula engine for such a simple operation?
Dim strGroceryString as String
Dim varGroceryArray as Variant
strGroceryString$ = “apple~oranges~jus~bread”
varGroceryArray = split(strGroceryString$, “~”)
forall g in varGroceryArray
print g
end forall
'// if you know, for instance, that you want the first two elements
strGroceryString$ = varGroceryArray(0) & " " & varGroceryArray(1)
You could also use StrToken but I would guess that, depending on the number of elements you need and the length of the string in question, it might be less efficient than just parsing the whole string into an array in one pass.
dgg
Subject: Need to get part of a value from a sting.
x := “apple~oranges~jus~bread”; requestedElements := 2; @Implode(@Subset(@Explode(x; “~”); requestedElements); “~”)