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

PICCORO McKAY Lenz mckaygerhard at gmail.com
Fri Jun 29 20:53:39 CEST 2018


2018-06-29 14:30 GMT-04:00 Tobias Boege <taboege at gmail.com>:

> > ok how can i force the type of result from variant to boolean
> This is not the problem. Despite being inside a Variant "container",
> False is still known to be a Boolean internally and will be printed
> correctly. Just try it:
>
>   Dim a As Variant = False
>   Print a
>   > False
>
works! so then following your mail we get some details that let me in same
situation:


> Here, you are concatenating a Boolean to a string. This coerces the Boolean
> to a string, but it does so using CStr(), which prints False as Null, which
> is the empty string, as I explained earlier. It's not that you "Print", but
>
i understant clear that you posted! please see that:

but in any case inclusivelly usign your suggested funtion code does not
return "False" so

> that you "&". Either use Str$(exu.email(...)) or
>   Print exu.email("mpes");; "y este";; exu.email("email at mail.com")
> and Print will take care of the human-friendly Boolean conversion.
>
this let me in same situation, normal print does not print the variable
jajajajajaj XD XD


BTW, I personally wouldn't write the function like that in the first place.
> You only get in trouble because the returned datatype depends on the
> argument.
>
yeah now i got "T" for match case but still "null" or empty for false!



> I would write it like this:
>
>   Public Function email(texto As Variant) As Boolean
>     ' For performance: compile the pattern once and cache it
>     Return texto Match "^[A-Za-z0-9._%+-]+@[A-Za-z0-
> 9.-]+\\.[A-Za-z]{2,8}$"
>   Endif
>
> and use it to actually branch in the code that wants to do something
> with texto. But if you really value the one-liner here, there's probably
> no other choice.
>
that's horrible, i think its a bug now! as you can see in the previously
code!
i need a solution to mantain simple a keep compatibility, gambas becomes be
too unflexible! currently the odbc in 3.11 are a crap and now details like
this!


> PS: As always when someone posts a regex for email addresses, yours is
> not quite perfect. For starters, we have very long TLDs these days,
> like .christmas, .engineering or .cancerresearch [1], which your regex
> will reject.
>
> [1] https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains

YES you have right but i not have enought experience in regex xpressions i
send another mail to mantain this in context!



>
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180629/5e2d2ca7/attachment-0001.html>


More information about the User mailing list