{"action":"created","issue":{"url":"https://api.github.com/repos/CoolProp/CoolProp/issues/892","labels_url":"https://api.github.com/repos/CoolProp/CoolProp/issues/892/labels{/name}","comments_url":"https://api.github.com/repos/CoolProp/CoolProp/issues/892/comments","events_url":"https://api.github.com/repos/CoolProp/CoolProp/issues/892/events","html_url":"https://github.com/CoolProp/CoolProp/issues/892","id":121304856,"number":892,"title":"Delphi wrapper","user":{"login":"bru32","id":8019833,"avatar_url":"https://avatars.githubusercontent.com/u/8019833?v=3","gravatar_id":"","url":"https://api.github.com/users/bru32","html_url":"https://github.com/bru32","followers_url":"https://api.github.com/users/bru32/followers","following_url":"https://api.github.com/users/bru32/following{/other_user}","gists_url":"https://api.github.com/users/bru32/gists{/gist_id}","starred_url":"https://api.github.com/users/bru32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bru32/subscriptions","organizations_url":"https://api.github.com/users/bru32/orgs","repos_url":"https://api.github.com/users/bru32/repos","events_url":"https://api.github.com/users/bru32/events{/privacy}","received_events_url":"https://api.github.com/users/bru32/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-09T18:04:08Z","updated_at":"2015-12-10T05:57:51Z","closed_at":"2015-12-10T05:57:51Z","body":"The Delphi wrapper seems to have some errors (probably just out of date). I had to do a bit of trial and error and managed to get most parts working.\r\n[I tried to attach all the code but it wouldn't accept then  -  how do I submit some code?].\r\n\r\n{\r\n  Delphi Interface for CoolProp\r\n  Bruce Wernick, 9 December 2015\r\n}\r\n\r\nunit cpIntf;\r\n\r\ninterface\r\n\r\nconst\r\n  cpdll = 'CoolProp.dll';\r\n\r\ntype\r\n  CoolChar = AnsiChar;\r\n  PCoolChar = PAnsiChar;\r\n  CoolStr = AnsiString;\r\n  CoolVec = array[0..1023] of CoolChar;\r\n\r\nfunction get_global_param_string(\r\n  param: PCoolChar;\r\n  var res: CoolVec): LongInt; stdcall;\r\n  external cpdll name '_get_global_param_string@12';\r\n\r\nfunction get_fluid_param_string(\r\n  fluid: PCoolChar; param: PCoolChar;\r\n  var Output: CoolVec): Longint; stdcall;\r\n  external cpdll name '_get_fluid_param_string@12';\r\n\r\nfunction PropsSI(spec: PCoolChar;\r\n  prop1: PCoolChar; val1: Double;\r\n  prop2: PCoolChar; val2: Double;\r\n  ref: CoolStr): Double; stdcall;\r\n  external cpdll name '_PropsSI@32';\r\n\r\nfunction Props1SI(spec: PCoolChar;\r\n  ref: CoolStr): Double; stdcall;\r\n  external cpdll name '_Props1SI@8';\r\n\r\nfunction HAPropsSI(spec: PCoolChar;\r\n  prop1: PCoolChar; val1: Double;\r\n  prop2: PCoolChar; val2: Double;\r\n  prop3: PCoolChar; val3: Double): Double; stdcall;\r\n  external cpdll name '_HAPropsSI@40';\r\n\r\nimplementation\r\n\r\nbegin\r\nend.\r\n\r\n\r\nWhen I started using it, I kept getting the odd error.  So, I plotted a ph-chart and on every error, I draw a yellow blob.\r\nThe attached picture shows R22 but a similar pattern happens with all the other fluids.\r\n![coolprop_error01](https://cloud.githubusercontent.com/assets/8019833/11693717/23fefdd2-9eaf-11e5-92db-5f6520671041.png)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/CoolProp/CoolProp/issues/comments/163499174","html_url":"https://github.com/CoolProp/CoolProp/issues/892#issuecomment-163499174","issue_url":"https://api.github.com/repos/CoolProp/CoolProp/issues/892","id":163499174,"user":{"login":"bru32","id":8019833,"avatar_url":"https://avatars.githubusercontent.com/u/8019833?v=3","gravatar_id":"","url":"https://api.github.com/users/bru32","html_url":"https://github.com/bru32","followers_url":"https://api.github.com/users/bru32/followers","following_url":"https://api.github.com/users/bru32/following{/other_user}","gists_url":"https://api.github.com/users/bru32/gists{/gist_id}","starred_url":"https://api.github.com/users/bru32/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bru32/subscriptions","organizations_url":"https://api.github.com/users/bru32/orgs","repos_url":"https://api.github.com/users/bru32/repos","events_url":"https://api.github.com/users/bru32/events{/privacy}","received_events_url":"https://api.github.com/users/bru32/received_events","type":"User","site_admin":false},"created_at":"2015-12-10T05:57:51Z","updated_at":"2015-12-10T05:57:51Z","body":"OK, I will try the pull request.\r\n\r\nIt could be a bug in my code but it is strange that it works correctly over the entire range except for this little region of high pressure liquid.\r\n\r\nHere, you can see the actual line that crashes:\r\n\r\nprocedure TMainForm.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,\r\n  Y: Integer);\r\nvar\r\n  h, p, t: Double;\r\n  i, j: Integer;\r\nbegin\r\n  h := MolChart.P2X(X);\r\n  p := MolChart.P2Y(Y);\r\n  try\r\n    // CoolProp crashes here! (at high pressure liquid)\r\n    t := PropsSI('T', 'P', 1e6*p, 'H', 1e3*h, CoolStr(ref))-273.15;\r\n  except\r\n    t := -99;\r\n    // paint a yellow blob at the position of the error\r\n    for j := -1 to 1 do\r\n      for i := -1 to 1 do\r\n        PaintBox1.Canvas.Pixels[X+i,Y+j] := clYellow;\r\n  end;\r\n  StaticText1.Caption := format('h=%0.3f, p=%0.3f, t=%0.2f', [h,p,t]);\r\nend;\r\n\r\n"}}