B4J Question String $ usage

ThRuST

Well-Known Member
Licensed User
Longtime User
I'd like that someone can explain how to use the string ${''} works and how it can be used? also refer to a tutorial on this. Thanks
 

Daestrum

Expert
Licensed User
Longtime User
It's a shortcut to allow you to place variables inside a $"..."$ string.

Instead of having to write
B4X:
Log("This is the time  : [" & DateTime.Time(DateTime.now) & " ]")

You can write
B4X:
Log($"This is the time  : [ ${DateTime.Time(DateTime.now)} ]"$)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Thanks, your example was as clear as it could be I've seen a similar handling for C sharp years ago, it was a new invention. Nice to be able to use it with B4X as well.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
ok so just to make it simple the [ ] chars is not neccessary it's just a decoration thing, just to clearlfy Don Manfred's example, anyway thanks

This is a good start, keep posting some more examples since this is a complex matter

I made Don Manfreds complicated code alot easier haha
B4X:
Log($"This current date is $date{DateTime.now} and the time is $time{DateTime.now}"$)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
And I should point out that when using this with CSS a HTML tag must always start with < and end with > Objections anyone?


B4X:
$"
<code goes here blabla ${variable1} blalba ${variable2}>
"$

Reminds me of Ajax/Cordova/JQuery calls even Angular.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…