Skip to content

Commit 4aaf7dc

Browse files
committed
[[ Community Docs ]] Format, examples, and tag
- Fixed some format problems with the description (list of schemes are not showing on separate lines) - One example used a very old, classic Mac OS style file path - Added examples using URL as destination rather than source, including need to textEncode and textDecode when reading and writing to external files. - Added file system tag, since URL can be used to read/write from local file system
1 parent 2dcd2cd commit 4aaf7dc

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

docs/dictionary/keyword/URL.lcdoc

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,44 @@ Example:
1818
get URL "http://www.xworlds.com/index.html"
1919

2020
Example:
21-
put URL "binfile:/Mac HD/Files/example.gif" into image "Example Logo"
21+
put URL "binfile:/Users/myuser/Files/example.gif" into image "Example Logo"
2222

2323
Example:
2424
post field "Results" to URL "http://www.example.org/current.txt"
2525

2626
Example:
2727
get URL "http://www.xworlds.com/index.html"
2828

29+
Example:
30+
put "Hello World" into URL "file:/Users/myuser/Documents/sample.txt"
31+
32+
Example:
33+
# Writing the contents of a field to an external file, preserving text encoding
34+
on textSave
35+
put "всем привет" into field "russiantext"
36+
put textEncode(field "russiantext","UTF-8") into "binfile:/Users/myuser/Documents/russtext.txt"
37+
end textSave
38+
# Reading contents of a file into LiveCode, preserving text encoding
39+
on textRead
40+
local tText
41+
put URL "binfile:/Users/myuser/Documents/russtext.txt" into tText
42+
put textDecode(tText,"UTF-8") into field "russiantext"
43+
end textRead
44+
2945
Description:
3046
Use the <URL> <keyword> to access the contents of a local <file> or a <file> accessible on the Web.
3147

32-
A <URL> is a method of designating a file or other resource. You can use a <URL> like any other container. You can get the contents of a <URL> or use its contents in any expression. LiveCode supports the following <URL> schemes:
48+
A <URL> is a method of designating a file or other resource. You can use a <URL> like any other container.
49+
You can get the contents of a <URL> or use its contents in any expression. LiveCode supports the following <URL> schemes:
3350

3451
http: a page from a web server
52+
3553
ftp: a directory or file on an FTP server
36-
<file> : a text file on the local disk (not on a server)
54+
55+
<file>: a text file on the local disk (not on a server)
56+
3757
binfile: a binary file
58+
3859
resfile: on Mac OS and OS X systems, the resource fork of a file
3960

4061
All actions that refer to a <URL> container are blocking: that is, the handler pauses until LiveCode is finished accessing the <URL>. Since fetching a web page may take some time due to network lag, accessing URLs may take long enough to be noticeable to the user. To avoid this delay, use the load command (which is non-blocking) to cache web pages before you need them.
@@ -49,4 +70,4 @@ From LiveCode 7.0.0, URL keyword has been upgraded to understand Unicode files w
4970

5071
References: HTMLText (property), URL (keyword), file (keyword), libURLSetAuthCallback (command), launch url (command), libURLSetExpect100 (command), load (command), container (glossary), keyword (glossary), resource (glossary)
5172

52-
Tags: networking
73+
Tags: networking,file system

0 commit comments

Comments
 (0)