Post Reply 
Custom Text Formatting (Previously: Getting long results in a program)
04-03-2024, 07:27 PM (This post was last modified: 04-03-2024 07:29 PM by komame.)
Post: #36
RE: Getting long results in Program
(04-03-2024 05:15 AM)Tyann Wrote:  Thanks for your help, my approach is the same as yours, the same function with a different number of parameters.
I've set the attributes parameter to position 7 so that the limited width and the overlap remain optional.

There is another way to handle default parameter values. I'm not sure if it will be better, but it doesn't require creating separate functions with different numbers of parameters. For this purpose, you can use a variable-length argument. This solution allows passing from 1 to 16 values to the function. Then it's just a matter of checking the types of the passed values, which can be done by comparing entire lists.

For example (inside the "CASE", all permissible scenarios should be listed):
Code:
EXPORT DRAWTEXT_P(...par)
BEGIN
  LOCAL pt;
  pt:=EXECON("TYPE(&1)",par);
  CASE
    IF EQ(pt,{2,8,0}) THEN
      //set params default values
    END;
    IF EQ(pt,{2,0}) THEN
      //set params default values
    END;
    IF EQ(pt,{2,8,0}) THEN
      //set params default values
    END;
    RETURN "Syntax Error";
  END;
  //The rest of the function's code 
END;

(04-03-2024 05:15 AM)Tyann Wrote:  Yes, the superbold is very nice, but one question comes to mind: these different attributes should be able to be combined: bold and underlined for example.
How would this work for these different types of bold, perhaps using a decimal value?

There are many possibilities here. It's a matter of preference. It could even be a string where each character corresponds to enabling a specific format, for example: B - bold, U - underline, I - italic, S - strikethrough, D - double-bold, F - framed. If any of these letters appear in the string (using INSTRING), then it's clear that a specific format needs to be set. But decimal presentation is also fine.

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-03-2024 07:27 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: