Page 1 of 1
Finding among column1 (wordchunk 1) of text file ?
Posted: Wed Apr 24, 2019 4:11 pm
by shawnblc
I'm trying to find just the text in column 1 of the text file, having difficulty. I've tried to use word 1, segment,. Can you give me some hints on the how to process this?
Code: Select all
put fld "fld1" into tFile1
put URL "http://domain.com/1.text" into tFile
if tFile1 is among the words of tFile then
....
My text file looks like this (set itemdel as TAB)
Code: Select all
sometext here somemoretext somemore text is here
Re: Finding among column1 (wordchunk 1) of text file ?
Posted: Wed Apr 24, 2019 4:23 pm
by Klaus
Hi Shawn,
you should try this:
Code: Select all
...
put URL "http://domain.com/1.text" into tFile
if tFile contains tFile1 then
...
But that will also be true if tFile1 may be found in column 2 or 3!
I would use a repeat loop:
Code: Select all
...
set itemdel to TAB
repeat for each line tLine in tFile
if item 1 of tLine = tFile1 then
## Found it, do something
end if
end repeat
...
Best
Klaus
Re: Finding among column1 (wordchunk 1) of text file ?
Posted: Wed Apr 24, 2019 11:22 pm
by shawnblc
I keep getting no, no matter what. Racking my brain.
Code: Select all
on mouseUp
put fld "fld1" into tLine
set itemDel to TAB
put URL "http://*********.on-rev.com/testing123.txt" into tFile
--answer tFile - shows the file
repeat for each line tLine in tFile
if item 1 of tLine = tFile then
answer "Yes" else
answer "No"
end if
end repeat
end mouseUp
Re: Finding among column1 (wordchunk 1) of text file ?
Posted: Thu Apr 25, 2019 12:31 am
by dunbarx
Hi.
You are comparing the first item in each line with the entire contents of tFile, the result of the URL call. That cannot be right.
Craig
Re: Finding among column1 (wordchunk 1) of text file ?
Posted: Thu Apr 25, 2019 9:28 am
by Klaus
That is not what I wrote!
I used your variables -> tFile and tFile1 as in your posting, so please look again!
This will work as in my fist proposal:
Code: Select all
on mouseUp
## Please look up REPEAT FOR EACH in the dictionary
######### put fld "fld1" into tLine
##!!!!!!!
put fld "fld1" into tFile1
## !!!!!!
set itemDel to TAB
put URL "http://*********.on-rev.com/testing123.txt" into tFile
repeat for each line tLine in tFile
if item 1 of tLine = tFile1 then
answer "Yes"
## Here is the time to:
exit repeat
else
answer "No"
end if
end repeat
end mouseUp