Post Reply 
Custom Text Formatting (Previously: Getting long results in a program)
04-07-2024, 05:55 AM (This post was last modified: 04-07-2024 06:52 AM by komame.)
Post: #45
RE: Getting long results in Program
(04-06-2024 09:27 PM)komame Wrote:  4. And one minor oversight: you need to add closing parentheses in the EXPR expressions.

Actually, it's not necessary because PPL correctly interprets and executes commands where closing parentheses aren't explicitly provided, in cases where they occur at the very end of the command.

Additionally, I found another bug that resulted in accepting a command with 9 parameters when the second parameter wasn't GROB (the issue also occurs in your proposal). To fix this in my proposal, we need to add "t==8" in the last condition of the "CASE" statement: d==9 => d==8 and t==8.

In the previous example, I made a mistake in suggesting the use of SUPPRESS. Of course, SUPPRESS should only be applied to the converted-to-string list, not the entire expression:
f:=STRING(l);
f:="TEXTOUT_P("+SUPPRESS(f,{1,SIZE(f)});

The corrected code is below:

Code:
EXPORT ATEXTOUT_P(...l)
BEGIN
 LOCAL d:=SIZE(l),t:=TYPE(l(2)),i,f;
 CASE
  if 2<d<6  OR (d==6  AND t==8) then
   f:=STRING(l);
   f:="TEXTOUT_P("+SUPPRESS(f,{1,SIZE(f)});
   //EXPR(f);
  end;
  if 5<d<9 then  
   IF t≠8 THEN 
    l:=INSERT(l,2,G0);
   END;
   IF d<8 THEN
    l(0):=GET(TEXTSIZE(l(1),l(5)),1);
   END;
   f:=STRING(l);
   f:="TEXTOUT_P("+SUPPRESS(f,{1,SIZE(f)});
   //EXPR(f);
  end;
  if d==9 and t==8 then
   f:=STRING(f);
   f:="TEXTOUT_P("+SUPPRESS(f,{1,SIZE(f)});
   //EXPR(f);
  end;
  default
   EXPR("Syntax error");
 END;
 f;
END;

I have only one question regarding your assumptions. It seems to me that the "atextout_p" function should always be called with 9 parameters because all default parameters should be set by the calling the main function, which receives a variable number of parameters. However, I see that you are doing it differently because the generated calls have from 7 to 9 parameters. Does this mean that you want to create 3 functions named "atextout_p"?

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-07-2024 05:55 AM
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: 1 Guest(s)