defaultfolder won't work inside a URL file statement?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
defaultfolder won't work inside a URL file statement?
My defaultfolder has been set to: “c:\temp\livecodefiles”
This works: put "This program is trending" into URL "file:c:\temp\livecodefiles\TestingNow.txt"
But the following yields this error: “compilation error at line x (Handler: bad command) near “&” , char xx
put "This program is trending" into URL "file:" & defaultfolder & "\TestingNow.txt"
Is there any reason the concatenation yielding exactly the same string won't work?
Thanks to all in advance.
This works: put "This program is trending" into URL "file:c:\temp\livecodefiles\TestingNow.txt"
But the following yields this error: “compilation error at line x (Handler: bad command) near “&” , char xx
put "This program is trending" into URL "file:" & defaultfolder & "\TestingNow.txt"
Is there any reason the concatenation yielding exactly the same string won't work?
Thanks to all in advance.
Re: defaultfolder won't work inside a URL file statement?
Hi Ed,
concatenated strings (for pathnames, object names etc.) need to be in parens to be parsed correctly by the engine!
...
put "This program is trending" into URL("file:" & defaultfolder & "/TestingNow.txt")
...
And if you ever want to develop for other platforms than Windows, get used to the internal LC pathdelimiter which is a SLASH -> /
Best
Klaus
concatenated strings (for pathnames, object names etc.) need to be in parens to be parsed correctly by the engine!
...
put "This program is trending" into URL("file:" & defaultfolder & "/TestingNow.txt")
...
And if you ever want to develop for other platforms than Windows, get used to the internal LC pathdelimiter which is a SLASH -> /
Best
Klaus
Re: defaultfolder won't work inside a URL file statement?
Thanks for the response.
For Klaus:
In the dictionary for the use of “URL file xxx” usage, there is no mention of having to do what you stated (use of a surrounding parenthesis) to make this work so where is this rule specified in the dictionary?
Also I had come up with a work around that does NOT require the use of the parenthesis. Any reason why the workaround (below) works without the need of the surrounding parenthesis?
My work around that worked without the need for a surrounding parenthesis.
put "file:" & defaultfolder & "\TestingNow.txt" into xvar
put "This program is trending" into url xvar --(works perfectly without parenthesis or any compilation errors)
Thanks.
For Klaus:
In the dictionary for the use of “URL file xxx” usage, there is no mention of having to do what you stated (use of a surrounding parenthesis) to make this work so where is this rule specified in the dictionary?
Also I had come up with a work around that does NOT require the use of the parenthesis. Any reason why the workaround (below) works without the need of the surrounding parenthesis?
My work around that worked without the need for a surrounding parenthesis.
put "file:" & defaultfolder & "\TestingNow.txt" into xvar
put "This program is trending" into url xvar --(works perfectly without parenthesis or any compilation errors)
Thanks.
Re: defaultfolder won't work inside a URL file statement?
Hi Ed,
the examples in the dictionary do NOT use concatenated strings!
Try this:
Create a button named "My Button"
Now create another button with this script
Error: Can't find object...
Change to :
...
hide button ("My" && "Button")
...
Works!
Same here:
...
put "My" && "Button" into tButt
hide button tButt
...
Works, too!
I do not say we ALWAYS have to use parens when concatenating strings, I say it depends!
When passing a concatenated string to any handler/function it needs to be in parens since
the engine will first evaluate the expression inside of hte parens and does the concatenating for us.
If not, the engine will only take the part until the first & and tries to use that for the command/function
which, in case of concatenated string, is only "half the rent" and it throws an error.
Best
Klaus
the examples in the dictionary do NOT use concatenated strings!
Check the content of xvar (or just ANSWER XVAR), here you pass an already concatenated string, so no complains from the engine.put "file:" & defaultfolder & "\TestingNow.txt" into xvar
put "This program is trending" into url xvar --(works perfectly without parenthesis or any compilation errors)
Try this:
Create a button named "My Button"
Now create another button with this script
Code: Select all
on mouseup
hide button "My" && "Button"
end mouseup
Change to :
...
hide button ("My" && "Button")
...
Works!
Same here:
...
put "My" && "Button" into tButt
hide button tButt
...
Works, too!
I do not say we ALWAYS have to use parens when concatenating strings, I say it depends!

When passing a concatenated string to any handler/function it needs to be in parens since
the engine will first evaluate the expression inside of hte parens and does the concatenating for us.
If not, the engine will only take the part until the first & and tries to use that for the command/function
which, in case of concatenated string, is only "half the rent" and it throws an error.
Best
Klaus
Re: defaultfolder won't work inside a URL file statement?
To me is a bug, becauseEd_Ray wrote:My defaultfolder has been set to: “c:\temp\livecodefiles”
This works: put "This program is trending" into URL "file:c:\temp\livecodefiles\TestingNow.txt"
But the following yields this error: “compilation error at line x (Handler: bad command) near “&” , char xx
put "This program is trending" into URL "file:" & defaultfolder & "\TestingNow.txt"
Is there any reason the concatenation yielding exactly the same string won't work?
Thanks to all in advance.
Code: Select all
put "This program is trending" into URL "file:" & the defaultfolder & "/TestingNow.txt"
See http://quality.livecode.com/show_bug.cgi?id=19098
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: defaultfolder won't work inside a URL file statement?
No bug, Max, just really bad concatenating of a string!
Didn't you read my second (lengthy) reply?
Didn't you read my second (lengthy) reply?
Re: defaultfolder won't work inside a URL file statement?
All right,Klaus wrote:No bug, Max, just really bad concatenating of a string!
Didn't you read my second (lengthy) reply?
Code: Select all
put "This program is trending" into URL "file:" & (the defaultfolder) & "/TestingNow.txt"
Code: Select all
put "This program is trending" into URL ("file:" & the defaultfolder & "/TestingNow.txt")

Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Re: defaultfolder won't work inside a URL file statement?
Yes, just as I already wrote in my first posting. 
