| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | [TSEPro] Re: Miscellaneous info, latest FAQ, etc. |
From: "Sammy Mitchell"
@Date: Sat, 11 Jan 2003 10:09:50 -0500
@Sender: semware-owner{at}sawasdi.apana.org.au
>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!
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!
/***********************************************************************
***
To determine if the current extension (CurrExt()) is in
the list of default extensions (Query(DefaultExt)), We
could just do:
if Pos(CurrExt(), Query(DefaultExt)) > 0 ...
But this won't quite work, because:
1) CurrExt() always returns the leading '.' if there is an
extension.
2) The extensions stored in DefaultExt do not contain the
leading '.'.
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 ...
This almost works, except that a CurrExt() of "foo" will
match a DefaultExt of "foobar".
Since all the extensions in DefaultExt are surrounded by
at least one space on either side (except the first one
and the last one), perhaps we can take advantage of this.
How about adding a space to the begining and end of
DefaultExt to handle the exception cases, and adding a
space to either side of CurrExt() (after trimming off the
leading '.').
if Pos(" " + RightStr(CurrExt(), Length(CurrExt()) - 1)
+ " ", " " + Query(DefaultExt) + "
") > 0
One more case to handle: What if the current file does not
have an extension? CurrExt() in that case returns an
empty string. Our macro should handle this, because we
take the right most (less one) characters of CurrExt(),
which would be 0 characters in this case, and then
sandwich it around a space on either side. This double
space will not match anything in the DefaultExt list, so
we're done - if I got my logic right!
Snippet follows - I leave it to you to combine it with your
original macro.
************************************************************************
**/
proc main()
if (not BrowseMode())
if Pos(" " + RightStr(CurrExt(), Length(CurrExt()) - 1) +
" ",
" " + Query(DefaultExt) + " ") == 0
BrowseMode(on)
Message("Opened in Browse Mode by Default")
endif
endif
end
--
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™.