Use an interactive environment for serialization 3

Source: Internet
Author: User

 

If we want to solve the problem of downloading a network image to a local disk, we can resolve the problem as follows:

A. Obtain the file name.

B. Download the network image.

C. store the data on a local disk.

The corresponding solutions are as follows:

A. Use Find
And the to-string function (you do not need to know the details of these two functions at present) to obtain

Name.

B. Read
The function can download images from a URL.

C. Write
The function can save images to a disk.

 

 

For the above three small problem solutions, each problem is handled with a command line code. In the interactive environment

Operations will affect subsequent operations, and will continue to accumulate, so we can split the task and execute it again. These three

Operations are processed in three command lines, but they are processed in the same line.

In order to do this experiment, first casually find a website picture, I found a http://www.rebol.com/graphics/reb-logo.gif
This

Images. To be cautious, enter the URL in a web browser to confirm that the image exists. Note,

The URL must be exactly the same, and the upper and lower case cases must be the same, because some websites are case sensitive.

First in REBOL
Set the URL in the interpreter interaction environment and perform these three operations in sequence:

AAA processes the URL and obtains the file name (file-name ).

Bbb reads URL from the network
. After the execution, you will see a large string of returned values. This is the content of the image.

We don't need to care about the original hexadecimal data. (Note: A timeout error may occur, or the page does not exist .)

CCC completes write
If no return value or intermediate information is returned after the command line is executed, the operation is successful.

It has been stored in the local file system. We can find the image file in the current directory. Double mouse

Click it to open the image and make sure the content is correct.

 

 

Some programs are used only once and do not need to be used repeatedly in the future. Such programs are called disposable programs or discarded programs. If

A one-time program requires a small amount of code, which is usually completed directly in an interactive environment without being written as a script file.

For example, the interactive environment is suitable for downloading some files from the network and processing local files.

If the previous page is successful, you have downloaded an image. How can I download another image? Re-enter all

? No. You only need to enter the first line of command
You can set the parameters A, B, and C later.
Three operations are acceptable.

Call history directly.

How to call history records? Use the up/down key! After finding the correct command line from the history, press the Enter key.

 

 

There are some basic button operations in the interaction environment, which we must know.

Each time you complete a command line, you must press enter to tell the REBOL
Interpreter input is complete, start

Run. You can use the left and right keys to move the cursor or use backspace to delete the cursor as long as you have not pressed the Enter key.

The first character.

You can use the up/down key to call up a previously entered command line for reuse or modification. Call up history records

Another method is F7.
Key to bring up the history window, move the command line with the up or down key, and press the Enter key to select

Command line, or press the exit key (ESC) to exit the history window. Mac OS X
The F7 key cannot be used to call up history records.

When the cursor looks like a line, it indicates the insert mode. If the cursor looks like a square, it indicates the rewrite mode. Available insert
Key switch

Mode.

In the interactive environment, you can use the mouse to select a text box (reversed), move the cursor to the reversed text, and press

Right-click the text, and the reverse white disappears. The text is copied (the text has been recorded in the memory ). If you are using Mac OS X,

You can use the mouse to frame a text (reversed) and move the cursor over the reversed text. Right-click the text and a menu appears,

Select "copy" from the menu.

Windows
You can move the cursor to the position you want to paste, and then right-click the cursor. Paste Mac OS X

By pressing command at the same time
And v.

The REBOL interaction environment uses the basic key operations of the operating system, so it is not very useful, but it does not matter, because most

We write code in the Text Editor (described later), instead of writing code in the interactive environment.

This article is excerpted from "programming ing: everyone can learn programming ".

Dr. Cai

Published by Electronic Industry Publishing House

Book details: http://blog.csdn.net/broadview2006/article/details/7768124

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.