Anything akin to macros in I7?

I’m using the Glulx Text Effects by Emily Short extension and it’s proving to be useful, but becomes a bit tedious and rather difficult to read when dealing with more intricate text. Is there a way to take a pattern like:

[first custom style][bold type][italic type]

and put it into a shorthand form like ‘[z]’? A more advanced form might be to allow for a macro variable to be used, as in: [za] or maybe [z]a which might represent:

[first custom style][bold type][italic type]a[roman type]

Note that I’ve defined these:

Table of User Styles (continued)
style name	justification	italic	indentation	first line indentation	font weight	color	reversed	fixed width
special-style-2	left-justified	false	--	--	regular-weight	"#000000"	TRUE	TRUE
special-style-1	left-justified	true	--	--	light-weight	"#FF0000"	FALSE	TRUE

Side question: Is it possible to create more custom styles without altering the extension?

Sure! Just define another “say phrase”:

To say z: 
    say "[first custom style][bold type][italic type]";

or whatever.

You can look up “phrases” in Writing with Inform in the IDE for more of what you can do with phrases.

5 Likes

While the answer above is correct, it will be useless with you example: you can’t combine styles in Glulx.

So writing [first custom style][bold type][italic type] will first switch to the first custom style, then to the bold style, then to the italic style, and you’ll only get italics in the end. And no, you can’t create custom styles. All of this is a limitation from Glulx.

I believe styles are deprecated or something, but I’m not really sure.

(By the way, looking at our names, I might be you from the future! :smile:)

4 Likes

Thank you - I did not realize that such phrases will work within brackets.

It’s a pity that successive flags won’t work, but at least I can use shorter forms for them individually.
I checked the extension and found no indication of deprecation, but the version I referenced is one that had been rewritten by Dannii Willis, so it may be that its predecessor (version 5 by Emily Short) had been deprecated.

Hmmm Natrium729… either that’s an EXTREMELY heavy isotope of Na or you are my future self cleverly telling me I should monitor my diet. :scream:

The bracketed things within double-quoted texts is just Inform 7 getting evaluated. If it’s a text variable or property, or a phrase that returns a text, it’s that text. If It’s a to say phrase, then it’s invoked and whatever it says is output*. (It can actually be arbitrary I7 phrases, not just to say phrases.)

Something one might like to do sometimes but can’t is to have a text literal within one of these texts so you can pass a parameter to one of the phrases.

Something you can do:

To say z (T - a text): say "[first custom style][bold type][italic type][T][roman type]";

and then in your code:

say z "a";

or, if it’s part of something longer…

let t be "a";
say "[other stuff][z t][more other stuff]";
  • well, maybe output. If you let t be "[p][q]"; and there are to say p: and to say q: phrases, then you’re capturing the text resulting from what those phrases say. If you say "[p][q]"; then you’re output-ing them, unless your output itself is being captured because you’re being invoked directly or indirectly by something else storing instead of saying your output.
1 Like

That looks like an interesting shotgun I will be able to discharge at one of both of my feet with ease. :slight_smile:
If I understand this, it won’t be the convenience I was seeking, as the text I’m ‘styling’ consists of many single letters imbedded within paragraphs of text. So that means the first example doesn’t apply. If I were to use the let t be "a" construct (which would apply), then I’d have to define one of these for each letter and case, yes?

well… you could do:

to say ca: say "a".
to say cb: say "b".
[...]

26 times. (“C” is short for “character”.) :upside_down_face:

Sometimes in I7, you will do things you never imagined you would. Filthy things.

1 Like

You can also type out your whole thing with individual characters in a text editor, and do some fancy automatic replacements to turn it into I7 code with the appropriate formatting. I’ve done that more than once.

1 Like

Less filthy.

lab is a room.

an alphabetical-letter is a kind of value. The alphabetical-letters are #a, #b, #c, #d, #e, #f, #g, #h, #i, #j, #k, #l, #m, #n, #o, #p, #q, #r, #s, #t, #u, #v, #w, #x, #y, #z.

to say chr of (ch - alphabetical-letter): (- print (char) (96 + {ch}); -)

To say (ch - an alphabetical-letter):
  say "[bold type][italic type][chr of ch][roman type]";

when play begins:
  say "[#i][#t]['][#s] [#t][#h][#a][#t] [#e][#a][#s][#y].";
1 Like

Seriously, I would have torn my hair out without text substitutions.

"Untitled"

Laboratory is a room.

to say i: say "[italic type]";
to say b: say "[bold type]";

to say /i: say "[roman type]";
to say /b: say "[roman type]";

When play begins:
	say "[i]Heyy. [/i][b]AND WOW heyeee![/b]";
2 Likes

Wowsers! That is a very clever and MUCH less filthy workaround, thanks!