{"id":405,"date":"2020-04-30T14:19:10","date_gmt":"2020-04-30T12:19:10","guid":{"rendered":"http:\/\/www.stepit.co.za\/wp\/?p=405"},"modified":"2020-04-30T14:19:10","modified_gmt":"2020-04-30T12:19:10","slug":"delphi-key-value-pairs","status":"publish","type":"post","link":"http:\/\/www.stepit.co.za\/wp\/blog\/2020\/04\/30\/delphi-key-value-pairs\/","title":{"rendered":"Delphi Key Value Pairs"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We get so used to the data structures in more modern languages that its frustrating using old Delphi 7 but I will show you how you can at least create a list map like structure using TStringList.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\n var\n  KeyValuePairsSample: TStringList;\n  iIndex : integer;\n  sname, svalue, svalueindex: string;\nbegin\n  KeyValuePairsSample := TStringList.Create;\n  KeyValuePairsSample.Clear;\n  KeyValuePairsSample.NameValueSeparator := '=';\n    KeyValuePairsSample.Add('ZERO=0'); \/\/ name=value pair \/\/\n  KeyValuePairsSample.Add('ONE=1');\n  KeyValuePairsSample.Add('TWO=2');\n  KeyValuePairsSample.Add('THREE=3');\n  KeyValuePairsSample.Add('FOUR=4');\n  KeyValuePairsSample.Add('FIVE=5');\n  Memo1.Clear;\n  Memo1.Lines.Add(KeyValuePairsSample.Names&#x5B;1]);\n  Memo1.Lines.Add(KeyValuePairsSample.Values&#x5B;'THREE']);\n  Memo1.Lines.Add(KeyValuePairsSample.Names&#x5B;0]);\n\n  Memo1.Lines.Add(inttostr(KeyValuePairsSample.IndexOfName('THREE')));\n Memo1.Lines.Add(KeyValuePairsSample.ValueFromIndex&#x5B;KeyValuePairsSample.IndexOfName('THREE')]);\n  KeyValuePairsSample.free;\nend;\n\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nOutput:\nONE\n3\nZERO\n3\n3\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>We get so used to the data structures in more modern languages that its frustrating using old Delphi 7 but I will show you how you can at least create a list map like structure using TStringList.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-405","post","type-post","status-publish","format-standard","hentry","category-delphi"],"_links":{"self":[{"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/posts\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/comments?post=405"}],"version-history":[{"count":2,"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/posts\/405\/revisions"}],"predecessor-version":[{"id":407,"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/posts\/405\/revisions\/407"}],"wp:attachment":[{"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/media?parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/categories?post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.stepit.co.za\/wp\/wp-json\/wp\/v2\/tags?post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}