Page 1 of 1

item 1+2

Posted: Mon May 26, 2014 4:31 pm
by robm80
Why does 1+2 goes wrong and 1+2+3 does nothing; have a look:

get "Foo, John,Westerveen 29,9751 HT,HAREN,,,,,,de Heer en Mevrouw; "
put item 1+2 of it

answer="Westerveen 29", but I expected "Foo John
put item 2+3 of it gives "Haren", also wrong, expected "John,Westerveen 29""


But asking for more items like items 2+3+4 does nothing.

Why?

Re: item 1+2

Posted: Mon May 26, 2014 4:36 pm
by Klaus
Hi Rob,
Why?
because the engine will first add 1 + 3 = 3 and deliver you item 3 (1+2) of it 8)
You need to use the & sign!
...
put item 1 of it && item 2 of it
...
&& will concatenate two strings with a SPACE between them!


Best

Klaus

Re: item 1+2

Posted: Mon May 26, 2014 6:17 pm
by dunbarx
Rob.

What Klaus said.

But it isn't the space that is important, it is what you wanted out of your original construction. Extracting two separate chunks from a string requires two separate chunk operations.

Imagine you had a return delimited list instead, and wanted the first and third line as a new list:

Fred
John
Harry

I bet you will see that the following is a tad wrongheaded (PseudoCode);

answer line 1 + 3

Fred
Harry

You would rather: answer line 1 & return & line 3

Craig Newman

Re: item 1+2

Posted: Mon May 26, 2014 8:43 pm
by robm80
Hi Klaus e.o.

Is there not an equivalent of put chars 1 to 6 of "abcdefghijklmn"
answer "abcdef"

or

get "Foo, John,Westerveen 29,9751 HT,HAREN,,,,,,de Heer en Mevrouw; "
or put items 1 to 3 of it
answer "Foo, John,Westerveen 29"

It could make scripting a bit easier....

Re: item 1+2

Posted: Mon May 26, 2014 10:10 pm
by Klaus
Hi Rob.

yes, you can:
...
put "Foo, John,Westerveen 29,9751 HT,HAREN,,,,,,de Heer en Mevrouw; " into tVar
put item 1 to 2 of tvar
## -> Foo, John
## Including the itemdelimiter, if that is what you want!
...


Best

Klaus

Re: item 1+2

Posted: Tue May 27, 2014 2:14 am
by dunbarx
What Klaus said again.

It is just a matter of getting used to the syntax. If you look back, you will see that simply (mentally and physically) replacing "+" with "to" is all it takes to make it all work.

Craig

Re: item 1+2

Posted: Tue May 27, 2014 8:52 am
by robm80
hi Klaus + Craig
Yes, changing the + to "to" is exactly I was looking for.
But where did I find that + ?: in "menus.rev" recommende by Klaus. BTW very interesting stuff all those rev's.

Re: item 1+2

Posted: Tue May 27, 2014 11:26 am
by Klaus
Hi Rob,

you mean in the "Menus" stack from teh scripting conferences?
Where exactly is this?

I just had alook at that stack and did not find any hint about
using + for concatenating strings.


Best

Klaus