Hi Bob,
Thanks for posting that. Now that I see your example, yes it should be a help. You would no longer need the extra files where you now type in the Haystack lines... as you could type and maintain them in the main macro and... typing and maintaining it there will be easier because you won't have to manually type %CRLF% over and over again.
There's one point where I differ now though. Your suggested form was this:
Bob Hansen wrote:Code: Select all
UseBlock>Block1,vHaystack
line1
line2
line3
line4
line5
line6
line7
.........
EndBlock>Block1
Let>vNeedle=something
RegEx>%vNeedle%,%vHaystack%.......
Yes, that was the original form I suggested... but after seeing what Marcus has done with Data Labels... I am now hoping for a form closer to this:
Code: Select all
Block>Block1
line1
line2
line3
EndBlock>Block1
BlockToVar>Block1,Haystack
Let>vNeedle=something
RegEx>%vNeedle%,%vHaystack%.......
The difference is, we keep the definition of the block separate from the place where we load the block lines into a particular variable name. This gives us the ability to re-use that block in different ways without having to re-type the lines of the block.
For instance, if you also wanted to run another RegEx line further down but this time use a different variable name and inter-line delimiters, say %LF% instead of %CRLF%, you could just use this:
BlockToVar>Block1,Haystack2,%LF%
To me that's a lot better than having to retype the whole block.
Another thought just struck me. We could really get a lot of milage out of the default behaviour of a block definition. Consider this block:
Block>Block1
line1
line2
line3
EndBlock>Block1
At this point, there is no variable but the blockname is: Block1
Now further down in the script, we want to make use of this block. Let's say we want to write it to a file. So what if we just wrote this:
WriteLn>c:\file.scp,wres,Block1
Ahh you say it would fail because there is no VARIABLE yet called Block1.
True... but that doesn't have to be the case in the future. Default command behaviour could be changed such that after checking for a variable named Block1 (and finding none) it could additionally check for a blockname called Block1 and in this case, it would find it. It could then put the lines together in the default way and simply use them... In this case it would write them to disk to create the file.
The default way I am talking about is... using %CRLF% as inter-line delimiters.
Note that using it in this way does not create an actual variable called Block1... but we were still able to access and use Block1.
For any uses of Block1 other than in the default way, we would have to first use a command that loaded Block1 into a variable... because that command would have parameters allowing us to specify a different inter-line delimiter and whatever other parameters we'll have, for example...
BlockToVar>Block1,Haystack2,%LF%
...then we'd just use the variable Haystack2 in any command.
Again, just throwing these ideas out there. I would like to hear what the rest of you think.
Marcus, I have a question.
I created a file called "IMPORT_TEST.TXT" that contained 3 lines:
line 1
line 2
line 3
Then with my macro open in the editor, I clicked
Tools/Import Binary File and pointed it at the file. This created the following lines in my macro:
/*
IMPORT_TEST.TXT_DATA:
6C696E6520310D0A6C696E6520320D0A6C696E6520330D0A
*/
So then I ran the following command...
ExportData>IMPORT_TEST.TXT_DATA,C:\Users\Owner\My Documents\export_test.txt
And sure enough it created a duplicate of the first file on disk named export_test.txt
So then I did this...
/*
I_TYPED_THESE_BLOCK_LINES.TXT_DATA:
line 10
line 20
line 30
*/
ExportData>I_TYPED_THESE_BLOCK_LINES.TXT_DATA,C:\Users\Owner\My Documents\export_test2.txt
And the file it created on disk was gibberish. I understand why... If I had typed the binary representation of the lines in my block, it would have written what I had wanted to write.
My question is... does your planned LabelToVar> command properly handle Data Labels where the content is binary AND where the content is ACII i.e. lines we have typed in directly?
If that is not possible or if it is problematic... then maybe Data Labels like this...
/*
IMPORT_TEST.TXT_DATA:
6C696E6520310D0A6C696E6520320D0A6C696E6520330D0A
*/
...should strictly be left to handle binary data and a new block definition structure like this...
Block>BlockName
Line 1
Line 2
Line 3
BlockEnd>BlockName
...could handle the ASCII format text.
Also, would BlockEnd> or EndBlock> be better to use? I suppose since we have VBEND... maybe BlockEnd> would be more in keeping with naming convention. In any case, I would caution against just using End> as that is what ends a subroutine.
Here's something else to ponder. What if we had the following lines:
Block>Block1
Line 1
Block>Block1
Line 2
Line 3
BlockEnd>Block1
Line 4
BlockEnd>Block1
In the above, the whole thing is Block1. Inside it, we merely have some lines that also define a block, maybe because this block contains code that will be another macro we write to disk. So would Macro Scheduler parse this correctly as one block named Block1? Or would we have to define it this way to help things along?
Block>Block1
Line 1
_%Block>Block1%_
Line 2
Line 3
_%BlockEnd>Block1%_
Line 4
BlockEnd>Block1
JRL, you like writing code that writes code, any thoughts? Marcus?
Again, just thinking out loud. Thanks for listening and take care.