Jump to content

Ole Ekerhovd

  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio

Recent Profile Visitors

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

  1. Ole Ekerhovd

    Boolean evaluation

    A very, very idiotic mistake. The same check was also done from another unit, I did not remember it. That routine had the exact same text in Showmessage and that routine had a bug and checked against True, not False! So it was not the error message in the routine I posted here that was shown. A lot of hours lost, but I guess this may happen when a program grow to hundreds of units?
  2. Ole Ekerhovd

    Boolean evaluation

    Why? Please elaborate so I can learn from it 🙂
  3. Ole Ekerhovd

    Boolean evaluation

    Solved 🙂 It was a logical error in the code, and really hard to catch too. Regards, Ole
  4. Ole Ekerhovd

    Boolean evaluation

    Kryvich: aUser.Administrator is a boolean field in a record structure. Lars: No, even if I do aUser.Administrator:=true; if aUser.Administrator=false then begin .... end; the begin end always execute.
  5. Delphi 10.3 I have a code snippet that is not working as I expect. // Check if active user is different from document owner if aUser.Username<>aDocument.Owner then begin // If user is not an administrator if aUser.Administrator=false then begin showmessage('You are not allowed to delete this document'); exit; end; end; Problem: the showmessage pops up even if the active user is an administrator and the boolean Administrator is True What anm I missing here? Ole
  6. Ole Ekerhovd

    Parse XML

    Hi Remy Thanks for your answer, your code example works perfectly. Your comment on "dump code" is duly noted, it was not my intention. Regards, Ole
  7. Ole Ekerhovd

    Parse XML

    I'm not able to parse an xml file. I have looked into several code examples online, but I think parsing xml is quite hard to understand 🙂 Code shown is partly from Embarcadero Code Examples. I'm interested in getting then value/text from the msg-no, sender and receiver nodes. Any help appreciated. Regards Ole This is the xml file <inbox-query-response version="1.0"> <messages> <message> <self>https://xxxxxxx</self> <message-meta-data> <msg-no>9064430</msg-no> <direction>IN</direction> <received>2019-11-24T09:00:12.000+01:00</received> <uuid>15745</uuid> <peppol-header> <sender>9908:123</sender> <receiver>9908:456</receiver> <channel>busdox-transport-as2-ver1p0</channel> <document-type>INVOICE</document-type> <document-id>Long text here</document-id> <process-name>UNKNOWN</process-name> <process-id>urn:www.cenbii.eu:profile:bii05:ver2.0</process-id> </peppol-header> </message-meta-data> </message> <message> <self>https://xxxxxxx</self> <message-meta-data> <msg-no>9064565</msg-no> <direction>IN</direction> <received>2019-11-24T15:00:14.000+01:00</received> <uuid>15746</uuid> <peppol-header> <sender>9908:321</sender> <receiver>9908:654</receiver> <channel>busdox-transport-as2-ver1p0</channel> <document-type>INVOICE</document-type> <document-id>Long text here</document-id> <process-name>UNKNOWN</process-name> <process-id>urn:www.cenbii.eu:profile:bii05:ver2.0</process-id> </peppol-header> </message-meta-data> </message> </messages> </inbox-query-response> This is the code I try to use procedure TForm2.RetrieveDocument; const CAttrName = 'version'; // This is found //CAttrName = 'msg-no'; This is not found var LDocument: IXMLDocument; LNodeElement, LNode: IXMLNode; LAttrValue: string; I: Integer; begin LDocument := TXMLDocument.Create(nil); LDocument.LoadFromFile(SrcPath); { File should exist. } // Number of childNodes, always shows 1 showmessage(inttostr(Ldocument.ChildNodes.Count)); { Find a specific node. } LNodeElement := LDocument.ChildNodes.FindNode('inbox-query-response'); if (LNodeElement <> nil) then begin { Get a specific attribute. } if (LNodeElement.HasAttribute(CAttrName)) then begin LAttrValue := LNodeElement.Attributes[CAttrName]; showmessage('Attribute value: ' + LAttrValue); end; { Traverse child nodes. } for I := 0 to LNodeElement.ChildNodes.Count - 1 do // Gives only one iteration begin LNode := LNodeElement.ChildNodes.Get(I); { Display node name. } showmessage('Node name: ' + LNode.NodeName); // Only node, messages, is shown ones { Check whether the node type is Text. } if LNode.NodeType = ntText then begin showmessage('This is a node of type Text. The text is: ' + LNode.Text); end; { Check whether the node is text element. } if LNode.IsTextElement then begin showmessage('This is a text element. The text is: ' + LNode.Text); end; end; end; end;
  8. Ole Ekerhovd

    Rest request fails with error 406

    Thanks Zoran, now it's working fine. Had to set: Accept as */* Accept encoding as gzip,deflate Regards Ole
  9. Hi Delphi Tokyo. I try to make a Rest request using Delhpi Rest Debugger (a really simple one), but it fails with an error 406 Not acceptable. Basic authentication is used. When I make the exact same request using Postman there is no error and I get a valid response. Anybody with similar experiense? Regards Ole
  10. Ole Ekerhovd


    Thanks Remy, really appreciate it. Regards, Ole
  11. This code gives an error, "Invalid Pointer Operation". It's the aBlob.Free that triggers the error. What's wrong in my code? I should Free I guess? var aBlob : TBlobField; aStream : TStream; try ablob:=aQuery.fieldbyname('Memo') as tblobfield; astream:=Tmemorystream.Create; astream := aquery.CreateBlobStream(ablob, bmRead); amemo.Lines.LoadFromStream(astream); finally ablob.Free; astream.Free; end;