Get URL from field with link saved in a variable

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tareq_daher
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 7
Joined: Thu Mar 05, 2009 9:24 pm

Get URL from field with link saved in a variable

Post by tareq_daher » Tue Aug 24, 2010 10:13 pm

I want to be able to put an FTP url in a field and then use the Get URL to retrieve information from a server

If i say get URL (ftp://username:password@server.com/reco ... &GUsername&"/") it works with no problem, but i want to designate only one field to decide which server to get information from. Example below:

line 1 has this in the "ftplink" field ---> ftp://username:password@server.com

Code: Select all

put line 1 of field "ftplink" of card "starthere" of stack "writing" into curURL
   put curURL
   get URL curURL&"/recordings/"&GUsername&"/"

It does not work when i put it in a variable.
Tareq Daher (Tawaiha),
Instructional Technology, Doctoral student , UNL

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Get URL from field with link saved in a variable

Post by Mark » Wed Aug 25, 2010 1:55 am

Dear tareq_daher,

It is interesting that your first example contains brackets around it, but your second doesn't. Add the brackets and it should work.

Code: Select all

get URL (curURL & "/recordings/" & GUsername &"/")
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

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

Re: Get URL from field with link saved in a variable

Post by FourthWorld » Wed Aug 25, 2010 8:21 am

Mark's answer is spot-on, Tareq, and while it may seem unintuitive for an "English-like" language to depend on parentheses now and then, it may help to look at it from the engine's perspective.

When the engine sees this:

get URL curURL&"/recordings/"&GUsername&"/"

..it thinks of it like this:

1. get url cURL
2. then append "/recordings/" to the result
3. and then append gUserName &"/" to it

The parens make it clear to the engine that all of that stuff after "get URL" is to be evaluated as a single string first.

With the parens, the engine thinks of it like this:

1. Concatenate curURL&"/recordings/"&GUsername&"/"
2. Then pass that to "get URL"

HTH -
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

tareq_daher
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 7
Joined: Thu Mar 05, 2009 9:24 pm

Re: Get URL from field with link saved in a variable

Post by tareq_daher » Wed Aug 25, 2010 6:43 pm

That was exactly my problem, thanks to the both of you. When i was outputting curURL in the message box, it looked just fine with no problems at all. However without the parentheses it did not work. Now i have one field that contains the server information that i use to connect (ftp://servername:password@server.com) , in case i need to access a different server in the future all i need is to change that information.

Do either of you know if SFTP has been introduced into runtime revolution ?
Tareq Daher (Tawaiha),
Instructional Technology, Doctoral student , UNL

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

Re: Get URL from field with link saved in a variable

Post by FourthWorld » Wed Aug 25, 2010 8:41 pm

SFTP has not yet found its way into the engine, but my understanding is that the team is exploring ways to do that for future versions.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Get URL from field with link saved in a variable

Post by Mark » Wed Aug 25, 2010 11:59 pm

Hi tareq_daher ,

Some time ago, I compiled Putty for Windows. You can use this to access an sftp server. The command utilities are available here. On Mac OS X and Linux you can also use the built-in sftp command line utility.

Best regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply