[Gambas-user] print does not output if the var is FALSE, how to override?

Tobias Boege taboege at gmail.com
Fri Jun 29 00:09:18 CEST 2018


On Thu, 28 Jun 2018, PICCORO McKAY Lenz wrote:
> > Instead of Jussi's suggestion with IIf() you can also use Str$(),
> > if you really just want "True" or "False" to be printed and not some
> > other strings.
> >
> well seems to work, but i want something more direct,
> 
> so them how to override the print rule/code/class ?
> 

I believe it's called SUBR_print [1]. It's deeply wired into the interpreter
because it's a keyword in the Gambas language. It's not polymorphic and gives
you nothing to hook into. It really just (locale-awarely) coerces its arguments
to string using Str$().

I don't see how you could modify its implementation without having to ship your
own Gambas to your users. I also think wanting to change the Print instruction
is misguided. Just add a Print() method to your class, which formats it in
whatever fancy way you need, and call that.

Regards,
Tobi

[1] https://gitlab.com/gambas/gambas/blob/master/main/gbx/gbx_subr_file.c#L278

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


More information about the User mailing list