Creating a Pro-SiMPLE
"Drag-and-Drop" Program
One of the cool features of Windows is its "Drag-and-Drop" capability. (For example, if you want to use the MSPAINT program to edit an image file, all you have to do is drag the image file's icon onto a shortcut to the MSPAINT program.)
You can implement this same "Drag-and-Drop" feature into your SiMPLE programs as well. Doing so is merely an extension of the ideas discussed in "Passing Calling Parameters to a Pro-SiMPLE Program". To pass a data file's path to a SiMPLE program, just drag the data file's icon onto the program's shortcut (see: "Creating a Shortcut to a Pro-SiMPLE Program"). The path to the data file will be contained in Param[1].
To illustrate, let's write a "Drag-and-Drop" program that will simply display
the contents of any text file that is dragged onto it:
Pro-SiMPLE
Text line
Int eof
If (Numargs!=1) quit
command="read "+Param [1]
open a (command)
Do
read line a (line, eof)
If eof Break
Display line
Loop
close a
(Compare this listing with the one shown in:
"Reading Text Data From A File".)
After you initially run the program, create a shortcut to it. Then drag any text file onto that shortcut to have its contents displayed. [Note: Lines of text greater than about 255 characters will be truncated.]
[
Webmaster |
FAQ's |
Home Page |
Contact Us ]