{"id":1918,"date":"2014-11-13T21:23:28","date_gmt":"2014-11-13T21:23:28","guid":{"rendered":"https:\/\/alt2.minisoft.com\/support\/?p=1918"},"modified":"2016-09-26T01:03:59","modified_gmt":"2016-09-26T01:03:59","slug":"using-data-access-from-delphi-3-with-arrays","status":"publish","type":"post","link":"https:\/\/c002.minisoft.com\/support\/using-data-access-from-delphi-3-with-arrays\/","title":{"rendered":"Using Data Access &#8211; From Delphi 3 with Arrays"},"content":{"rendered":"<p>The MDMDA session object is being called from a Borland Delphi 3 application.<br \/>\nThis sample includes references to an item array (12J1).<\/p>\n<p class=\"subheads\">The dataset and items are defined as follows:<\/p>\n<pre>ITEMS:\r\nITEM-NO, Z6;\r\nSALES-PERIODS, 12X6;\r\nSALES-HISTORY, 12P12;\r\nMISC, 12J1;\r\nOTHER, J2;\r\n\r\nSETS:\r\nNAME: HISTORY, DETAIL (1\/18);\r\nENTRY: ITEM-NO(!HISTORY-M),\r\nSALES-PERIODS,\r\nSALES-HISTORY,\r\nMISC,\r\nOTHER;\r\nCAPACITY: 101;\r\nEND.<\/pre>\n<p><a href=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2014\/11\/mdm_001.gif\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1919\" src=\"https:\/\/alt2.minisoft.com\/support\/wp-content\/uploads\/2014\/11\/mdm_001.gif\" alt=\"mdm_001\" width=\"380\" height=\"353\" \/><\/a><\/p>\n<pre>unit Unit1;\r\n\r\ninterface\r\n\r\nuses\r\nWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,\r\nStdCtrls, Grids;\r\n\r\ntype\r\nTForm1 = class(TForm)\r\nEdit1: TEdit;\r\nEdit2: TEdit;\r\nMISC: TStringGrid;\r\nNext: TButton;\r\nRewind: TButton;\r\nAdd: TButton;\r\nprocedure FormCreate(Sender: TObject);\r\nprocedure NextClick(Sender: TObject);\r\nprocedure RewindClick(Sender: TObject);\r\nprocedure AddClick(Sender: TObject);\r\nprivate\r\nda : Variant;\r\ndb : Variant;\r\nds : Variant;\r\nt1 : string;\r\nprocedure GetItemValues;\r\nprocedure SetItemValues;\r\nend;\r\n\r\nvar\r\nForm1: TForm1;\r\n\r\nimplementation\r\n\r\n{$R *.DFM}\r\n\r\nuses\r\ncomobj;\r\n\r\nprocedure TForm1.GetItemValues;\r\nvar\r\nt2 : string;\r\nii : integer;\r\njj : integer;\r\nbegin\r\nt1 := '';\r\nfor ii := 0 to 11 do begin\r\nt2 := trim(Misc.Cells[0,ii]);\r\nif ( t2 = '' ) then begin\r\njj := 0;\r\nend else begin\r\ntry\r\njj := StrToInt ( t2 );\r\nexcept\r\njj := 0;\r\nend;\r\nend;\r\nt1 := t1 + format ( '%6d', [jj] );\r\nend;\r\nds.Item('ITEM-NO') := Edit1.Text;\r\nds.Item('MISC') := t1;\r\nEdit2.Text := t1;\r\nend;\r\n\r\nprocedure TForm1.SetItemValues;\r\nvar\r\nt2 : string;\r\nii : integer;\r\njj : integer;\r\nbegin\r\nEdit1.Text := ds.Item('ITEM-NO');\r\nt1 := ds.Item('MISC');\r\nEdit2.Text := t1;\r\nfor ii := 0 to 11 do begin\r\nt2 := trim(copy(t1, 1+(ii*6),6));\r\nif ( t2 = '' ) then begin\r\njj := 0;\r\nend else begin\r\ntry\r\njj := StrToInt ( t2 );\r\nexcept\r\njj := 0;\r\nend;\r\nend;\r\nMisc.Cells [0,ii] := IntToStr ( jj );\r\nend;\r\nend;\r\n\r\nprocedure TForm1.FormCreate(Sender: TObject);\r\nbegin\r\nda := CreateOleObject('MdmDA.Session');\r\nda.TraceLevel := 0;\r\nda.HostAddress := 'support';\r\nda.Port := '30002';\r\nda.LoginUser := 'mgr';\r\nda.UserPassword := InputBox('user password','user password', '');\r\nda.LoginGroup := 'util';\r\nda.LoginAccount := 'minisoft';\r\nIf Not da.Connect Then begin\r\nShowMessage ( 'Connect failed' );\r\nexit;\r\nEnd;\r\nIf da.LoginStatus = False Then begin\r\nShowMessage ( 'Login failed' );\r\nexit;\r\nEnd;\r\ndb := da.AddImageDBRef('MSCARD');\r\nds := db.AddDatasetRef('HISTORY');\r\nIf Not db.Open('MSCARD', 'UTIL', 'MINISOFT', 1, 'DO-ALL') Then begin\r\nShowMessage ( 'Open failed' );\r\nExit;\r\nEnd;\r\nds.Delimiter := '';\r\nIf Not ds.ReadSerialNext('@;') Then begin\r\nShowMessage ( 'readserialnext failed: ' + ds.ErrorMessage );\r\nExit;\r\nEnd;\r\n\r\nSetItemValues;\r\n\r\nend;\r\n\r\nprocedure TForm1.NextClick(Sender: TObject);\r\nbegin\r\n\r\nIf Not ds.ReadSerialNext('@;') Then begin\r\nShowMessage ( 'readserialnext failed: ' + ds.ErrorMessage );\r\nExit;\r\nEnd;\r\n\r\nSetItemValues;\r\n\r\nend;\r\n\r\nprocedure TForm1.RewindClick(Sender: TObject);\r\nbegin\r\n\r\nIf Not ds.Rewind Then begin\r\nShowMessage ( 'Rewind Failed: ' + ds.ErrorMessage );\r\nExit;\r\nEnd;\r\n\r\nend;\r\n\r\nprocedure TForm1.AddClick(Sender: TObject);\r\nbegin\r\n\r\nGetItemValues;\r\n\r\nIf Not ds.Write('@;') Then begin\r\nShowMessage ( 'Write failed: ' + ds.ErrorMessage );\r\nExit;\r\nEnd;\r\n\r\nend;\r\n\r\nend<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The MDMDA session object is being called from a Borland Delphi 3 application. This sample includes references to an item array (12J1). The dataset and items are defined as follows: ITEMS: ITEM-NO, Z6; SALES-PERIODS, 12X6; SALES-HISTORY, 12P12; MISC, 12J1; OTHER, J2; SETS: NAME: HISTORY, DETAIL (1\/18); ENTRY: ITEM-NO(!HISTORY-M), SALES-PERIODS, SALES-HISTORY, MISC, OTHER; CAPACITY: 101; END. [&hellip;]<\/p>\n","protected":false},"author":75,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,54],"tags":[],"_links":{"self":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1918"}],"collection":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/comments?post=1918"}],"version-history":[{"count":1,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1918\/revisions"}],"predecessor-version":[{"id":1920,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/posts\/1918\/revisions\/1920"}],"wp:attachment":[{"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/media?parent=1918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/categories?post=1918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c002.minisoft.com\/support\/wp-json\/wp\/v2\/tags?post=1918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}