Home » Extra libraries, Code snippets, applications etc. » U++ Esc Interpreter, Esc Macros and templates » simple enhancement for EscValue (ESC_ARRAY is ambigous - is array or is string? newfunc - IsString)
| simple enhancement for EscValue [message #62044] |
Tue, 04 August 2026 20:19  |
luoganda
Messages: 218 Registered: November 2016
|
Experienced Member |
|
|
[edit: added]
Also - a small typo in EscStdLib.cpp:
Escape(global, "OpenFileOut(x)", ESC_OpenFileOut);
Escape(global, "OpenFileAppend(x)", ESC_OpenFileOut);
Just this is missing in EscValue.
EscValue has eg ESC_ARRAY,
but when one does not in advance know if it's an array(eg arr[0] arr[1],...) vs is string "abcd",
it can't continue.
Suppose one want's to store it into a String,
to properly store it as a string it would be: "\"abcd\"" - while array would be as number - eg "1,2,3,4".
Now without IsArrayStr(or IsString) - this can't be done.
So, just adding a simple bit(or byte) would be enough,
eg instead of:
int type;
byte type, arrString,nu1,nu2; (nu1/2 <=not-used)
One could also just add new type - eg ESC_ARRAYSTR.
arrString must be then possibly when setting EscValue - if it's string - marked arrString,eg in esc:
arr_string="abcd"; <=here - array should be marked arrString
arr=[1,2,"abcd",3,4]; <="abcd" should be marked as it already is(ESC_ARRAY) + arrString
And also adding it's check, eg:
IsArrayStr() - or just IsString().
GetString is not really needed to be added, but could be there.
EscValue would be then - perfect,
here just meaning it's fully self descriptive.
It's similar with IsNumber(can be double or int64) - but that is ok since has IsInt64(), and
if there would not be IsInt64 - it would be the same situation like with up array/string ambiguity.
[Updated on: Thu, 06 August 2026 00:57] Report message to a moderator
|
|
|
|
|
|
| Re: simple enhancement for EscValue [message #62048 is a reply to message #62047] |
Sun, 30 August 2026 10:18  |
 |
Klugier
Messages: 1119 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hi,
I fixed the problem and added docs https://github.com/ultimatepp/ultimatepp/pull/407. OpenFileOut and OpenFileAppend works as expected.
path = "/home/klugier/test.txt";
file_a = OpenFileOut(path);
file_a.PutLine("New day!");
file_a.Close();
file_b = OpenFileAppend("/home/klugier/test.txt");
file_b.PutLine("Hello world!");
file_b.Close();
Content of the file:
Klugier
U++ - one framework to rule them all.
|
|
|
|
Goto Forum:
Current Time: Wed Sep 16 20:13:21 GMT+2 2026
Total time taken to generate the page: 0.00703 seconds
|