Hi all,
ran yesterday into a reproducible problem with the Split function:
s=“##”
uName$=“name”
uCompany$=“company”
adr_adr1$=“adr_adr1”
adr_adr2$=“adr_adr2”
adr_nop$=“adr_nop”
ucity$=“city”
pays$=“” '<-empty !!
adr_tel1$=“tel1”
uEmail$=“Email” adr_fax2$=“4711”
adr_dep$=“la la la la”
adr_no$=“1234”
updatefields={SET “name”=[1]
SET “company”=[2]
SET “Address”=[3]
SET “Apt./Suite”=[4]
SET “zip”=[5]
SET “city”=[6]
SET “Addr Intl”=[7]
SET “Pax Office Phone”=[8]
SET “Pax Email”=[9]
SET “Pax Office Fax”=[10]
SET “state”=[11]
SET “Employee Number”=[12]}
x$= updatefields+S+uName$+S+uCompany$+S+_
adr_adr1$+S+adr_adr2$+S+adr_nop$+S+_
uCity$+S+pays$+S+adr_tel1$+s+uEmail$+s+_
adr_fax2$+S+adr_dep$+S+adr_no$
Print x$
Print "---------------"
updatefields=Split(x$, S)
For i%=0 To Ubound(updatefields)
Print updatefields(i%)
Next
<\code>
Because of 1 empty entry we get the situation that 2 separators “####” can be found in the string and Split is not able to handle it.
We got results like this :
…SET “Employee Number”=[12]namecompanyadr_adr1adr_adr2adr_nopcity##tel1##Email##4711##la la la la##1234#tel1##Email##4711##la la la la##1234tel1Email4711la la la la1234
Exactly at the point where there were two separators but no value between them, Split started to become messy.
Joe
Subject: double delimiter
You’re getting the problem because your delimiter is ## (two hashes). If you use one it’ll work
Whether this is a bug or not I’m not sure, you’ve essentially got part of your text as ####, so when splitting it goes through every character looking for ##, so looks at this #### more than once. This is how I understand it anyway, someone else may be able to give a proper answer
Subject: Split / Double separator/Delimiter
Yes, exactly and Split is not able to handle it.
A double separator from the syntactical point of view is nothing else than an empty string surrounded by separators/delimiters.
In the help it is clearly said that :
delimiter
An optional scalar String containing the characters to separate substrings. If delimiter is not specified, then the space character " " is used
<\code>
Subject: I think Split is confused by being given the same separator character twice…
While the Help isn’t as clear as it could be, Split isn’t meant to work with a single separator consisting two or more characters. It’s meant to work like the formula @Explode function, where each character in the separator argument is treated as another separator.
Re-read this part from the Help, noting the section I’ve bolded:
delimiter
An optional scalar String containing the characters to separate substrings. If delimiter is not specified, then the space character " " is used
Basically, it’s trying to treat your S=“##” as two separators, and apparently can’t handle the fact that both separator characters are the same.
If you want “#” as a separator, just use one, like S=“#”.
If you must use a 2-character separator, write a custom function to do it instead of using Split.
Subject: Split & @Explode
Thanks for your response !
SPLIT does not have the same functionality like @Evaluate as my example works with @Evaluate without any problem!
I assume that one can call this a bug.
Joe