Removing spaces

Hi , I am trying to write an agent to remove spaces from the contents of a field. I have tried several ways and searched in the old forums too but nothing is working. I am testing on a local replica - that shouldn’t matter I assume?

I have tried the following: (where the field name is PartNo)

Formula language

@ReplaceSubstring(PartNo;" “;”");

Script 1 :

Sub Initialize

Dim s As String

Dim v As Variant



s = PartNo



v = Split(s, " ", -1)



s = ""



Forall vals In v

	

	s = s + vals

	

End Forall

End Sub

Script2:

Sub Initialize

Evaluate(|@replacesubstring(PartNo;" ";"")|)

End Sub

I would be reeally grateful for any suggestions as I am now completely stumped! Thanks Anne

Subject: are you using the return value

I can’t tell from your formula code fragments whether this is the problem, but in the past I’ve made the mistake of assuming that @ReplaceSubstring changes the contents of the first argument. It does not - it is the return value that holds the changed value. So your code might look something like:

FIELD PartNo := @ReplaceSubstring(PartNo;" “;”");

Subject: Retrun value

Hi Stuart, no I didn’t set a return value - it looks so obvious now you say it! I just assumed it would change it, I should have thought a bit more! Thanks so much for that, can’t try it until tomorrow but will let you know, Anne

Subject: Thanks Stuart

…that worked perfectly