-
Content Count
106 -
Joined
-
Last visited
Everything posted by PizzaProgram
-
@Zoran @programmer You both misunderstood my question. I know about the basics. I know about all those links. Those do not help. I can create reports. (Using them since 20 years.) - But how do I close it safely via code? (For example with a timer.) ONLY the report-preview, not the whole form it's placed on !
-
Convert ISuperObject TDateTime to RFC3339
PizzaProgram posted a topic in ICS - Internet Component Suite
I've just realized that my code is not good enough, because it contains 3 digits after the second part, not just 2, as RFC3339 specifies. function ftdt_ISO(const dt: TDateTime; RFC3339: Boolean = False): string; // ISO8601 formรกtum: "2022-04-19T11:30:26.090+02:00" RFC3339 formรกtum: "2022-04-19T11:30:26.09+02:00" const RFCDateLongTimeMask = 'yyyy-mm-dd"T"hh:nn:ss.zz' ; ISODateLongTimeMask = RFCDateLongTimeMask + 'z' ; var TZINFO : TTimeZoneInformation; _b : Double; begin case Windows.GetTimeZoneInformation(TZINFO) of TIME_ZONE_ID_STANDARD: _b := TZINFO.Bias / (60*24); TIME_ZONE_ID_DAYLIGHT: _b := (TZINFO.Bias+ TZINFO.DaylightBias) / (60*24); else _b := 0; end; Result := FormatDateTime( IfThen(RFC3339, RFCDateLongTimeMask, ISODateLongTimeMask), dt) + ifThen(_b <= 0, '+', '-') + FormatDateTime( 'hh:nn', _b) ; end; I'm using it this way: var o : ISuperObject; begin ... o := SO(); o.S['started'] := ftdt_ISO( myTime, True ); // result: 2022-11-19T18:18:18.123+01:00 instead of ..18.12+.. Is there a working way to do it under Delphi 7 ? Thanks for the help! ๐ -
Convert ISuperObject TDateTime to RFC3339
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
OFF: Oh... now I understand! Sorry, never thought about that. Using ICS since this few month only. (PS: Sorry I didn't sent you a postcard yet, I hate Hungarian government post offices and rarely leave my house. But ICS is great! I love it and I'm thinking about You every day and how I could repay You for this great work...) -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram posted a topic in ICS - Internet Component Suite
Hi, I'm trying this function the first time and it would be really great, if it would find the string I'm looking for. Here is my code: procedure TFrm_Ntak.gmb_jsonTesztClick(Sender: TObject); var o : ISuperObject; function stat_search(what: string): string; var JsonSearch : TSuperObjectIter; begin Result := ''; if ObjectFindFirst(o, JsonSearch) then begin repeat if JsonSearch.key = what then begin Result := JsonSearch.val.AsString; Break; end; until not ObjectFindNext(JsonSearch); end; ObjectFindClose( JsonSearch ); end; begin o := SO('{"messageAnswers":[{"id":"fe134b3e-...","successfullMsgs":[{"type":"DAILYCLOSING","rmsID":"fe134b3e-..."}],"status":"SUCCESS"}]}'); ShowMessage( stat_search('status') ); end; Instead of showing : SUCCESS it gives back no result. I can see, that the trouble is caused by the ARRAY, but I simply don't get it, why an "universal search" function can not handle that? So what can I do? I don't know the EXACT form of the json it needs to digest, there can be multiple embedded arrays, or who knows what ... but I need to search for this specific value. Tried to search on stackoverflow + in ICS samples too, no success. Thanks for any help ! ๐ -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
No problem! I'll see what I can do, and copy the end result here. ๐ -
Convert ISuperObject TDateTime to RFC3339
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
This is a non-breaking way, it's a fix, because this format is BOTH RFC3339 AND ISO 8601-1:2019 compatible. https://ijmacd.github.io/rfc3339-iso8601/ -
Convert ISuperObject TDateTime to RFC3339
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
Found it, here is the fix for OverbyteICSUtils.pas line 1676: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // V8.62 Get time zone bias as string, ie -0730 // V8.71 Get time zone bias as RFC3339 compatible string, ie -07:30 function IcsGetLocalTZBiasStr: String; var Bias: Integer; Sign: String; begin Bias := IcsGetLocalTimeZoneBias; if Bias > 0 then Sign := '-' else Sign := '+'; Bias := Abs(Bias); Result := Format('%s%.2u%s%.2u', [Sign, Bias div 60, ':', Bias mod 60]); end; ... also changed %d = decimal to %u = unsigned, because Bias can be negative. (I'm not sure, if it's necessary, but it's better to make sure.) Tested it, works nice with our current +01:00 winter-timezone. Cheers ๐ -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
I was thinking how to enhance the practical usage of this ISuperObject component, because it is great, but lack of "easy-to-use" methods. So why not enhance the original methods a bit too, to search in Arrays too ? function ObjectFindFirst(const obj: ISuperObject; var F: TSuperObjectIter; const inArrayToo: Boolean = False): boolean; ... function ObjectFindNext(var F: TSuperObjectIter; const inArraysToo: Boolean = False): boolean; At the FindFirst it would be necessary, because it is possible that the whole JSON is an array. {[{..},{..}]} I've looked into the iterator code, but sadly I do not understand how this whole FPath[FDepth] := h; thing works. Can not understand the concept and there are no comments in the code. So I can not do it myself. What is your opinion? Can / Would you like to enhance it? -
Convert ISuperObject TDateTime to RFC3339
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
This is the best compare table I've found. (Except that it is maybe wrong about the millisecond part) https://ijmacd.github.io/rfc3339-iso8601/ You can see, that +0100 timezone format is ONLY ISO compatible, but not RFC3339. -
Convert ISuperObject TDateTime to RFC3339
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
Yes, I know that, thank you for doing it! That was the first thing I've tried. But that format gets rejected by our Government's server. ๐ (Our dictatorial gov. su**s.) {"sentValue":"2022-11-20T14:52:52+0100","errorKey":"MissmatchType","errorMessage":"Field Type not appropriate!"} They are most likely using Java. We (programmers) have no idea why it getting rejected. In their examples they always use this format: 2022-11-11T12:34:56.78+01:00 RFC3339 is more strict than ISO. Edit: 1. max frac. 2 digits after second are allowed 2. there must be a ":" sign for timezone part. -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
Can you maybe rewrite it, so it may serve every kind of value? I've never done such thing, so can not help. Something with VarArray ... or like: function SearchInAll(const inWhat: ISuperObject; findThisarray[1..1] of const; var foundValue: TSuperValue): Boolean; Edit: added "foundValue" for adding back the Result, if Boolean = True; -
ICS V8.70 announced
PizzaProgram replied to Angus Robertson's topic in ICS - Internet Component Suite
Never mind, looked at the old code and realized: those 2 lines are simply switched ! ๐ New code (wrong) {$ELSE} IgnorePathList.Delimiter, '"' + IgnorePathList.Delimiter + '"', [rfReplaceAll]) + '"'; { V8.63 for D7 } IgnorePathList.DelimitedText := '"' + StringReplace(AnsiLowerCase(FIgnorePaths), {$ENDIF} Old code (working) {$ELSE} IgnorePathList.DelimitedText := '"' + StringReplace(AnsiLowerCase(FIgnorePaths), IgnorePathList.Delimiter, '"' + IgnorePathList.Delimiter + '"', [rfReplaceAll]) + '"'; { V8.63 for D7 } {$ENDIF} -
ICS V8.70 announced
PizzaProgram replied to Angus Robertson's topic in ICS - Internet Component Suite
If I try to compile the runtime under Delphi 7: [Error] OverbyteIcsFileCopy.pas(1583): 'END' expected but ',' found -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
PS: Thanks for notifying me, and your patients ! ๐ -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
No, can not EDIT. That function is Disabled. Maybe that was the problem before >> it showed the Edit button on that day, but did not really allow it. Here is it again: function SearchInAll(inWhat: ISuperObject; const findThis : string): string; // returns '' if not found var JsonSearch : TSuperObjectIter; i : integer; begin Result := ''; if inWhat = nil then Exit; if ObjectFindFirst(inWhat, JsonSearch) then begin repeat if JsonSearch.key = findThis then Result := JsonSearch.val.AsString else if JsonSearch.val.DataType = stObject then Result := SearchInAll( JsonSearch.val, findThis ) else if JsonSearch.val.DataType = stArray then begin for i := 0 to JsonSearch.val.AsArray.Length -1 do begin Result := SearchInAll( JsonSearch.val.AsArray.O[i], findThis ); if Result <> '' then Break; end; end; if Result <> '' then Break; until not ObjectFindNext(JsonSearch); end; ObjectFindClose( JsonSearch ); end; -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
Hmmm... That's strange! I've replaced all occurrences, wrote: "fixed" on Sunday. Now I see: the code is reverted back, all js_keres naming are back! Maybe some browser-cashing problem. Restarted Firefox. I'm fixing again... -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
Sorry, but which message? Did I spell something wrong? My English is not perfect. -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
A leftover from half-translation. Fixed. -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
Sorry for the late response, I've already wrote it myself. Although it would be great to put it directly into: unit OverbyteIcsSuperObject; Should be changed to an universal one, not just "string". The result should be a Boolean. function SearchInAll(inWhat: ISuperObject; const findThis : string): string; // returns '' if not found var JsonSearch : TSuperObjectIter; i : integer; begin Result := ''; if inWhat = nil then Exit; if ObjectFindFirst(inWhat, JsonSearch) then begin repeat if JsonSearch.key = findThis then Result := JsonSearch.val.AsString else if JsonSearch.val.DataType = stObject then Result := js_keres( JsonSearch.val, findThis ) else if JsonSearch.val.DataType = stArray then begin for i := 0 to JsonSearch.val.AsArray.Length -1 do begin Result := js_keres( JsonSearch.val.AsArray.O[i], findThis ); if Result <> '' then Break; end; end; if Result <> '' then Break; until not ObjectFindNext(JsonSearch); end; ObjectFindClose( JsonSearch ); end; -
TSuperObjectIter ObjectFindFirst problem
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
Yes, that's what I wrote too: I know that. To rephrase my question: - Is there no "ready to use" function for that? > if not, WHY ? - Nobody has a finished version? Nobody ever needed such a thing? I can not imagine that! -
How to build JSON with ISuperObject as an Array ?
PizzaProgram posted a topic in ICS - Internet Component Suite
My code looks currently like this, but it is causing AV error. ๐ function JSONt_array_Creator(z1: string) : SOString; var o, n: ISuperObject; begin Result := ''; o := SO(); insert_other_JSON_data( o ); n := SO(); n.S['id'] := z1 ; o.O['identifiers'].AsArray.Add( n ); // << ERROR Result := o.AsJSon(); n := nil; o := nil; end; The result should look like this { "base": "something", "identifiers": [ {id: 2} ] } There are many many SO examples out there, but all about "how to parse / read / digest ..." not a single one about "how to CREATE SO sub-tree or array ... ". -
How to build JSON with ISuperObject as an Array ?
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
YES, thank You! ๐ OFF: I think the problem was, that first we need to create an Array on that level, and we can .Add() elements only after that. Maybe you can improve the code later to add "auto-array-creation" in those cases, but it's not necessary. Some better examples can do it also. I would do it myself, but I have a nearing deadline and already working 14-16 hours pro day. Sorry. -
How to build JSON with ISuperObject as an Array ?
PizzaProgram replied to PizzaProgram's topic in ICS - Internet Component Suite
This method works: ๐ n := SO(); n.S['id'] := z1 ; o.O['identifiers'] := SA([ n ]); -
I'm using a simple procedure to save and load form positions under Delphi 7. procedure LoadSavePos(f: TForm; save: Boolean); begin ... if not save then begin ScreenSnap := True; f.Top := t; f.Height := h; ... But if I set these values during `OnShow` procedure, they get ignored, and the window is restoring to the position of: - before the ScreenSnap happened ! ๐ ScreenSnap is that: - Any time the user is resizing the window, and nearing to the edge, the form "jumps" to full height or width. That's fine, it should work like this, but I can not set those positions, only if I restart the whole program, and the form is showed initially, loading the new values. My guess is it may has to do with the https://www.alphaskins.com components, but it is extremely hard to debug it.
-
ISuperObject local double conversion problem. {"value":0,22}
PizzaProgram posted a topic in ICS - Internet Component Suite
In Hungarian language (and Windows) defaults we use "decimal-comma", instead of decimal-point to write down float numbers: `100 000,34 (instead of: 100000.34)` I know, it's not ideal, but that's how it is. The original ISuperObject had no problem with this, (we have tested!) it has created still numbers `Obj.D['value'] := 100000.34` with dec.point: `{"value":100000.34}` But now it does insert comma "," instead of point "." I see at CHANGED: Aug 11, 2020 - V8.65 ... Replaced gcvt with FloattoStr Usually I am using my own conversion function for these, and thought I could pass the value by string: var FormatSetting : TFormatSettings; FormatSSajat : TFormatSettings; //0x040e Hungarian Hungary 1250 HUN GetLocaleFormatSettings(1038, FormatSetting); FormatSSajat := FormatSetting; FormatSSajat.DecimalSeparator := '.'; FormatSSajat.DateSeparator := '.'; FormatSSajat.ShortDateFormat := 'yyyy.MM.dd'; // Win10 compatibility, because they have changed to 'yyyy. MM. dd' ๐ฎ ... function fts(const i:Double ) : string; begin Result := FormatFloat('0.00000000', i, FormatSSajat); end; // and pass as string: json.S['value'] := fts(0.33); But that is wrong too !!! because it will enclose it to "" : `{"value":"100000.34"}` What can we do ?