Post Reply 
Custom Text Formatting (Previously: Getting long results in a program)
04-08-2024, 10:48 PM (This post was last modified: 04-09-2024 05:12 AM by komame.)
Post: #53
RE: Getting long results in Program
(04-08-2024 05:58 PM)Tyann Wrote:  When I switched to an atextout(...l) function, I realized that the EXPR construction for calling it was no longer mandatory, so neither were the ... (I've attached the modified code).

Regarding the use of a list in "atextout", thanks to this, you could have dispensed with EXPR on the "ATEXTOUT_P" side, but at the same time, you had to add list-to-variable conversion in "atextout" (which was not necessary with EXPR). You simply replaced one conversion with another conversion, but this is quite a good solution, so I think we should leave it as you suggested.

(04-08-2024 05:58 PM)Tyann Wrote:  As for the 9th parameter, I don't think a default value should be used for the following reason: just like TEXTOUT_P, ATEXTOUT_P should return an error if the value doesn't match a color, unless you have a solution in mind.

In the solution I was thinking of, there wouldn't be such a problem, but your current solution with the list that you proposed is also very good, so there's no point in dwelling on the 9th parameter for now. Let's forget about it - we may revisit it later if needed.

(04-08-2024 05:58 PM)Tyann Wrote:  As far as attributes are concerned, I had personally opted for a numerical value, bearing in mind that for this parameter, which is not known to TEXTOUT_P, we ourselves must return an error if the value is out of range. However, if the same thing can easily be done with a string, no problem for me (we can even consider both).

As for attributes in the form of a text string, I simply prefer this call:
ATEXTOUT_P("text",G0,10,10,7,255,"BU")
because it's immediately clear what it refers to. Such a call is slightly less readable:
ATEXTOUT_P("text",G0,10,10,7,255,3).
But I don't see a problem with sticking to numeric flags if that's your preference.

However, in response to your question, there is a way to easily check if the given sequence of attributes contains only allowed values, and this can be done by using SUPPRESS. Assuming that the given attributes are in the variable "attr", we can check it like this:
SUPPRESS(attr,"BDIUS")

If the result is different from "" (an empty string), it means we have not allowed attributes.
One could also check for duplicate occurrences, which is also quite easy, although in this case, it seems unnecessary to me because even if any attribute is provided more than once, it will not have any negative impact.

(04-08-2024 05:58 PM)Tyann Wrote:  Something I've been thinking about is that if we go into atextout() and the attributes parameter is null (0 or ""), we end up with a simple TEXTOUT_P. Perhaps we should think about handling this special case.

I think this shouldn't be difficult at all.

(04-08-2024 05:58 PM)Tyann Wrote:  Finally, as for your semi-transparent proposal, I don't really see what it means, but why not?

Have you ever used the alpha channel in PPL? Here's an example of using the alpha channel for two rectangles that overlap each other and also overlay an image:
   

Currently, I'm writing a demo that extensively utilizes this feature. Combined with animations, you can achieve amazing graphical effects.
The same mechanism can be used for text to achieve transparent letters.
However, I think we'll come back to this later because I don't want to overly complicate this solution at this stage.

(04-08-2024 05:58 PM)Tyann Wrote:  On the other hand, I'd also like to see a 'framed' parameter.

As for "framed" you were the first to use that term, it was in post #33:
(04-01-2024 09:08 PM)Tyann Wrote:  [...] All this has given me something to think about, and while I've decided on a programme with 2 instructions, DEFTEXT to define the parameters and TEXT_P to display, I'm wondering whether it wouldn't be better to create a single function based on the TEXTOUT_P syntax, with the option of defining attributes such as italics, bold, underlined, framed or strikethrough. [...]

At that time, I even wanted to ask you what "framed" means, but then it was not very important, and ultimately, I forgot to ask later.
Perhaps it's an issue with the translation generated by DeepL?

(04-08-2024 05:58 PM)Tyann Wrote:  I think I now have a complete working code, which can certainly be improved and to which your suggestions can be added. [...]

It's very late already, and I have to go to sleep. But I'll gladly take a look at it tomorrow after work.

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Getting long results in Program - komame - 04-08-2024 10:48 PM
RE: Custom Text Formatting - Tyann - 04-15-2024, 06:55 PM
RE: Custom Text Formatting - komame - 04-15-2024, 07:42 PM
RE: Custom Text Formatting - Tyann - 04-16-2024, 04:38 AM
RE: Custom Text Formatting - komame - 04-16-2024, 06:02 AM



User(s) browsing this thread: 66 Guest(s)