Error getting tags :
error 404Error getting tags :
error 404 put | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Version
put
Basics
Expander triangle
Type
Command
Syntax

put value [{before | into | after} container]

put value into URL destinationURL

Introduced
1.0
Environment
Desktop, Web and Server
Platform Support
MacOS,Mac OS X,Windows,Linux
Security
Disk
Summary
Places a value in a container.
Examples

put "ABC"
>e
e
e
e
e
put return someGlobalVar after field "Accumulations"
put field 1 field 2 into URL "file:more.txt"
put homegrownMP3Data into URL "binfile:My file.MP3"

Additional Comments
Expander triangle

Use the put command to set the value of a variable, put text into a field, put data into a file, display text in the message box, or upload a file to a server.

Parameters:

The value is any expression that evaluates to a string.

The container is a field, button, image, URL, or variable, or the message box.

Comments:

If you use the put into form, the value replaces anything that was previously in the container.

The put before and put after forms place the value before or after the current contents of the container.

If you don't specify a container, the put command puts the value into the message box.

If you put a value into a nonexistent container, Revolution assumes it is a variable name, and initializes the container as a local variable. This is the most common way to create a local variable. You can also explicitly declare local variables with the local command. If the explicitVariables property is set to true, you must declare local variables before using them, and using the put command with a nonexistent variable will cause an error instead of creating the variable.

The action of the put...into URL form varies depending on the type of URL:

* When used with a file or binfile URL, places the value in the specified file. If the file doesn't exist, the put command creates it. (Use the file URL type for text data and the binfile URL type for binary data.)

* When used with a resfile URL, sets the resource fork of the specified file to the value. Because resource forks have a specific format, in general you should use put with a resfile URL only when the value is also a resfile URL. The following example copies the entire resource fork of one file to another:

put URL "resfile:My Source" into URL "resfile:Destination"

Note: Unlike its use with the file and binfileURL types, the putcommand, when used with a resfileURL, does not create the file if it doesn't exist. Instead, an error message is returned in the result. To create the file, first use a statement like the following:

put empty into URL "file:filePath"

Then you can use the put command with a resfile URL type to create the resource fork.

* When used with an ftp URL, uploads the value to an FTP server. If an error occurs during uploading, the error is placed in the result function. The first word returned by the result function is "error", followed (where appropriate) by the text of the error message returned by the FTP server, including the server response code.

* When used with an http URL, uses the HTTP PUT method to upload the value to the server. However, since most HTTP servers don't implement the PUT method, you usually will use an FTP URL instead to upload files to an HTTP server.

Note: Uploading a URL by putting a value into it is a blocking operation: that is, the handler pauses until Revolution is finished Uploading the value. Since contacting a server may take some time due to network lag, URL operations may take long enough to be noticeable to the user. To upload without blocking, use the libURLftpUploadcommand instead.

Note: On windows, it is imperative not to name a file with one of the reserved device names: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8 and LPT9. Also do not use these names followed by an extension, for example, NUL.tx7.

Important! If a blocking operation involving a URL (using the putcommand to upload a URL, the postcommand, the delete URLcommand, or a statement that gets an FTP or httpURL) is going on, no other blockingURL operation can start until the previous one is finished. If you attempt to use a URL in an expression, or put data into a URL, while another blockingURL operation is in progress, the result is set to "Error Previous request not completed".

User Comments
Expander triangle
User thumbnail
Oliver Kenyon
StarStarStarStarStar
Nov 2, 2009
When using this command to write to any sort of url (file, binfile, resfile, http, ftp etc), if the command fails, it will *not* throw an error. Instead the error message is placed into the result.
To check for error messages when putting into urls, something like this should be used:


local tResult
put tData into url ("file:" & tFilePath)
put the result into tResult
if tResult is not empty then
# Handle error here
else
# Continue execution
end if

User thumbnail
phil@liverpool.ac.uk
StarStarStarStarStar
Jan 25, 2011
Note that for put URL on OS X it is ok to use a URL that includes the usual "//" sequence after the "file:" part. On Windows this does not work. i.e.


put URL ("file://" & it) into myfilecontents

(where it contains a filepath) works fine on a Mac, but fails on Windows. The solution is not to include the "//". i.e.


put URL ("file:" & it) into myfilecontents

This works correctly on both platforms (despite not conforming to rfc1738).