Custom Text Formatting (Previously: Getting long results in a program)
|
04-06-2024, 09:27 PM
(This post was last modified: 04-06-2024 10:41 PM by komame.)
Post: #44
|
|||
|
|||
RE: Getting long results in Program
(04-06-2024 04:01 PM)Tyann Wrote: I think we've hit the nail on the head when it comes to the structure of the function. It looks good, but a few minor corrections are required. 1. You used: f:=SUPPRESS(f,"{}"); however, this won't work for cases where you want to display text containing curly braces because they will be removed. That's why I suggested using MID earlier. If you still insist on using SUPPRESS, it's also possible, but it needs to be implemented using slightly different syntax: f:=SUPPRESS(f,{1,SIZE(f)}). 2. The condition: 5<d<8 OR (d==8 AND t==8) can be simplified to 5<d<9 because the two subsequent conditions already exclude t=8 and d=8 respectively, and in conjunction with 5<d<9, they will behave the same way. This, in turn, allows us to change d>7 to d>8 And then the following condition can be removed: IF d==8 THEN l:=INSERT(l,2,G0); END; 3. Missing protection against too many parameters. A "Syntax error" should be triggered when more than 9 parameters are provided. Currently, providing 10 or more parameters does not trigger an error. 4. And one minor oversight: you need to add closing parentheses in the EXPR expressions. Here is the code after all these corrections: Code: EXPORT ATEXTOUT_P(...l) It's a pity that in PPL there's no capability to throw errors. Simply returning the string "Syntax Error" doesn't effectively address the issue, as it fails to trigger an error within the program, allowing it to continue execution. I propose using the EXPR("Syntax error"), which raises an "Syntax error" and terminates program execution. I know it's just a workaround, but at the moment, I don't know of a better solution. It would be beneficial to have a built-in mechanism in PPL where any error can be raised on demand. Piotr Kowalewski |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 66 Guest(s)