number of items?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
number of items?
Can I count the numbers of items after setting the item delimiter?
-
- VIP Livecode Opensource Backer
- Posts: 2718
- Joined: Sat Dec 22, 2007 5:35 pm
- Location: Genève
- Contact:
Re: number of items?
Hi Tusa,
Yes we can.
Best regards
Jean-Marc
Yes we can.
Code: Select all
on mouseUp
put "A_B_C" into tVar
set the itemdel to "_"
put the num of items of tVar into tNbItems
set the itemdel to ","-- dont forget this
answer "Num of items of tVar =" && tNbItems
end mouseUp
Jean-Marc
https://alternatic.ch
Re: number of items?
Hi Jean-Marc,
the itemdelimiter is a LOCAL property and will automatically be reset to COMMA
after a handler is finished, so no need for this in your example!
Best
Klaus
the itemdelimiter is a LOCAL property and will automatically be reset to COMMA
after a handler is finished, so no need for this in your example!
Best
Klaus
Re: number of items?
Hi Tue,
You can even swith itemdelimiters to your needs inside of a handler!
To reference your previous (and obviously deleted) posting :
Hint:
"the num of items" will be 1 even if there is NO itemdelimiter at all in the string to examine!
Best
Klaus
as Jean-Marc already said, yes, this is surely possible!tusa wrote:Can I count the numbers of items after setting the item delimiter?
You can even swith itemdelimiters to your needs inside of a handler!
To reference your previous (and obviously deleted) posting :
Code: Select all
...
put line 2 of the dgtext of grp "my wonderful datagrid" into aVar
## tVar now contains X number of items with TAB delimited
set itemdel to TAB
repeat with i= 1 to the num of items of tVar
put item i of tVar into tVar2
set itemdel to ";"
put "The num of items delimited with ; in item 1 of tVar = " & the num of items of tVar2 & CR after fld "Item info"
## IMPORTANT or the repeat loop will break:
set itemdel to TAB
end repeat
...
"the num of items" will be 1 even if there is NO itemdelimiter at all in the string to examine!
Best
Klaus
Re: number of items?
Thank you, that solved my problem.
I did only use part of your suggestion, but that was what I needed.
I did only use part of your suggestion, but that was what I needed.