URL Syntax

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
vamp07
Posts: 21
Joined: Mon Apr 10, 2006 2:12 pm

URL Syntax

Post by vamp07 » Sat Feb 06, 2010 9:37 pm

Hi Everyone,

I just bashed my head for an hour trying to get this to work:
put URL"file:/Users/xyz/"&it into field "log"

I had no success until I changed the syntax to:
put URL("file:/Users/xyz/"&it) into field "log"

I looked at the dictionary definition or URL and the examples provided did not use URL in the more traditional language syntax. Was I doing anything wrong?

Thanks

Steven

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: URL Syntax

Post by FourthWorld » Sun Feb 07, 2010 3:22 am

With the first form the engine attempts to get the contents of the URL and then concatenate that with "it" Using the parens in the second form makes it clear to the engine that "it" is to be concatenated to the URL, not the data returning from it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: URL Syntax

Post by BvG » Sun Feb 07, 2010 3:28 am

The problem here is the operator precedence.

IF you remember some of your school math, then you remember that + (add) comes before * ( multiply). Similar rules are followed by rev code, and the url (url keyword) comes before & (string merging operator). This is unfortunate, and I hate it. However, it has historical reasons, and is unlikely to be changed. So what rev tries to do without the brackets is:

Code: Select all

put URL "file:/Users/xyz/" into field "log"
put it after field "log"
by using brackets you tell rev that you want this:

Code: Select all

put "file:/Users/xyz/"&it into temporary
put URL temporary into field "log"
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

vamp07
Posts: 21
Joined: Mon Apr 10, 2006 2:12 pm

Re: URL Syntax

Post by vamp07 » Sun Feb 07, 2010 12:09 pm

Got it.. I went back to the manual and on page 163 it gets into the dirty details of this topic. Thank!!!

Post Reply