B4R Question Difference in Log command

JMB

Active Member
Licensed User
Longtime User
Hi there,

I was just wondering if there is a reason for the difference in the Log Command between B4R and B4J.

In B4J we use "&"
B4X:
Log("Here is the result:" & theResult)

In B4R we use ","
B4X:
Log("Here is the result:" , theResult)

Is there a reason for the difference?

Thanks.

JMB
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
& = concatenation operator. It takes two strings and returns a new string which is the combination of both strings.

There is no such operator in B4R as joining strings requires dynamic memory allocation and is better avoided on small microcontrollers.
See this tutorial: Strings and Bytes

To make it easier for developers to log values, the Log command can receive any number of arguments. It logs each one of the arguments and adds an end of line character at the end.
This way you get the same result without creating new strings which will quickly lead to memory issues.
 
Upvote 0
Top