terry
Freshman Member
Posts: 15
|
Post by terry on Nov 25, 2014 10:46:55 GMT -5
Greetings,
Is there any way to populate an edit session containing no lines entirely with a macro without any manual preparation? I had hopes of using the LINE primary command in a macro to insert some number of empty lines which would then be replaced with the contents of a file using the Set_Line function. That fails because the LINE command apparently can't work against the "Top of Data" or "Bottom of Data" lines.
Any ideas? Thank you, Terry
|
|
|
Post by George on Nov 25, 2014 11:35:31 GMT -5
Terry: If you are simply 'loading' a file, why not do a simple SPF_CMD("COPY", filename) into the empty edit session?
But you are right, there's a macro hole in trying to insert a line into an empty file. I'm going to have to examine the best way to fix that. Maybe just a line reference of .0 being allowed on a LINE or ADD command.
George
|
|
terry
Freshman Member
Posts: 15
|
Post by terry on Nov 26, 2014 8:29:42 GMT -5
Thanks George, I'm creating a file in a macro in an empty edit session and I wanted to load it in the empty session from within that macro. I should have looked for an alternative method before bothering you.
The COPY command works perfectly for this particular purpose, but being able to insert lines in an empty session would definitely be useful for displaying macro-generated data without having to create a file to subsequently COPY.
Thanks again, Terry
|
|
terry
Freshman Member
Posts: 15
|
Post by terry on Nov 27, 2014 8:47:03 GMT -5
The short answer to that is to make sure the file is not empty. One way to do this is by creating a named clipboard and pasting it into your file. You could create one blank line and save it as a named clipboard of BLANK. Do that by creating a blank line anywhere in a file, put a C on the blank line, then issue CUT BLANK. Now, in a new empty file, issue the command PASTE BLANK. You know have a blank line as line 1, the only line of the file. Proceed to insert lines after line 1. Finally, issue a command to delete line 1 assuming you don't want a blank line to start the file. I had thought of something similar but I was hoping to avoid manual preparation.
|
|
|
Post by George on Nov 27, 2014 12:23:20 GMT -5
Terry: I've made the changes to allow the pseudo line label .0 to refer to the top of data line. This enables a macro such as this sample to populate an empty file. This example uses the ADD command, you could use whatever suits your logic. ' try.macro
dim i as number
for i = 0 to 9
SPF_CMD("ADD", "." + format$(i), "'Some text" + str$(i+1) + "'")
next i
halt("Done")
The updated version can be downloaded from the web site at www.SPFLite.com/Files/SPFLite814331.EX_ Just rename it to SPFLite.EXE and swap it into the normal install folder. George
|
|
terry
Freshman Member
Posts: 15
|
Post by terry on Nov 28, 2014 8:44:53 GMT -5
Thanks George, but the link provided isn't working:
The document name you requested (/Files/SPFLite.V814331.EX_) could not be found on this server. However, we found documents with names similar to the one you requested.
|
|
|
Post by George on Nov 28, 2014 14:04:01 GMT -5
Terry: Da*n! I just cannot type that correctly for love nor money. I've corrected (and tested) it. Sorry. George
|
|
|
Post by George on Nov 28, 2014 14:15:36 GMT -5
You seem to have forgotten that SPFLite operands are mostly position independent when there is no confusion caused by multiple operands of the same data type. So you can say ADD .0 "Hello" or ADD "Hello" .0 That's why the example uses the loop index for the operand, it successively adds .0 .1 .2 etc. Get_Last+LPTR works fine once there are lines in the file. For an Empty file it returns an error indication and zero value (I believe, without looking) No. Remember !n operands refer to the actual internal index to the line, and we all know what happens programming-wise with indexes of zero. Well, almost always since you can have zero based arrays. !0 is illegal - always. Only .0 has been given special treatment. George
|
|