| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | [TSEPro] OpenSafe Macro (was `Re: Miscellaneous info, latest FAQ, et |
From: "Dalton Spence"
@Date: Sun, 12 Jan 2003 11:40:00 -0500
@Sender: semware-owner{at}sawasdi.apana.org.au
----- Original Message -----
From: "Sammy Mitchell"
Sent: Saturday, January 11, 2003 10:09 AM
> >Oops! I spoke too soon. It seemed to work okay to start
> >with, but somewhere along the line it began starting every
> >session in browse mode, even for the valid extensions. Any
> >ideas as to why?
> I was taking a break from listening to Adventures in Odyssey
> - it is an episode I've already heard - (Ranger Bill is up
> next, can't miss that one!) and I saw your message, so I
> thought I'd whip up a reply. And then I got a little
> carried away - I hope you don't mind!
Not at all! I asked for help, didn't I?
> The problem is CurrExt() returns the leading '.' if there is
> an extension, and the '.' is not stored in DefaultExt. Here
> is a slightly modified version, and my comments as to how I
> got there. I hope it helps!
Huh? Well, I'll be darned. How did I miss that? :(
> So, to see if there is a match, we need to remove the '.'
> from CurrExt().
>
> if Pos(RightStr(CurrExt(), Length(CurrExt()) - 1),
> Query(DefaultExt)) > 0 ...
Rather than the RightStr function, how about SubStr(CurrExt(),2,3)?
Same effect, fewer function calls.
> Snippet follows - I leave it to you to combine it with your
> original macro.
Here's what I got. As you can see, I prefer assigning the values to
variables for flexibility. In this case, it allowed me to use the
macro command line to enter an alternate list of valid extensions.
(Uhm, command line arguments *can* be added to the Autoload list
entry, right?)
string DftExt[62]
proc OpenSafe()
string ExtToken[5]=" " + SubStr(CurrExt(),2,3) + " "
if (not BrowseMode())
if Pos(ExtToken,DftExt) == 0
BrowseMode(TRUE)
Message("Opened in Browse Mode by Default")
endif
endif
end
proc WhenLoaded()
if (Query(MacroCmdLine)=="")
DftExt=" " + Query(DefaultExt) + " "
else
DftExt=" " + Trim(Lower(Query(MacroCmdLine))) + " "
endif
Hook(_ON_FIRST_EDIT_,OpenSafe)
end
proc main()
EditFile()
PurgeMacro("OpenSafe")
end
My biggest concern was which event to hook this to. Originally this
macro was designed to prevent accidently altering an unregistered
file type from Windows, but I realized that non-text files had an
equal chance of being opened from within the editor itself. Another
issue is the Autoload sequence; any that open invalid files for
editting *after* OpenSafe is loaded would be opened in Browse mode.
I added a main procedure to allow one-shot interactive execution,
but as it automatically purges itself any command line arguments
have to be re-enterred.
--
{at}=================================================={at}
| Dalton S. Spence, B.Sc. |
| Home Page: http://www.hwcn.org/~ag775/home.html |
| Family Motto: Virtute Acquiritur Honos |
| A kitten from Toledo commands the anorexic |
| phone. FNORD! |
{at}=================================================={at}
--
TSEPro mailing list
---
[sawasdi.apana.org.au] (3:800/846.13)
* Origin: apana>>>>>fidonetSEEN-BY: 633/267 270 @PATH: 800/846 1 640/954 774/605 123/500 106/1 379/1 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.