faqts : Computers : Programming : Languages : Tse : Configuration : .ui file

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 3 people (67%) answered Yes
Recently 2 of 3 people (67%) answered Yes

Entry

TSE: Configuration: File: .UI: How to possibly use .UI macros in external macros?

Mar 5th, 2005 09:01
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 18 January 2004 - 10:24 pm --------------------

TSE: Configuration: File: .UI: How to possibly use .UI macros in 
external macros?

---

One of the best methods (because you can make changes to your external
macros easily without recompiling your .ui) is to save your macro in an
external file and then use ExecMacro in your .ui to execute it.

---

Steps: Overview:

1. Make a backup of your old .ui file

2. Open a new file in TSE with the extension .s

      myfilename.s

3. Copy your macro inside

e.g.

--- cut here -----------------------

 proc dosomething()
  Warn( "hello" )
 end

 proc main()
  dosomething()
 end

--- cut here -----------------------

4. compile your macro with <CTRL><F9>

5. this will have created a .mac file

     e.g.

      myfilename.mac

6. now goto your .ui file

7. remark out your old statement, using // or /* */
    (so that you can use it again in case of)

    e.g.

    // <F3> myoldmacro

8. replace it with the call to your new macro

e.g.

<F3>    ExecMacro( "myfilename" )

9. save this .ui

10. recompile this .ui in TSE, by pressing <CTRL><F9>

11. quit TSE

12. restart TSE

13. pressing that key combination should do your action now

 e.g.

  <F3> shows "Hello"

---

Here an example of such an approach in an existing TSE.UI.

You can easily move the text to other versions of TSE (e.g. from v3 to
v4), as you only move 'pointers' to macros, that is their 'names' and
not their content.

---

// ------------------------------ //

// <Ctrl f1>                 ExecMacro("video") // old
<Ctrl f1>                    ExecMacro( "gototecq" ) // operation:
goto: text: word: previous: left: capitalize // new

// <Ctrl f2>                 mSwapLines() // old
<Ctrl f2>                    ExecMacro( "gototeco" ) // operation:
goto: text: word: next: right: capitalize // new

// <Ctrl f3>                 // old
<Ctrl f3>                    ExecMacro( "gotorecc" ) // operation:
goto: record: direction: current: header // new

// <Ctrl f4>                 // old
<Ctrl f4>                    ExecMacro( "recogoen" ) // "operation:
goto: record: direction: end // new

<Ctrl f5>                    ExecMacro( "gotopagp" ) // new //
operation: goto: paragraph: previous //

<Ctrl f6>                    ExecMacro( "gotopagn" ) // new //
operation: goto: paragraph: next //

// <Ctrl f7>                 mShift() // old
<Ctrl f7>                    ExecMacro( "gotorerf" ) // operation:
goto: record: macrorunpurge: filename: menu: option //

// <Ctrl f8>                 // old
<Ctrl f8>                    ExecMacro( "gotolmrp" ) // operation:
goto: line: filenamemacro: definition to menu //

<Ctrl f9>                    ExecMacro("Compile " + CurrFilename())

// <Ctrl f10>                MouseMenu() // old
// <Ctrl f10>                MENUMouseMenu() //
// <Ctrl f10>                ExecMacro( "menumomm" ) // operation:
get: menu: open the mouse menu if you right click
<Ctrl f10>                   ExecMacro( "gotoremm" ) // operation:
goto: record: example: current: goto: message when not found // new

<Ctrl f11>                   ExecMacro( "gotorepr" ) // operation:
goto: record: previous: example: marker // new

<Ctrl f12>                   ExecMacro( "gotorenx" ) // operation:
goto: record: next: example: // e.g.: marker // new

// --- OPERATION: GOTO: END --- //

---
---

The problem that I am facing is that I want to use mCopyChar() out
of the Win.ui. My workaround is to copy mCopyChar out of Win.ui
into my external macro, but that is not good if mCopyChar is changed
later.  Are there any better options that I am overlooking?

1. You often see that .UI procedures change their content between the
different version of TSE.
E.g. from TSE v2.5 to v4.0 there are source code changes.

2. So you will not  escape from having to deal with changed source
code in your TSE .ui
(e.g. win.ini)

3. So in my opinion a flexible strategy is to put say that mCopyChar()
in an external file .s file,
compile it, and then use ExecMacro( "mCopyChar" ) everywhere you need
it.
You put also in your win.ini file this ExecMacro( "mCopyChar" ).

4. In case there comes a new win.ini which has a new mCopyChar() with
the same functionality
you know there is just 1 central file in your system where to change
things.
That is in this

   mCopyChar.s

5. Note you will then have to recompile once all your .s files (e.g.
using sc32.exe *.s) to adapt this
macros for your new version of TSE.

---

Another possibility would be to make that .UI procedure or function

'public'

in your .UI file.

(so anyhow involving code change of your .UI file)

You can then also call it with

ExecMacro( "yourmacroprocedurename" )

in any other macro.

Disadvantage: no parameter passing possible in an easy way.

---

Otherwise one might possibly think of:
changing the macro names,
and the order of loading (the latest is the active one)

---
---

Internet: see also:

---

TSE: Configuration: File: .UI: Link: Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/34317/fid/1007

---

Function/Procedure: Public: Create: How to create a public procedure 
or function?
http://www.faqts.com/knowledge_base/view.phtml/aid/28387/fid/903

----------------------------------------------------------------------