Get url "file:///..."

Richard Gaskin ambassador at
Tue Jun 21 11:05:13 EDT 2016

Jim Hurley wrote:

 > I got this web page address from the county election's office:

How did the elections office get a path to a file on your hard drive?

 > It opens when I paste  it into the address field in Safari.
 > But
 >    get url 
 > in Live Code leaves "it" empty.
 > I need to get the source code (programmatically) so that I may parse
 > "it" for voter results.
 > Is there something I can do to the address that would make it
 > acceptable to LiveCode's: get url

In a traditional URL what you have is good, which explains why it works 
well in a browser.

"file://" is the service protocol specifier, and "/Users/jimhurley/..." 
is the path to the file.

LiveCode's URL syntax for working with local files isn't quite the same, 
though.  In LC, we do need the "//" when using an Internet protocol 
(e.g. "http://" or "ftp://"), but for accessing local files the "file:" 
or "binfile:" specifier is not treated as a service per se, merely a 
keyword to let the engine know to use very different internal routines 
than it uses for Internet access.

The POSIX standard that's supposed to govern these things is notoriously 
inconsistent among implementations.  IIRC the spec calls for any path 
that includes more than one "/" to be interpreted as if there is only 
one (e.g. "///" becomes "/").  If that was happening here, then using this:


...would be the same as:


But apparently it isn't.

Perhaps this is a bug in LC.  Mark/Monte/Peter: opinions?

Oddly, I believe I've encountered times when "file:///" worked, but not 
others (Windows?).  Maybe it's dependent on how the host OS handles 
paths?  FWIW on Ubuntu it works with 1, 2, 3, and even 10 slashes.

In any event, if you change that to use a single slash you should find 
that it works:

   replace "file:///" with "file:/" in tUrl
   put url tUrl into tWhatever

  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  Ambassador at      

More information about the Use-livecode mailing list