Variable in filepath

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
geo
Posts: 10
Joined: Sun Aug 04, 2019 7:28 pm

Variable in filepath

Post by geo » Sun Aug 04, 2019 7:35 pm

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

SparkOut
Posts: 2020
Joined: Sun Sep 23, 2007 4:58 pm

Re: Variable in filepath

Post by SparkOut » Sun Aug 04, 2019 8:08 pm

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)
Last edited by SparkOut on Sun Aug 04, 2019 8:11 pm, edited 1 time in total.

Klaus
Posts: 11210
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Variable in filepath

Post by Klaus » Sun Aug 04, 2019 8:09 pm

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

geo
Posts: 10
Joined: Sun Aug 04, 2019 7:28 pm

Re: Variable in filepath

Post by geo » Sun Aug 04, 2019 10:16 pm

Thanks guys!

geo
Posts: 10
Joined: Sun Aug 04, 2019 7:28 pm

Re: Variable in filepath

Post by geo » Tue Aug 13, 2019 5:50 pm

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

Klaus
Posts: 11210
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Variable in filepath

Post by Klaus » Tue Aug 13, 2019 6:04 pm

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

geo
Posts: 10
Joined: Sun Aug 04, 2019 7:28 pm

Re: Variable in filepath

Post by geo » Tue Aug 13, 2019 6:39 pm

Hi Klaus

listMOU calls the command

Klaus
Posts: 11210
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Variable in filepath

Post by Klaus » Tue Aug 13, 2019 6:47 pm

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

geo
Posts: 10
Joined: Sun Aug 04, 2019 7:28 pm

Re: Variable in filepath

Post by geo » Tue Aug 13, 2019 7:10 pm

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

Klaus
Posts: 11210
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Variable in filepath

Post by Klaus » Tue Aug 13, 2019 7:31 pm

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!

geo
Posts: 10
Joined: Sun Aug 04, 2019 7:28 pm

Re: Variable in filepath

Post by geo » Tue Aug 13, 2019 7:47 pm

Perfect, that's what I needed
Thanky you very much

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”