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: FourthWorld, heatherlaine, Klaus, kevinmiller
-
robm80
- Posts: 161
- Joined: Sat May 03, 2014 7:15 am
Post
by robm80 » Mon Aug 04, 2014 9:28 am
I need to know the name of the directory of "Thumnails".
I use:
Code: Select all
on mouseUp
global tSeltxt
-- put the filename of this stack into tFilenm
-- put the number of chars of tFilenm into tNum
-- put tNum-18 into tMin
-- delete char tMin to tNum of tFilenm
put the defaultFolder into tFilenm
put tFilenm &" /thumbnails/" into tStam
lock screen
put selectedtext of fld index into tVar
put tVar into tSeltxt
put lineoffset (tVar,fld index) into tLO
put number of lines of fld index into tLines
put tLO && "of" && tLines into tKeus
set the label of button "linenumber" to tKeus
put fld "titel" of card tVar of stack "recepten" into fld "titel"
put fld "nodig" of card tVar of stack "recepten" into fld "ingr"
put fld "recept" of card tVar of stack "recepten" into fld "recept"
delete last image
-- put tFilenm & "thumbnails/" into tStam
import paint from file tStam& tVar&".jpg" --------------------errormessage, see below
set the rect of last image to the rect of button "pict"
set the lockloc of last image to true
unlock screen
end mouseUp
errormessage: field "index": execution error at line 24 (import: can't open file, mask file or display) near "D:/Livecode /thumbnails/Cassoulet.jpg", char 1
What's wrong ?. When i use the outcommented lines: no problem
Rob
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Mon Aug 04, 2014 10:05 am
Hi Rob,
Paths are different for each plateform and you have to consider if this is a stack or a standalone.
This function return the path of the folder where the stack is (no tested for Linux)
Code: Select all
function getPathFolder
put the filename of this stack into P
set the itemdel to "/"
if the environment = "development" then
delete item-1 of P
else -- It's in a StandAlone mode.
if the platform = "MacOS" then
delete item -4 to -1 of P
else
delete item-1 of P
end if
end if
set the itemdel to ","
return p
end getPathFolder
Best regards
Jean-Marc
Last edited by
jmburnod on Tue Aug 05, 2014 8:55 am, edited 1 time in total.
https://alternatic.ch
-
Klaus
- Posts: 14199
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Aug 04, 2014 12:28 pm
Hi Rob,
you need to be a bit more careful when scripting!
You have a space too much in your script, which will make the pathname invalid:
Code: Select all
put tFilenm &" /thumbnails/" into tStam
This is something even the error dialog reveals!
D:/Livecode /thumbnails/Cassoulet.jpg
Or is that directory really named "Livecode "?
And in your own interest you should start to put PARENS around concatenated file- and object names:
Code: Select all
import paint from file (tStam & tVar & ".jpg")
Best
Klaus
-
robm80
- Posts: 161
- Joined: Sat May 03, 2014 7:15 am
Post
by robm80 » Mon Aug 04, 2014 1:17 pm
Thank you both'
Deleting the space like Klaus said, was the solution.
Stupid of me not to have seen that.
Still sleep in my eyes.
Rob
-
Klaus
- Posts: 14199
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Mon Aug 04, 2014 2:00 pm
In cases like this, a little:
...
put tStam & tVar & ".jpg" into tFile
answer (there is a file tFile)
## FALSE should give you a hint that the pathname is not correct.
...
may also help!
-
mwieder
- VIP Livecode Opensource Backer

- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
-
Contact:
Post
by mwieder » Tue Aug 05, 2014 1:33 am
Rob-
It's much easier to see problems in someone else's code than in your own, especially when you know a problem exists.
No worries.