Page 1 of 1
Variable in filepath
Posted: Sun Aug 04, 2019 7:35 pm
by geo
Hello
Here my problem:
--This works:
set the text of image "image" to url ("binfile:" & specialFolderPath("documents") & "/filename")
-- this doesn't work
set the text of image "image" to url ("binfile:" & specialFolderPath("documents") & "/tName")
Thanks for any help
Re: Variable in filepath
Posted: Sun Aug 04, 2019 8:08 pm
by SparkOut
Hi geo
Concatenate the literals within quotes, and the variables outside, joined with the & operator, just as you join the url file format to the value returned by the specialFolderPath function
Code: Select all
set the text of image "image" to url ("binfile:" & specialFolderPath("documents") & "/" & tName)
Re: Variable in filepath
Posted: Sun Aug 04, 2019 8:09 pm
by Klaus
Hii geo,
welcome to the forum!
Well, when you quote the name of a variable, it becomes a STRING with the name, but we need the value of the variable not the name. Do like this:
Code: Select all
...
set the text of image "image" to url ("binfile:" & specialFolderPath("documents") & "/" & tName)
...
Best
Klaus
Re: Variable in filepath
Posted: Sun Aug 04, 2019 10:16 pm
by geo
Thanks guys!
Re: Variable in filepath
Posted: Tue Aug 13, 2019 5:50 pm
by geo
Hello, another beginner question:
I can call a command with
on mouseUp
databaseConnect
listMOU
end mouseUp
Now I have the listMOU stored in a variabel which I'm not able to get out of there to call the command.
Thanks for any help
Re: Variable in filepath
Posted: Tue Aug 13, 2019 6:04 pm
by Klaus
Hi geo,
it is always a good idea to open a new thread for a new problem!
Sorry, don't understand your question, what is listMOU?
Best
Klaus
Re: Variable in filepath
Posted: Tue Aug 13, 2019 6:39 pm
by geo
Hi Klaus
listMOU calls the command
Re: Variable in filepath
Posted: Tue Aug 13, 2019 6:47 pm
by Klaus
So listMOU is the name of a handler, right? Where did you put this handler?
Sound like it is not in the message hierarchie.
Here good article about the "message hierarchie" in LC and how to effectively use it:
http://www.fourthworld.com/embassy/arti ... _path.html
Re: Variable in filepath
Posted: Tue Aug 13, 2019 7:10 pm
by geo
listMOU ist the name of the handler, it is on the stack
on mouseUp
databaseConnect
listMOU
end mouseUp
this works fine, it shows the correct values
now I would like to use a segmented control where I get the name of the handler from the tab:
on hiliteChanged
put the hiliteditemNames of me into tHilited
answer tHilited
put list before tHilited
answer tHilited
end hiliteChanged
the tHilited contains listMOU, but how do I get the value out of the variabel so it would look something like that:
on hiliteChanged
put the hiliteditemNames of me into tHilited
put list before tHilited
databaseConnect
tHilited
end hiliteChanged
Re: Variable in filepath
Posted: Tue Aug 13, 2019 7:31 pm
by Klaus
Ah, I think I get it now, you want to build the string "listMOU" from two singll strings "list" and "MOU". Is that correct?
In that case you could do something like this:
Code: Select all
on hiliteChanged
put the hiliteditemNames of me into tHilited
## Always put strings in QUOTES!
put "list" before tHilited
databaseConnect
## In cases like this we need to DO the concatenated handlername:
do tHilited
end hiliteChanged
And please use the CODE tags after you pasted your script(s), this way formatting like identation will be kept!
Re: Variable in filepath
Posted: Tue Aug 13, 2019 7:47 pm
by geo
Perfect, that's what I needed
Thanky you very much