jingoro2112 / wrench

practical embedded script interpreter
MIT License
106 stars 9 forks source link

concatenate string #15

Closed rjjrbatarao closed 9 months ago

rjjrbatarao commented 10 months ago

im trying to concatenate string like

message = "hello "; message += "world";

but the output is - hello

how can i do this? is strcat possible in wrench?

jingoro2112 commented 9 months ago

So wrench's string-handling is lacking a little bit, and I am fixing that as we speak. the string functions:

str::strlen str::sprintf str::printf str::format str::isspace str::isdigit str::isalpha str::mid str::chr str::tolower str::toupper str::tol

were an afterthought and obviously need a few additions, I will have these done within the day:

str::concat str::left str::right str::substr str::trimright str::trimleft str::trim str::insert

Those should get you everything you need.

The longer answer is that the operators don't know about strings, I wish they did but I made certain concessions when for speed and compactness. I am looking those concessions over in light of the very usual and reasonable use-case of string operations.

jingoro2112 commented 9 months ago

Okay just uploaded the new str:: library calls + test code. as 3.1.0

"str += str" is not going to happen today,. but I'll take a hard look on adding it.

jingoro2112 commented 9 months ago

HA! I could not get this itch to go away in my head and suddenly hit upon a way to do it, which worked!

3.1.1 now allows code like

str + str

AND

str += str

To work!! Specifically strings and addition only, and at no overhead to normally running code :)

rjjrbatarao commented 9 months ago

wow amazing, thank you for this great addition will be testing it now.