Issue while filtering a received string
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller
Issue while filtering a received string
Hi there
I receive a string from a distant server containing a list of files(including their folder), aka :
Folder1/File1
Folder1/File2
Folder2/File3
etc
I want put this into a dataGrid and be able to filter those within folder.
I manage to emulate a menu button to choose the folder
with this code :
put textString into the field "tempList"
replace "/" with " " in the field "tempList"
repeat for each line tLine in the field "tempList"
Put the first word of tLine & format("\r\n") after foldText
end repeat
split foldText by return and return
combine foldText by return and empty
delete the last char of foldText
put foldText into the button "templatefold"
set the ListFold of the button "templatefold" to foldText
(I created a custom key "ListFold" onto the button)
But when I want to filter using the option button, only the last folder returns the right result, the others return nothing, I tried lots of methods but all failed, here is my last button script :
on mouseUp
put line (the menuHistory of me) of the ListFold of me into tSelectedLine
put tSelectedLine & format("*") into tSelectL
filter lines of field "tempList" with tSelectL into theFilteredList
put theFilteredList into the field "test"
end mouseUp
Does someone faced such an issue ? Please let me know. Thx
I receive a string from a distant server containing a list of files(including their folder), aka :
Folder1/File1
Folder1/File2
Folder2/File3
etc
I want put this into a dataGrid and be able to filter those within folder.
I manage to emulate a menu button to choose the folder
with this code :
put textString into the field "tempList"
replace "/" with " " in the field "tempList"
repeat for each line tLine in the field "tempList"
Put the first word of tLine & format("\r\n") after foldText
end repeat
split foldText by return and return
combine foldText by return and empty
delete the last char of foldText
put foldText into the button "templatefold"
set the ListFold of the button "templatefold" to foldText
(I created a custom key "ListFold" onto the button)
But when I want to filter using the option button, only the last folder returns the right result, the others return nothing, I tried lots of methods but all failed, here is my last button script :
on mouseUp
put line (the menuHistory of me) of the ListFold of me into tSelectedLine
put tSelectedLine & format("*") into tSelectL
filter lines of field "tempList" with tSelectL into theFilteredList
put theFilteredList into the field "test"
end mouseUp
Does someone faced such an issue ? Please let me know. Thx
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Issue while filtering a received string
Try this:
You don't need to use "the" when referring to object names, BTW.
For the option button:
I didn't test, so you may need to adjust the script.
Code: Select all
put textString into tList
split tList by cr and slash
put the keys of tList into button "templatefold"
For the option button:
Code: Select all
put the text of line (the menuhistory of me) of me into tFolder
filter lines of field "templist" with tFolder
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Issue while filtering a received string
Hi jacque
thanks for your answer.
I tried your solution :
the first code nicely populates the button.
But the second code (option button one) sends to an error :
Did I miss something ?
thanks again
thanks for your answer.
I tried your solution :
the first code nicely populates the button.
But the second code (option button one) sends to an error :
Code: Select all
button "templatefold": execution error at line 5 (Object: object does not have this property), char 17
thanks again
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Issue while filtering a received string
Post the whole button script so we can see what's happening. I only provided a couple of lines, so something else is going on.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Issue while filtering a received string
Hi Jacque
here is the retrieved string:
here is the script of the card:
and finally the script of the button:
thanks
here is the retrieved string:
Code: Select all
OLD/FRAMESSSS
OLD/NTSC-TEST-30
OLD/NTSC-TEST-60
OLD/PHONE
OLD/SCORE_STARS2
TITRE/1MANDARIN
TITRE/BASIC2_A
TITRE/COMINGUPNEXT2FIELDS
XTEMPLATE/INDEX
SCORE/1SCORE_STARS2
SCORE/12CHAMPS
SCORE/8CHAMPS
SCORE/24CHAMPS
HTML_TEMPLATE/TEMPLATE2
HTML_TEMPLATE/TEMPLATE
ESPORT-TEMPLATES-MASTER/01_INTERVIEW
ESPORT-TEMPLATES-MASTER/00_TEMPLATE
ESPORT-TEMPLATES-MASTER/02_CASTERS
ESPORT-TEMPLATES-MASTER/10_BRACKET
ESPORT-TEMPLATES-MASTER/11_ADROTATE
ESPORT-TEMPLATES-MASTER/12_TIMETABLE
ESPORT-TEMPLATES-MASTER/17_HSMAINOKSET
ESPORT-TEMPLATES-MASTER/13_GROUP
ESPORT-TEMPLATES-MASTER/20_CLOCK
ESPORT-TEMPLATES-MASTER/18_HSINGAME
ESPORT-TEMPLATES-MASTER/19_GAMERS
ESPORT-TEMPLATES-MASTER/50_TITLESAFE
ESPORT-TEMPLATES-MASTER/TESTFRAME
Code: Select all
put textString into field "tempList"
replace "/" with " " in field "tempList"
repeat for each line tLine in field "tempList"
if the first word of tLine ="SCORE" or the first word of tLine = "200" or the first word of tLine = "202" or the first word of tLine = "" or the first word of tLine = "403" or the first word of tLine = "404"
then
put tLine into tDump
else
Put the first word of tLine & format("\r\n") after foldText
delete the first word of tLine
Put tLine & format("\r\n") after gridText
end if
end repeat
split foldText by cr and slash
put the keys of foldText into button "templatefold"
set the dgText of group gMedia to gridText
Code: Select all
on mouseUp
put the text of line (the menuhistory of me) of me into tFolder
filter lines of field "templist" with tFolder into field "test"
end mouseUp
Re: Issue while filtering a received string
you could set the itemdelimiter to "/"
put item 1 of line tLine into a variable
if the variable is "SCORE"
put item 2 of line tLine into another variable (which is the rest of your line)
put item 1 of line tLine into a variable
if the variable is "SCORE"
put item 2 of line tLine into another variable (which is the rest of your line)
Re: Issue while filtering a received string
Thank you Sphere
I'm a new LC user and didn't know the itemDelimiter which is quite usefull.
However, my problem remains the same in the final part :
I early succeed to build the menu button dynamically (but updated to follow your method).
The things is that it still refuses to filter my gridtext, except for the last choice of my button and I can't explain why...
If a genious idea comes to anyone, please let me know.
Thanks
I'm a new LC user and didn't know the itemDelimiter which is quite usefull.
However, my problem remains the same in the final part :
I early succeed to build the menu button dynamically (but updated to follow your method).
The things is that it still refuses to filter my gridtext, except for the last choice of my button and I can't explain why...
If a genious idea comes to anyone, please let me know.
Thanks
-
- VIP Livecode Opensource Backer
- Posts: 7258
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Issue while filtering a received string
Accessing fields is one of the slowest things in LC so it is always better to move the text to a variable, process it, and then put it back. But since you're just testing I've left most of the field access the way you have it now.
For the card script (I named the handler, since you didn't include that, but use whatever method you use instead):
You'll probably see some new ideas in there, mainly the "among" keyword which makes it easier to access parts of a list of things instead of writing each one out in the script.
For the option button, use the "label" property instead of the menuhistory. I also gave you an incomplete filter command which needed an asterisk:
The format command is rarely needed. What you're looking for is the constant "cr" which indicates a carriage return. CR will match the line ending of the current OS, so you don't need to worry whether you need a return, a linefeed, or a return-linefeed. It's all automatic.
For the card script (I named the handler, since you didn't include that, but use whatever method you use instead):
Code: Select all
on processText
put fld 1 into textString
put textString into field "tempList"
replace "/" with " " in textString
put "SCORE,200,202,403,404" into tRejects
repeat for each line tLine in textString
if the first word of tLine <> "" and the first word of tLine is not among the items of tRejects then
put the first word of tLine & cr after foldText
delete the first word of tLine
put tLine & cr after gridText
end if
end repeat
split foldText by cr and slash
put the keys of foldText into button "templatefold"
set the dgText of group gMedia to gridText
end processText
For the option button, use the "label" property instead of the menuhistory. I also gave you an incomplete filter command which needed an asterisk:
Code: Select all
on mouseUp
put the label of me into tFolder
filter lines of field "templist" with (tFolder & "*") into field "test"
end mouseUp
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Issue while filtering a received string
Thank you jacque
it's perfectly working
best
it's perfectly working
best