Hi Folks,
does anybody know how to compare a title of a matrix (the one you select)
with the content of a file?
set the_file_path to (path to desktop folder as string) & "wein_name.txt" as file specifiacation
set wein_name to read the_file_path as string
-- wein_name is "Grüner Veltliner"
set theWine to title of current cell of matrix "wine" of box "box" of window "main" as string
if theWine is equal to wein_name then
ergebnis_wein is 1
else if theWine is not equal to wein_name then
ergebnis_wein is 0
end if
Allthough theWine is also “Grüner Veltliner” ergebnis_wein is “missing value”
Thanks for your Feedback,
Stefan
Hi Folks,
solved it that way:
set the_file_path to (path to desktop folder as string) & "wein_name.txt" as file specifiacation
set wein_name to read the_file_path as string
-- wein_name is "Grüner Veltliner"
set theWine to title of current cell of matrix "wine" of box "box" of window "main" as string
set q to theWine as string
set r to wein_name as string
if q = r then
set ergebnis_wein to 1
else if q is not r then
set ergebnis_wein to 0
end if
BR
Stefan
Hi Stefan,
¢ too many as string coercions
¢ I recommend to read the first paragraph of the file to avoid comparing problems with the line delimiter.
easier version:
set the_file_path to (path to desktop folder as string) & "wein_name.txt"
set wein_name to paragraph 1 of (read file the_file_path)
-- wein_name is "Grüner Veltliner"
set theWine to title of current cell of matrix "wine" of box "box" of window "main"
set ergebnis_wein to theWine is wein_name -- true or false, a boolean value is easier to use
– or, it you want really an integer result:
set ergebnis_wein to (theWine is wein_name) as integer -- 1 or 0
Hi Stefan,
as thousand times before - you saved my life by giving me the correct code!
Thanks a lot!
Stefan