Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: ADO
The script ( which could be called traversing 101 ) simply opens the XML file as an ADO Recordset, assigns variables to columns, then presents the data in a dialog with 'navigation' buttons. The code within the callback subroutine, is generic to any ADO Recordset.
The dialog/script could be modified to include Search and Filter Buttons, but at this point I really want to keep it simple.
Hope this will be of some help to beginners who desire to move from ODBC to ADO.
For the rest of you, you might geta kick out of some of the Industry Code Descriptions.
Here is the WinBatch Script:
; // Winbatch - Dialog Template for Traversing a Database or File ; // Stan Littlefield, November 7, 2002 ; ; // All credit for getting the controls working goes to Marty ; // about the database: ; The template opens an XML file which contains four columns. ; The columns represent the codes and descriptive keywords ; Used to define standard industries. Both the current NAICS ; Codes and the older SIC are referenced ; // ; generic function to assign 'field' values to variables ; and update the dialog text controls #DefineSubroutine Refresh() cN = oN.Value cNT = oNT.Value cS = oS.Value cST = oST.Value DialogControlSet(handle,004,4,cS) DialogControlSet(handle,005,4,cNT) DialogControlSet(handle,010,4,cN) DialogControlSet(handle,011,4,cST) Return(0) #EndSubroutine ; basic callback function to keep dialog fresh on screen ; whileupdatng field values #definesubroutine dialogproc(handle,DialogMessage,DialogControlID,p4,p5) MSG_INIT=0 MSG_PUSHBUTTON=2 Switch DialogMessage Case MSG_INIT ; Initialization DialogProcOptions(handle,MSG_PUSHBUTTON,@TRUE) ; allows for future processing ; of buttond Return (-1) ; each button value corresponds to Icodes[nnn] = where nnn is the value ; After Cancel are Standard buttons and corresponding ADO code Case MSG_PUSHBUTTON ; Process Buttons Switch DialogControlID Case 002 ; Cancel Return (0) Case 001 ; Next If ! RS.Eof RS.MoveNext() If RS.Eof RS.MoveLast() Endif Else RS.MoveNext() Endif Refresh() Break Case 006 ; Previous If RS.Bof RS.MoveFirst() Else RS.MovePrevious() If RS.Bof RS.MoveFirst() Endif Endif Refresh() Break Case 008 ; Top Of File RS.MoveFirst() Refresh() Break Case 007 ; Bottom of File RS.MoveLast() Refresh() Break EndSwitch Return(-2) EndSwitch Return (-1) #endsubroutine adOpenDynamic = 2 adLockReadOnly = 1 adLockOptimistic = 3 adCmdTableDirect = 256 cXML = StrCat(DirGet(), "NAICS.XML") If ! FileExist( cXML ) Then Exit RS = ObjectOpen("ADODB.RecordSet") ; open a full recordset to allow movement RS.Open(cXML,"Provider=MSPersist;",adOpenDynamic,adLockReadOnly,adCmdTableDirect) ; if you want to edit data, the use ;RS.Open(cXML,"Provider=MSPersist;",adOpenDynamic,adLockOptimistic,adCmdTableDirect) ;set up field objects and inital variable values ;variable names will be included in the dialog below oN = RS.Fields(0) oNT = RS.Fields(1) oS = RS.Fields(2) oST = RS.Fields(3) cN = oN.Value cNT = oNT.Value cS = oS.Value cST = oST.Value ; insert dialog from WDL file IcCodesFormat=`WWWDLGED,6.1` IcCodesCaption=`Industry Codes Database` IcCodesX=002 IcCodesY=052 IcCodesWidth=227 IcCodesHeight=086 IcCodesNumControls=011 IcCodesProcedure=`dialogproc` IcCodesFont=`DEFAULT` IcCodesTextColor=`DEFAULT` IcCodesBackground=`DEFAULT,DEFAULT` IcCodes001=`186,006,011,010,PUSHBUTTON,DEFAULT,">",1,1,DEFAULT,"Tahoma|6963|70|34","0|0|0",DEFAULT` IcCodes002=`186,054,034,010,PUSHBUTTON,DEFAULT,"Cancel",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT` IcCodes003=`002,006,019,020,STATICTEXT,DEFAULT,"NAICS CODE",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT` IcCodes004=`026,047,042,011,VARYTEXT,cS,DEFAULT,DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT` IcCodes005=`073,004,107,033,VARYTEXT,cNT,"Vary 2",DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT` IcCodes006=`206,006,010,010,PUSHBUTTON,DEFAULT,"<",2,1,DEFAULT,"Tahoma|6963|70|34","0|0|0",DEFAULT` IcCodes007=`186,023,011,011,PUSHBUTTON,DEFAULT,"|>",3,1,DEFAULT,"Tahoma|6963|70|34","0|0|0",DEFAULT` IcCodes008=`206,023,010,011,PUSHBUTTON,DEFAULT,"|<",4,1,DEFAULT,"Tahoma|6963|70|34","0|0|0",DEFAULT` IcCodes009=`002,046,019,020,STATICTEXT,DEFAULT,"SIC CODE",DEFAULT,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT` IcCodes010=`026,007,042,011,VARYTEXT,cN,DEFAULT,DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT` IcCodes011=`074,044,107,033,VARYTEXT,cST,DEFAULT,DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("IcCodes") ObjectClose( oN ) ObjectClose( oNT ) ObjectClose( oS ) ObjectClose( oST ) RS.Close ObjectClose(RS) Exit
Article ID: W15594
File Created: 2019:08:14:09:21:42
Last Updated: 2019:08:14:09:21:42