Jump to content

Bob Baudewyns

Members
  • Content Count

    16
  • Joined

  • Last visited

Community Reputation

1 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thank you for your feedback. I managed to solve my RegEx problems quite some time ago with the help of another member (Fr0sT.Brutal) But this is indeed a very interesting approach.
  2. Bob Baudewyns

    Updating a JSON file with THTTPClient

    Got it. Thanks for the clarification Uwe. Have a nice weekend
  3. Bob Baudewyns

    Updating a JSON file with THTTPClient

    There is absolutely no server action here. Sorry for the confusion. Let's say it's a remote file instead of a file stored on each local computer The file is just sitting there to be shared between computers and potentially modified by one of these computers Imagine this is a configuration JSON file driving the behavior of each computer. But can be changed and affecting all computers that are reading it at startup My question is focusing if I can change that file by code without downloading and uploading it. If I can get the content of the file with THTTPClient.Get, why I couldn't change that content with POST or PUT ?
  4. Bob Baudewyns

    Updating a JSON file with THTTPClient

    The URL is located on a web server. www.smallconsult.com/Tests/Test.json This is for quick test purpose The server response Status Text is just OK. I don't want to upload the file. I want to update the content of that file on the server
  5. Hi, To drive my application, I am downloading at startup a JSON structure from a file located on a server. I need to share that file between me and a remote person. I am doing that successfully with the following code: function GetJSONFromServer(const Filename: string): TJSONObject; var FullURLPath: string; Buffer: TStringStream; Client: THTTPClient; Response: IHTTPResponse; begin Result:= nil; Buffer := TStringStream.Create; try Client := THTTPClient.Create; try FullURLPath:= Concat(URL, '/', Filename); Response:= Client.Options(FullURLPath, nil, 0); if Response.GetStatusCode = 200 then begin Client.Get(FullURLPath, Buffer); if (Buffer.Size > 0) then Result:= TJSONObject.ParseJSONValue(Buffer.DataString) as TJSONObject else Log('ERROR: JSON File is empty !', ErrorColor); end else Log('ERROR: File does not exist on server !', ErrorColor); finally Client.Free(); end; finally Buffer.Free(); end; end; I'm simply trying to do the opposite: Updating the same JSON file at shutdown. The following code doesn't generate any error but the file is not updated. function PostJSONToServer(const Filename: string; const JSONObject: TJSONObject): Boolean; var FullURLPath: string; Buffer: TStringStream; Client: THTTPClient; Response: IHTTPResponse; begin Result:= false; Buffer := TStringStream.Create; try Client := THTTPClient.Create; try FullURLPath:= Concat(URL, '/', Filename); Response:= Client.Options(FullURLPath, nil, 0); if Response.GetStatusCode = 200 then begin Buffer.Seek(0, soFromBeginning); Buffer.WriteString(JSONObject.ToString); Client.Post(FullURLPath, Buffer); if Response.GetStatusCode = 200 then begin Log('Transaction with server successfull !', OkColor); Result:= true; end else Log('ERROR: Transaction with server failed !', ErrorColor); end else Log('ERROR: File does not exist on server !', ErrorColor); finally Client.Free(); end; finally Buffer.Free(); end; end; The buffer contents before posting is correct. Is my code completely wrong ? Should I use another query instead of Post ? Is it a matter of security preventing me to modify the file ? Is there a workaround to allow such transaction ? Thanks
  6. The string conversion is supposed to be done by the end user of the application inside the GUI Not from the IDE by the developer. So, RegEx, running "behind the scene" looks like the best option here.
  7. Oh, I see. Unfortunately not. All of this is inside Delphi code.
  8. Hi, Thank you for your feedback. @Fr0sT.Brutal. I am not at all a RegEx expert. This is Chinese for me. The search string provided is not understood by regex101.com If you are an expert, your help would be greatly appreciated. @David What do you mean exactly by scripting language ? How this could help writing a "formula" to convert such strings ?
  9. I need to update a large number of strings because the syntax is not compliant with the expected format. I would like to automate that process. Such strings can have a mix of alphanumeric, numeric and special characters. A small example would be appropriate here Let's say 3 different strings: NameA 01 01 [A-01] NameB 01 02 [B-02] NameC 01 03 [C-03] Should become: My Name A [1963-A-01] My Name B [1963-B-02] My Name C [1963-C-03] As you can see: - 'My ' is inserted at the beginning - A space is inserted between 'Name' and 'A' - The two groups of numbers before '[' are removed - '1963-' is inserted after '[' Rules: String Length can be different Some characters need to be added/inserted Some others need to be removed Others need to be replaced Inserting space/special characters The same rules must be applied to all strings based on a specific "syntax" defining what should be added/removed/replaced and at which location in the string. Do you known the most efficient way to achieve such smart replacement with Delphi ? Is Regular Expression can be applied here and how ? I'm looking to provide an Edit field that would allow the user to enter the syntax(rules) and see the result applied dynamically like done by Regular Expression web sites
  10. Bob Baudewyns

    How to design QR Scan focus screen with FMX

    Hey, well done ! Thanks
  11. Bob Baudewyns

    How to design QR Scan focus screen with FMX

    Thank you again Rollo62, In the meantime, I did something very close in the IDE with: - 1 TGridPanelLayout - 4 Outer Black TRectangle with opacity 0.5 - 8 Inner Yellow TRectangle with appropriate rounded corners With a TImage as background for rendering the camera, it looks Ok to me
  12. Bob Baudewyns

    How to design QR Scan focus screen with FMX

    Hi, Thanks for your feedback. My app is intended for Android and iOS. I already know all these solutions and examples. By the way, I am using ZXing with the standard FMX Camera because this is the same code for all platforms. With my friend Erik from Winsoft, I need 3 libraries as mentioned by you. But I am indeed using Winsoft's Barcode for FireMonkey to generate the QR codes My problem is not generating or scanning QR codes. This is working just fine. It is just a matter of look & feel for the scanning screen as explained above.
  13. Bob Baudewyns

    How to design QR Scan focus screen with FMX

    Hi, I'm developing an application that needs to scan QR Code. For the GUI design, I'd like to provide the usual scan focus screen with a transparent square inside a rectangle (the screen) like the attached mock-up. I already tried different approaches but not very successful. Any idea how could I design this with FMX ? Thanks
  14. Bob Baudewyns

    REST: Delete an object

    I have found my (stupid) mistake. I still had another object (me as user) as body from another request. I corrected that using RESTRequest.Body.ClearBody; RESTRequest.Params.Clear; Case closed
  15. Bob Baudewyns

    REST: Delete an object

    This is the request captured with Fiddler DELETE https://ws.synchroteam.com/api/v3/job/delete?myId=467927 HTTP/1.1 Connection: Keep-Alive Content-Type: application/json Accept: text/json Accept-Charset: UTF-8 Authorization: Basic XXXXXXXXXX Cookie: incap_ses_466_1982613=JG+hNrWzP3ntmaXA4pB3BhU0SmAAAAAArMFLFUXF8+BXuhjHFDJEIA==; visid_incap_1982613=eLvuGVc7ToSqZT5dVRPkcRU0SmAAAAAAQUIPAAAAAADEtuE8tUgs/WIAYTcpXzLh; ASP.NET_SessionId=tpffwpqwj0pphbx5s3llzp3f User-Agent: Embarcadero RESTClient/1.0 Content-Length: 348 Host: ws.synchroteam.com And response HTTP/1.1 404 Not Found Cache-Control: private, s-maxage=0 Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/10.0 X-RateLimit-Limit: 1000 X-RateLimit-Remaining: 999 X-RateLimit-Reset: 1615476362 X-Quota-Limit: 15000 X-Quota-Remaining: 14679 Date: Thu, 11 Mar 2021 15:25:02 GMT Content-Length: 66 X-CDN: Imperva X-Iinfo: 10-12437416-12437480 SNNN RT(1615476301530 1054) q(0 0 0 -1) r(1 1) U6 {"error":"Not Found","message":"The requested Job does not exist"}
×