Help with a macro

16 views
Skip to first unread message

Jose Adriano Baltieri

unread,
Jan 20, 2026, 4:50:33 AM (11 days ago) Jan 20
to sem...@googlegroups.com
Hi !

Unfortunately I've lost my fluency in SAL and this is so SAD ! I used to write a lot with it... 

However I've been retired for a couple years and , even though I still use Tessie ^.*A +LOT.*$ , I couldn't write this very simple macro (it may looks even silly for the knowledged ones) :

Imagine you're on top (cursor) of a variable name you don't like. The macro would do this (when triggered) :

Open the Replace dialog, with the "Replace From" already filled with the word under cursor (the bad variable name) , then followed by the same word again, on the Replace To Field and finally, for the options, it would be with the default value "GIW". One could change any of these fields, of course.

It's a very simple thing to do (the macro), I guess...

Thanks 4 any help !

BTW : can U believe I've been in love with Tessie for 27 years (or so) ? I knew it before the Year 2000 "nightmare" ! 

Thanks again !
--


Grato,
Jose Adriano Baltieri

Carlo Hogeveen

unread,
Jan 20, 2026, 6:11:34 AM (11 days ago) Jan 20
to sem...@googlegroups.com

Dieter Koessl's dlg222.zip package does most of what you describe.
You can find it on Semware's "classic" website at:
https://semware.com/html/tseprofilesd.php

Executing "DlgRplc" does show such a dialogue, does offer the word under the cursor as the from-word, and remembers what options you used last time, so you can make it "giw" as requested.
Unlike your request it does not offer the word under the cursor as the to-word.

Beware:
Dieter erroneously uses .si files as include files, and uses .s files with the same names.
.si and .s files compile to the same .mac file, one overwriting the other.
By ALWAYS compiling .si files before .s files Dieter's mistake will be ignored.

Carlo



Carlo Hogeveen

unread,
Jan 20, 2026, 10:29:18 AM (10 days ago) Jan 20
to sem...@googlegroups.com

Hi Jose,

Below is a 90-line macro that does exactly what you specified:

"Imagine you're on top (cursor) of a variable name you don't like. The macro would do this (when triggered) :
Open the Replace dialog, with the "Replace From" already filled with the word under cursor (the bad variable name) , then followed by the same word again, on the Replace To Field and finally, for the options, it would be with the default value "GIW". One could change any of these fields, of course."

Use <[Shift] Tab> to switch fields, <Enter> to do the replace, or <Escape>.

Carlo


/*
Replace command as specified by Jose Adriano Baltieri on 20 Jan 2026
in the TSE mailing list.
*/


integer field = 1
integer stop = TRUE


proc after_getkey()
case Query(Key)
when <Tab>
stop = FALSE
if field == 3
field = 1
else
field = field + 1
endif
Set(Key, -1)
PushKey(<Enter>)
PushKey(<end>)
when <Shift Tab>
stop = FALSE
if field == 1
field = 3
else
field = field - 1
endif
Set(Key, -1)
PushKey(<Enter>)
PushKey(<end>)
endcase
end after_getkey


proc Main()

string replace_from [MAXSTRINGLEN] = GetWord()
string replace_to [MAXSTRINGLEN] = GetWord()
string replace_options [12] = 'giw'

if replace_from == ''
replace_from = GetHistoryStr(_FIND_HISTORY_, 1)
endif
if replace_to == ''
replace_to = GetHistoryStr(_REPLACE_HISTORY_, 1)
endif
if replace_options == ''
replace_options = GetHistoryStr(_REPLACEOPTIONS_HISTORY_, 1)
endif

PopWinOpen(3, 5, Query(ScreenCols) - 3, 5 + 7, 1, 'Replace',
Query(MenuTextAttr))
PutStrAttrXY(1, 1, Format('From:' :-255), '', Query(MenuTextAttr))
PutStrAttrXY(1, 2, Format(replace_from :-255), '', Query(TextAttr))
PutStrAttrXY(1, 3, Format('To:' :-255), '', Query(MenuTextAttr))
PutStrAttrXY(1, 4, Format(replace_to :-255), '', Query(TextAttr))
PutStrAttrXY(1, 5, Format('Options:' :-255), '', Query(MenuTextAttr))
PutStrAttrXY(1, 6, Format(replace_options:-255), '', Query(TextAttr))

Hook(_AFTER_GETKEY_, after_getkey)

repeat
stop = TRUE

case field
when 1
VGotoXY(1, 2)
Read(replace_from , _FIND_HISTORY_)
when 2
VGotoXY(1, 4)
Read(replace_to , _REPLACE_HISTORY_)
when 3
VGotoXY(1, 6)
Read(replace_options, _REPLACEOPTIONS_HISTORY_)
endcase
until stop

UnHook(after_getkey)
PopWinClose()

if stop
and (Query(Key) in <Enter>, <GreyEnter>)
and replace_from <> replace_to
Replace(replace_from, replace_to, replace_options)
endif

PurgeMacro(CurrMacroFilename())
end Main





Reply all
Reply to author
Forward
0 new messages