TIP: Click on subject to list as thread! ANSI
echo: semware
to: All
from: `Dalton Spence`
date: 2003-01-16 14:16:08
subject: [TSEPro] Re: Using .ui file procedures in external macros

From: "Dalton Spence" 
@Date: Wed, 15 Jan 2003 22:46:09 -0500
@Sender: semware-owner{at}sawasdi.apana.org.au



----- Original Message -----
Sent: Wednesday, January 15, 2003 12:15 PM

> ----- Original Message -----
> From: "Sammy Mitchell" 
> Sent: Tuesday, January 14, 2003 7:18 PM
>
> > In version 4 of TSE Pro, public procedures can be called via
> > external macros.  For example:
> >
> > ---------foo.s---------------------------------------------
> > public proc doit()
> >     MsgBox("", "Hello from foo!")
> > end
> >
> > ---------bar.s---------------------------------------------
> > proc main()
> >     ExecMacro("foo", "doit")
> > end
> >
> > When you run bar.mac, assuming assuming foo.mac exists, the
> > doit procedure in foo will run.
> >
> > And, you can do the same thing with your .ui file:
> >
> > ---------tse.ui--------------------------------------------
> > public proc mEmptyClipboard()
> >     EmptyBuffer(Query(ClipboardId))
> > end
> >
> > ---------test.s--------------------------------------------
> > proc main()
> >     ExecMacro(".ui", "mEmptyClipboard") //
note ".ui"
> > end
> >
> > What good is this?
> >
> > 1) You can have a macro library, that is shared by multiple
> > macros.  While simply #including the relevant code also
> > works, the macro library sometimes offers a better solution.
> >
> > 2) This also opens up .ui file routines to external macros.
> >
> > 3) Since the parameters to ExecMacro() are strings, this can
> > potentially be used for a sort of poor mans dynamic linking
> > facility within the macro language.
> >
> > What is bad about this?
> >
> > 1) The syntax is ugly: ExecMacro(macro-filename, public-macroname)
> >
> > Perhaps in a future version we could just type:
> > macro-filename.public-macroname()
> >
> > 2) Declaring the proc as "public" also makes it show up in
> > the publics list.  For "library" routines, it probably
> > should not show up there.
> >
> > 3) Only procs without parameters are supported in this
> > version.  Bummer.
>
> Too bad you can't make *menus* public. An ExecMenu command could be
> *really* useful here. Half a mo' . . . include the following code in the
UI
> somewhere after the last pull-down menu is defined.
>
>
/**************************************************************************
>   TSE User Interface Pull-Down Menu Procedures for external use
>
>
**************************************************************************/
>
> public proc uiFileMenu()
>     FileMenu()
> end
>
> public proc uiClipMenu()
>     ClipMenu()
> end
>
> public proc uiWindowMenu()
>     WindowMenu()
> end
>
> public proc uiBlockMenu()
>     BlockMenu()
> end
>
> public proc uiSearchMenu()
>     SearchMenu()
> end
>
> public proc uiPrintMenu()
>     PrintMenu()
> end
>
> public proc uiMacroMenu()
>     MacroMenu()
> end
>
> public proc uiTextMenu()
>     TextMenu()
> end
>
> public proc uiUtilMenu()
>     UtilMenu()
> end
>
> public proc uiOptionsMenu()
>     OptionsMenu()
> end
>
> public proc uiHelpMenu()
>     HelpMenu()
> end
>
>
/**************************************************************************
> /
>
> This allows you to use the default menus in your customized menubar as
> below.

Oops(part 2)! I forgot that menubars can only execute menus. :( Oh well,
couldn't a popup menu fixed in the upper left-hand corner could be
considered a vertical menu bar? (Of course, if my ExecMenu command idea is
adopted, the menubar function could be rewritten to accept those as well.)
Here's what I've got that works:

/**************************************************************************
**
  TSE Pull-down Menus

***************************************************************************
/

menu HelpMenu()
    history

    "Table of &Contents" ,   GeneralHelp()
    "&Key Assignments"   ,   Help("Key Assignments")
    "&Index"             ,   Help("Index")
    "&Word at Cursor"    ,   HelpOnWordAtCursor()
    "&Marked Topic"      ,   HelpOnTopic()
    "&Previous Topic"    ,   PrevHelp()
    "&About..."          ,   About()

menu MainMenu()
    history
    title="Main Menus"
    x=1
    y=1
    "&File"    ,   
ExecMacro(".ui","uiFileMenu")   , DontClose
    "&Text"    ,   
ExecMacro(".ui","uiTextMenu")   , DontClose
    "&Search"  ,   
ExecMacro(".ui","uiSearchMenu") , DontClose
    "&Block"   ,   
ExecMacro(".ui","uiBlockMenu")  , DontClose
    "&Clip"    ,   
ExecMacro(".ui","uiClipMenu")   , DontClose
    "&Window"  ,   
ExecMacro(".ui","uiWindowMenu") , DontClose
    "&Macro"   ,   
ExecMacro(".ui","uiMacroMenu")  , DontClose
    "&Print"   ,   
ExecMacro(".ui","uiPrintMenu")  , DontClose
    "&Utility" ,   
ExecMacro(".ui","uiUtilMenu")   , DontClose
    "&Options" ,   
ExecMacro(".ui","uiOptionsMenu"), DontClose
    "&Extras"  ,    ExecMacro("MyMenu")            
, DontClose
    "&Help"    ,    HelpMenu()                      , DontClose
end

proc WhenLoaded()
    LoadMacro("MyMenu")     // Load macro to activate key bindings
end

//*** Other commands
********************************************************

                   MainMenu()
                MainMenu()

                    GeneralHelp()
               HelpOnWordAtCursor()
                HelpOnTopic()
                 HelpMenu()

My help system sports two new procedures; 1) GeneralHelp() which displays
the "Macros" help index when the current file extension is .s, .si or .ui
and the "Table of Contents" otherwise, and 2) HelpOnTopic() which can seek
a help topic matching a marked phrase. (I modified HelpOnWordAtCursor() to
use HelpOnTopic() internally.) These procedures may be modified to use
external help systems when appropriate.

--
              {at}=================================================={at}
              | Dalton S. Spence, B.Sc.  |
              | Home Page: http://www.hwcn.org/~ag775/home.html  |
              |      Family Motto: Virtute Acquiritur Honos      |
              | The vice squad takes my club and is commanded by |
              |         the best place possible. FNORD!          |
              {at}=================================================={at}


--
TSEPro mailing list



---
[sawasdi.apana.org.au] (3:800/846.13)
* Origin: apana>>>>>fidonet
SEEN-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™.