Page 1 of 3
Interpolated Strings
Posted: Thu Aug 16, 2018 10:07 am
by FFF
Guys, Wolfgang,
just found "the" thing about interpolated strings, and thought maybe i'm not the only one a bit slow
VAR i:= 4 AS INT
VAR c AS STRING
c:= i"Bla {i} blabla"
i.e.: the syntax allows to insert ANY type into a string, handling silently the conversions! That's really cool.
Even something like
c:= i"Bla {oMainWindow} blabla"
works, inserting the classname.
So you might consider adding/adapting the docs, as up2now the samples insert only strings, which is relatively pointless
Karl
Interpolated Strings
Posted: Thu Aug 16, 2018 12:11 pm
by wriedmann
Hi Karl,
Currently I am on holiday, will add better samples after my return.
Wolfgang
Interpolated Strings
Posted: Thu Aug 16, 2018 12:43 pm
by FFF
Ey, saw your "status" in whatsapp - cool location....
Enjoy your free days, i'm almost at the end of mine <sigh>
Karl
Interpolated Strings
Posted: Thu Aug 16, 2018 4:09 pm
by Karl-Heinz
Hi Karl,
I'm eagerly waiting for the next C# feature to become true.
local dw as dword
dw := 12_123_789
instead of the boring
dw := 12123789
regards
Karl-Heinz
Interpolated Strings
Posted: Thu Aug 16, 2018 4:27 pm
by Chris
I like that a lot, too!
Interpolated Strings
Posted: Thu Aug 16, 2018 6:49 pm
by FFF
Could it be that you didn't get the drift of my post?
All samples i saw for i"..." used strings as insertion, and that is really old, as i can do the same with simple +...+, so i never understood the usecase
But for any other type it comes handy...
K.
Interpolated Strings
Posted: Thu Aug 16, 2018 8:19 pm
by Karl-Heinz
? 12.22 + " " + today() + " " + setcentury() + " " + 12123789
Maybe even that will work someday
? 12.22 + " " + today() + " " + setcentury() + " " + 12_123_789
Interpolated Strings
Posted: Thu Aug 16, 2018 8:27 pm
by FFF
That all works (but only) for "?"...
Interpolated Strings
Posted: Fri Aug 17, 2018 4:48 am
by robert
Mmm, that (underscore delimiters inside numeric literals) should not be too difficult to implement I think.
I'll see what I can do.
Robert
Interpolated Strings
Posted: Fri Aug 17, 2018 6:29 am
by MathiasHakansson
I use this a lot. I have an old C# application built around datasets and i use this when building sql strings.
plInfo.SqlUpdate =
$@"UPDATE {Const.TBL_PRICE_LIST_STRUCT}
SET
{Const.COL_COLUMN_NUM} = {dataReader.SqlValueString(Const.COL_COLUMN_NUM)}
,{Const.COL_START_POSITION} = {dataReader.SqlValueString(Const.COL_START_POSITION)}
,{Const.COL_END_POSITION} = {dataReader.SqlValueString(Const.COL_END_POSITION)}
,{Const.COL_IS_ACTIVE} = {dataReader.SqlValueString(Const.COL_IS_ACTIVE)}
,{Const.COL_IMPORT_FORMAT} = {dataReader.SqlValueString(Const.COL_IMPORT_FORMAT)}
,{Const.COL_EDIT_UID} = {dataReader.SqlValueString(Const.COL_EDIT_UID)}
,{Const.COL_EDIT_DATE} = '{YYYYMMDDHHMMSS}'
,{Const.COL_CREATE_UID} = {dataReader.SqlValueString(Const.COL_CREATE_UID)}
,{Const.COL_CREATE_DATE} = {dataReader.SqlValueString(Const.COL_CREATE_DATE)}
,{Const.COL_PRICE_FORMAT_NUM} = {dataReader.SqlValueString(Const.COL_PRICE_FORMAT_NUM)}
WHERE {Const.COL_PLS_NUM} = {dataReader.SqlValueString(Const.COL_PLS_NUM)}";