( in preprocessor

Discussion related to "Everything" 1.5.
Post Reply
NotNull
Posts: 5961
Joined: Wed May 24, 2017 9:22 pm

( in preprocessor

Post by NotNull »

addcol:a a:=[repeat:"(",3]
=> ""
addcol:a a:=[repeat:"[",3]
=> ""
addcol:a a:=[repeat:")",3]
=> ")))"
addcol:a a:=[repeat:"]",3]
=> ")))"

What is going on here? (and how to work around it?)

Other non-alphanumeric characters give unexpected results too.
Phlashman
Posts: 53
Joined: Sun Sep 11, 2022 4:57 am

Re: ( in preprocessor

Post by Phlashman »

Try
addcol:a a:=[repeat:char(40),3]

where char() is the character function and 40 is the ASCII dec code for the "(" character
void
Developer
Posts: 19870
Joined: Fri Oct 16, 2009 11:31 pm

Re: ( in preprocessor

Post by void »

[repeat:"(",3]
is the term processor.
The term processor is applied before formulas

[repeat:"(",3] => (((

Which is then evaluated as a formula.
Formulas will treat unhandled text as literal.
( is handled as parenthesis.
Although, there's no terminating )
I want to at some stage return an #error: value.
For now, formulas are not strict.

Please try the following instead:

addcol:a a:=REPEAT("(",3)

The formula REPEAT() function returns a string.
NotNull
Posts: 5961
Joined: Wed May 24, 2017 9:22 pm

Re: ( in preprocessor

Post by NotNull »

Phlashman wrote: Sun Jan 05, 2025 11:00 pm addcol:a a:=[repeat:char(40),3]
Good idea! Tested and works fine. Thanks!


void wrote: Sun Jan 05, 2025 11:13 pm [..] Which is then evaluated as a formula.
Aha, the fog is lifting a bit ..
Testing: addcol:B B:=((( gives an empty colum too.
And indeed: a:=&quot:[repeat:"(",3]&quot: gives the expected result.

void wrote: Sun Jan 05, 2025 11:13 pm Please try the following instead:
addcol:a a:=REPEAT("(",3)

Will try, but for what I want to do, the term processor needs to build some formulas *before* they are executed.
void
Developer
Posts: 19870
Joined: Fri Oct 16, 2009 11:31 pm

Re: ( in preprocessor

Post by void »

addcol:a a:=[repeat:char(40),3]


expands to:

char(40)char(40)char(40)


Formulas evaluate this as:

(((
Post Reply