Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Trim question

 [1/5] from: sharriff:aina:med-iq at: 10-Oct-2000 16:49


Can someone tell me what makes this fail?
>> a: { one two
{ three four } == " one two^/ three four "
>> a2: trim/auto copy a
== "one two^/ three four "
>> a3: trim/with "^/" copy a2
== ""
>>
or this? ""
>> a3: trim/all copy a2
== "onetwothreefour"
>> a4: trim/with "two" copy a3
== ""
>>
I thought the "TRIM/WITH" command removes the supplied string value and returns the rest of the string. I tried out the examples in the new core manual, page 235. Best regards Sharriff Aina med.iq information & quality in healthcare AG

 [2/5] from: brett:codeconscious at: 11-Oct-2000 10:17


> Can someone tell me what makes this fail? > > >> a: { one two > { three four } > == " one two^/ three four " > >> a2: trim/auto copy a > == "one two^/ three four "
This I cannot explain. It doesn't look right at all. However if you define the source string differently it works: trim/auto copy rejoin [" one two" newline " three four " ] == "one two^/three four "
> >> a3: trim/with "^/" copy a2 > == ""
You got your parameters in the wrong order. Should be:
>> a3: trim/with copy a2 "^/"
== "one two three four "
> or this? > > "" > >> a3: trim/all copy a2 > == "onetwothreefour"
Is correct
> >> a4: trim/with "two" copy a3 > == ""
Again, the order of your parameters is wrong. Do this instead:
>> a4: trim/with copy a3 "two"
== "nehreefur"
> I thought the "TRIM/WITH" command removes the supplied string value and > returns the rest of the string. I tried out the examples in the new core > manual, page 235.
No. Trim/with interprets the supplied string value as a set of characters that must be removed from the source string. It does not remove sub-strings. HTH, Brett

 [3/5] from: rryost:home at: 10-Oct-2000 16:11


I think you have the two argument strings interchanged. Also, all the characters in the 'with string are used separately. A console session:
>> a: "onetwothreefour"
== "onetwothreefour"
>> a3: trim/with copy a "two"
== "nehreefur"
>>
Russell [rryost--home--com]

 [4/5] from: rryost::home::com at: 10-Oct-2000 16:23


I think you have the two args interchanged. See the following console session:
>> a: "onetwothreefour"
== "onetwothreefour"
>> a1: trim/with copy a "two"
== "nehreefur"
>>
All the characters in the 'with string are used separately. Russell [rryost--home--com]

 [5/5] from: ingo:2b1 at: 11-Oct-2000 8:54


Once upon a time [brett--codeconscious--com] spoketh thus:
> > Can someone tell me what makes this fail? > >
<<quoted lines omitted: 3>>
> > >> a2: trim/auto copy a > > == "one two^/ three four "
<...> As to my understanding it's correct: trim/auto unindents the first line, and conserves indentation relative to this line, let's see
>> print trim/auto {abc^/ def}
abc def
>> print trim/auto { abc^/ def}
abc def
>> print trim/auto { abc^/ def}
abc def In the first example nothing got changed, because the first line wasn't indented. In the second all whitespace got deleted, because the lines were indented equally, and in the last example the three spaces that the second line was indented deeper were preserved. I hope that helps, Ingo

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted