Back to start
All this started with scripts for DirOpus. Time to use our newly gained knowledge.
Problem:
When interacting with DOPUS, many commands deliver the selected or unselected
contant as a single string. Depending on how many files and directories are
retrieved, this string becomes very, very long. And to make it worse, it uses blanks
for seperating by default. Pathes and names containing blanks cause trouble when
reading the result string. They'll be taken as seperate files e.g. "Check o mat"
is split into 3 file names. We need a seperator to avoid misinterpretations.
But what character is uniqe and not allowed?
The mentioned scripts in the starting post use "*" (asterisk) as a seperator.
This is problematic, the "*" is a valid char in file names. It is not recommended
to use such characters for DOS names, but it is not forbidden.
Following characters are not allowed in file names: ":" colon and "/" slash.
The list of characters allowed includes: ";.,-_#'*+-°^~$" + " " (blank).
The only secure way to identify them as a real seperator and not part of the file
name is to use a combination (e.g. ;-) ), but again, someone might have named his
files like "MyBirthdayPics;-).ilbm"
A single unallowed character might not be unique, f.e. the colon might appear in
pathes or device names, but "::" will probably never happen.
I suggest "::" as delimiter. This is unallowed in files and pathes. Any path
ending with ":" then has 3 colons like "Ram Disk:::". Very easy to identify
when you read about parsing before.
Let's go:
Code:
/**/
Options Results
Address DOPUS.1
GetSelectedAll "::"
selection = result
say selection
Do s=1 until selection=""
Parse Var selection file.s "::" selection
end
Do i=1 to s
say file.i
end
==>
4.Ram Disk:> rx sel
Clipboards::ENV::T::check o mat::check o mat.info::say*.not::sel::
Clipboards
ENV
T
check o mat
check o mat.info
say*.not
sel
4.Ram Disk:>
The result has no path or devices names. A single ":" will do.
Using the parsers abilities is simple and easy to read.
Code can be reused and is royalty free. No magic, no fog.
And if you have read my examples carefully, you came across my question if a
Do While ~Eof() loop can't be done better. In a previous example i deleted last
element read to avoid redundant lines in output.
Compare to example above, the loop introduces a new option "until".
Loops are to be examined in next chapter.