avoiding non ascii in macros

13 views
Skip to first unread message

Fred H Olson

unread,
Jul 24, 2024, 12:17:05 PM (3 days ago) Jul 24
to Semware
The tse.ui file has the hex byte $10 in several menus
It is displayed as a small solid right facing arrow (for me at least)
to indicate that the item has a sub menu.

The $10 (even one) causes the Linux shell command "file" which
examines files to determine their type to consider tse.ui to be a
"data file".
If all the $10's are change to ">" in tse.ui and redoing command:
file tse.ui
it returns
BSD makefile script, ASCII text

I got to wondering if there was a way to have the $10 used in a
static string in a macro without having the hex byte $10 in the macro's
.s file (or generated at run time).

I formerly used the language FORTH
https://en.wikipedia.org/wiki/Forth_(programming_language) It's
compiler had the ability to exit the compiler temporarily to the
interpreter (run time mode) , run some commands and pass a result back
to the compiler thru the heavily used system stack and resume
compiling. An ability to do something like this would make creating a
static string with a non ascii character without using the non ascii
in the source code possible. Is there another way?

Fred

--
Fred H. Olson Minneapolis,MN 55411 USA (near north Mpls)
Email: fholson at cohousing.org 612-588-9532
My Link Pg: http://fholson.cohousing.org

Carlo Hogeveen

unread,
Jul 24, 2024, 12:46:48 PM (3 days ago) Jul 24
to sem...@googlegroups.com

Fred,

> I got to wondering if there was a way to have the $10 used in a
> static string in a macro without having the hex byte $10 in the macro's
> .s file (or generated at run time).

I think the compilable and working example below answers your question affirmatively.
(Mail converted the \x10 character in the 2nd menu line, but that is irrelevant here.)

Carlo


menu dinner()
history
"Soup", Warn('Tomato soup'), , 'Tomato soup'
"Soup ", Warn('Gazpacho'), , 'Gazpacho'
"Soup " + Chr(16), Warn('Onion soup'), , 'Onion soup'
end dinner

proc Main()
repeat
dinner()
until not MenuOption()
PurgeMacro(CurrMacroFilename())
end Main




Fred H Olson

unread,
Jul 24, 2024, 3:25:56 PM (3 days ago) Jul 24
to sem...@googlegroups.com
On Wed, 24 Jul 2024, Carlo Hogeveen wrote:

>
> Fred,
>
> > I got to wondering if there was a way to have the $10 used in a
> > static string in a macro without having the hex byte $10 in the macro's
> > .s file (or generated at run time).
>
>I think the compilable and working example below answers your
>question affirmatively.

Interesting, thanks Carlo. I looked at the binary of the .mac file
from that code and it does indeed look, if I understand it correctly, like
"Soup " + Chr(16)
gets compiled into a constant string.

I had taken the the help file verbage:

> menu menu_name()
>
> [ title = constant_string ]

to mean that the title had to be presented to the compiler
as a constant string ie a string in quotes.

Fred

> Carlo
>
>
> menu dinner()
> history
> "Soup", Warn('Tomato soup'), , 'Tomato soup'
> "Soup ", Warn('Gazpacho'), , 'Gazpacho'
> "Soup " + Chr(16), Warn('Onion soup'), , 'Onion soup'
> end dinner
>
> proc Main()
> repeat
> dinner()
> until not MenuOption()
> PurgeMacro(CurrMacroFilename())
> end Main
>
>
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/semware/000201dadde9%24116ff7c0%24344fe740%24%40ecarlo.nl.

Carlo Hogeveen

unread,
Jul 25, 2024, 2:28:52 AM (2 days ago) Jul 25
to sem...@googlegroups.com

Building on and exceeding what you asked for, here is an extreme and fun fact.

Using TSE's memory addressing functions, a macro can in run-time modify a string literal to one of equal length.
This includes a menu option's option_string and message.

That said, while less pretty, it is usually a lot simpler to just duplicate the whole menu or to use a menu's var_text_function.

I did use this trick in the EventLogger macro:
Showing the currently configured full directory log path inside a menu option would have looked very bad.
Showing it in the menu option's message (its helpline) looks a lot better.

Carlo




Reply all
Reply to author
Forward
0 new messages