home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / r / rcdo_c03.zip / RC-DO-C.CMD next >
OS/2 REXX Batch file  |  1992-12-09  |  27KB  |  752 lines

  1. /* RC-DO-C.CMD */
  2. /*Copyright 1992 American Coders LTD  Raleigh NC USA*/
  3. /*All rights reserved*/
  4. /* release 02 - define radio and push button logical arrays */
  5. /* release 03 - define entry field and mle char arrays */
  6. /*                     add dialog on exit warning */
  7. say 'Before use; read RC-DO-C.LIC and RC-DO-C.TXT'
  8. say 'Copyright 1992 American Coders LTD  Raleigh NC USA'
  9. say 'All rights reserved'
  10.  
  11. signal on failure name CLEANUP
  12. signal on halt name CLEANUP
  13. signal on syntax name CLEANUP
  14.  
  15. '@echo off'
  16. call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
  17. initcode = VInit()
  18. if initcode = 'ERROR' then signal CLEANUP
  19.  
  20.  
  21. arg ffile
  22. say ffile
  23. file = ffile
  24. if ffile = '' then ffile = '*.rc'
  25. else call findfile
  26. filec = ''
  27. item.dlgcnt = 0
  28. item.wincnt = 0
  29. item.filework = 0
  30. item.dcnt = 0
  31. item.wcnt = 0
  32. item.qcnt = 0
  33. item.inc = ''
  34. flist.1 = 'Start Win/Dlg'
  35. flist.2 = 'End Win/Dlg'
  36. flist.3 = 'End with Warning'
  37. flist.4 = 'Find A File Dialog'
  38. flist.5 = 'Add Help Logic'
  39. flist.0 = 5
  40.  
  41. slist.0 = 6
  42. slist.1  = 'Find A RC File'
  43. slist.2 =  'Parse The File'
  44. slist.3  = 'Add Controls'
  45. slist.4  = 'Save Parsed RC File'
  46. slist.5  = 'Load a Parsed RC file'
  47. slist.6  = 'Build a C File'
  48. slist.vstring = slist.1
  49.  do forever
  50.   if ffile \=  ''  then msgfile = ffile 
  51.   else msgfile = 'First, find a RC file'
  52.   call VDialogPos 50, 45
  53.   rc = VRadioBox( msgfile, slist, 3)
  54.   if rc =  CANCEL then leave
  55.   if slist.vstring = slist.1 then call findfile
  56.   if slist.vstring = slist.2  then call parsefile file 
  57.   if slist.vstring = slist.3 then call addcontrols
  58.   if slist.vstring = slist.4 then call savecontrols
  59.   if slist.vstring = slist.5 then call loadcontrols
  60.   if slist.vstring = slist.6 then do
  61.     if cfile() = CANCEL then iterate
  62.     call buildc
  63.   end
  64.   if file \= '' then do
  65.        lp = lastpos('\',file)+1
  66.        rfile = substr(file,lp,length(file))
  67.   end    
  68. end
  69. call Cleanup
  70. return
  71.  
  72. addcontrols: procedure expose file win. dlg. item. flist.
  73. if item.wincnt = 0 & item.dlgcnt = 0 then return
  74. do forever
  75.    j = 0
  76.    do i = 1 to item.wincnt
  77.      j = j + 1
  78.      list.j = win.nm.i
  79.    end
  80.    do i = 1 to item.dlgcnt
  81.       j = j + 1
  82.       list.j = dlg.nm.i
  83.    end
  84.    list.vstring = list.1
  85.    list.0 = j
  86.    call VDialogPos 25, 90
  87.    rc = VListBox('Pick A Win/Dlg', list, 25,8,3)
  88.    if rc =  CANCEL then leave
  89.    do i = 1  to j
  90.       if list.i = list.vstring then savef = i
  91.    end
  92.    do forever
  93.    if savef <= item.wincnt then do
  94.       j = 0
  95.       do k = win.first.savef to win.last.savef
  96.          j = j + 1
  97.          list.j = item.nm.k
  98.          pos.j = k
  99.       end
  100.    end
  101.    else do
  102.      j = 0
  103.      l = savef - item.wincnt
  104.      do k = dlg.first.l to dlg.last.l
  105.          j = j + 1
  106.          list.j = item.nm.k
  107.          pos.j = k
  108.      end
  109.    end
  110.     list.0 = j
  111.     list.vstring = list.1
  112.     call VDialogPos 50, 70
  113.     rc = VListBox('Pick A Control', list, 28,12,3)
  114.     if rc = CANCEL then leave
  115.     do l = 1 to j
  116.       if list.vstring = list.l then do
  117.          m = pos.l
  118.          leave
  119.       end
  120.      end     
  121.      call VDialogPos 75, 50
  122.      rc = VRadioBox('Pick A Function', flist, 3)
  123.      if rc =  CANCEL then iterate
  124.      if flist.vstring \= flist.1 then do
  125.        item.fn.m = flist.vstring
  126.        if flist.vstring = flist.4 then item.filework = 1
  127.        iterate
  128.      end
  129.      j = 0
  130.      l = 0
  131.      do i = 1 to item.wincnt
  132.         l = l + 1
  133.         if l = savef then iterate
  134.         j = j + 1
  135.         list.j = win.nm.i
  136.      end
  137.      do i = 1 to item.dlgcnt
  138.        l = l + 1
  139.        if l = savef then iterate
  140.        j = j + 1
  141.        list.j = dlg.nm.i
  142.      end
  143.      list.vstring = list.1
  144.      list.0 = j
  145.      call VDialogPos 100, 25
  146.      rc = VListBox('Pick A Starting Win/Dlg', list, 25,8,3)
  147.      if rc =  CANCEL then leave
  148.      item.fn.m = list.vstring
  149.    end
  150. end
  151. j = item.dlgcnt
  152. j = dlg.last.j
  153. do i = 1 to j
  154.    if item.fn.i \= '' then say i item.nm.i item.fn.i
  155. end
  156. return 
  157.  
  158. findfile: procedure expose file ffile
  159. call VDialogPos 15, 45
  160. button = VFileBox('Pick a file...', ffile, ifile)
  161. if button = OK then file = ifile.vstring
  162. lp = lastpos('\',file)
  163. if lp = 0 then ffile = '\*.rc'
  164. else ffile=substr(file,1,lp)'*.rc'
  165. return
  166.  
  167. cfile: procedure expose filec ffile
  168. call VDialogPos 15, 45
  169. lp = lastpos('\',ffile)
  170. if lp = 0 then cffile = '\*.c'
  171. else cffile=substr(ffile,1,lp)'*.c'
  172. button = VFileBox('Load to a .c file...', cffile, ifile)
  173. if button = OK then filec = ifile.vstring
  174. return button
  175.  
  176. parsefile: procedure expose file win. dlg. item.
  177. item.dcnt = 0
  178. item.wcnt = 0
  179. item.qcnt = 0
  180. item.filework = 0
  181. item.inc = ''
  182. item.pointer = 0
  183. item.accel    = 0
  184. item.icon      = 0
  185. call buildqueue file
  186. dotype = 'win'
  187. inln = ''
  188. wcnt = 0
  189. dcnt = 0
  190. icnt = 0
  191. depth = 0
  192. do while queued() > 0
  193.   parse pull inln
  194.   if inln = '{' then do 
  195.    depth = depth + 1
  196.     iterate
  197.     end
  198.    if inln = 'BEGIN' then do 
  199.    depth = depth + 1
  200.     iterate
  201.     end
  202.   if inln = '}' then do 
  203.    depth = depth - 1
  204.     iterate
  205.     end
  206.   if inln = 'END' then do 
  207.    depth = depth - 1
  208.     iterate
  209.     end
  210.   parse var inln type value','idn','therest
  211.    parse var idn idn1 therest1
  212.   if idn1 = '-1' then iterate /* no assignment */
  213.   if type = '#include' then do
  214.      item.inc = value
  215.      iterate
  216.      end
  217.   if pos(',',type) > 0 then iterate /* continutation line */
  218.   if pos('_',type) > 0 then iterate           /*   probably a pm option */
  219.   if type = 'NOT' then iterate /* pm word */
  220.   if pos('|',type) > 0 then iterate /* continutation line */
  221.   if type = GROUPBOX then iterate /* let's not do this type either */
  222.   if type = POINTER then do
  223.          item.pointer = 1
  224.          iterate
  225.       end
  226.   if type = LISTBOX then idn = value
  227.   if datatype(idn) = NUM then iterate /* no name from .h file */
  228.   if pos('""',idn) > 0 then iterate /* empty value */
  229.   if type = MENU then do
  230.      if wcnt > 0 then   win.last.wcnt = icnt
  231.      wcnt = wcnt + 1
  232.      win.first.wcnt = icnt  + 1
  233.      parse var value name therest2
  234.      win.nm.wcnt = name
  235.      say Window function is name
  236.      dotype = 'win'
  237.   end
  238.   else  if type = DIALOG then iterate
  239.   else  if type = DLGTEMPLATE then do
  240.      if dotype = 'win'  & wcnt > 0 then win.last.wcnt = icnt
  241.      if dcnt > 0 then dlg.last.dcnt = icnt
  242.      dcnt = dcnt + 1
  243.      dlg.first.dcnt = icnt + 1
  244.      parse var value name therest
  245.      dlg.nm.dcnt = name
  246.      say Dialog function is name
  247.      dotype = 'dlg'
  248.    end
  249.    else  do
  250.      icnt = icnt + 1
  251.      item.typ.icnt = strip(type,b)
  252.      item.nm.icnt =  strip(idn,b)
  253.      parse var therest x ',' y ',' xlen ',' ylen ',' therest4
  254.      item.sz.icnt = ylen
  255.      item.fn.icnt = ''
  256.     end
  257. end
  258. if dotype = 'win' then win.last.wcnt = icnt
  259. else dlg.last.dcnt = icnt
  260. if  depth \= 0 then say "Depth error "
  261. item.wincnt = wcnt
  262. item.dlgcnt = dcnt
  263. item.itemcnt = icnt
  264. say windows found is item.wincnt
  265. say dialogs found is item.dlgcnt
  266. say items found is item.itemcnt
  267. return 
  268.  
  269. buildc: procedure expose item. win. dlg. flist. filec
  270. queue '/* 'filec' produced by vrexx pgm rc-do-c */'
  271. queue '/* American Coders Ltd */'
  272. queue '/* PO Box 97462 */'
  273. queue '/* Raleigh, NC  27462 */'
  274. queue '/* (919) 846 - 2014 */'
  275. queue '#define INCL_WINBUTTONS'
  276. queue '#define INCL_WINSYS'
  277. queue '#define INCL_WINFRAMEMGR'
  278. queue '#define INCL_WINMENUS'
  279. queue '#define INCL_WINENTRYFIELDS'
  280. queue '#define INCL_WINMLE'
  281. queue '#define INCL_WINDIALOGS'
  282. if item.filework = 1 then do
  283.   queue '#define INCL_WINSTDFILE  /* Window Standard File Functions       */'
  284. end
  285. queue '#define INCL_GPI'
  286. queue '#define INCL_DOS'
  287. queue '#include <os2.h>'
  288. queue '#include <stdlib.h>'
  289. if item.inc \= '' then queue '#include 'item.inc
  290. do i = 1 to item.wincnt
  291.      queue 'MRESULT EXPENTRY winproc'i'(HWND, ULONG, MPARAM, MPARAM);'
  292. end
  293. foundone = 0
  294. do i = 1 to item.dlgcnt
  295.  do j = dlg.first.i to dlg.last.i
  296.  if pos('ENTRYFIELD',item.typ.j) = 0 then iterate
  297.   if foundone = 0 then
  298.       queue ' /* start char array defines for ENTRY fields */'
  299.       queue 'char sz_' || item.nm.j || '[' || item.sz.j || '];'
  300.       queue 'ULONG ul_length_' || item.nm.j || ' = 0;'
  301.   foundone = 1
  302.  end
  303. end
  304. foundone = 0
  305. do i = 1 to item.dlgcnt
  306.  do j = dlg.first.i to dlg.last.i
  307.  if pos('MLE',item.typ.j) = 0 then iterate
  308.   if foundone = 0 then    queue ' /* start *char  defines for MLE fields */'
  309.   queue 'char *sz_' || item.nm.j || ';'
  310.   queue 'ULONG ul_length_' || item.nm.j || ' = 0;'
  311.   foundone = 1
  312.  end
  313. end
  314. foundone = 0
  315. do i = 1 to item.dlgcnt
  316.  do j = dlg.first.i to dlg.last.i
  317.   if pos('CHECKBOX',item.typ.j) = 0 then iterate
  318.   if foundone = 0 then do
  319.       queue ' /* start enum list of check box */'
  320.       queue 'enum   en_check_box {    en_cb_' || item.nm.j
  321.        foundone = 1
  322.   end
  323.   else  do
  324.           queue '                         ,    en_cb_' || item.nm.j
  325.            foundone = foundone + 1
  326.         end
  327.   end
  328. end
  329.  
  330. if foundone >0 then do 
  331.     queue '   }; /* end enum list of check box */'
  332.     queue ' /* boolean table of all  checkbox each is set to false */'
  333.     queue 'BOOL check_box['foundone'];'
  334. end
  335. if item.dlgcnt > 0  then queue 'ULONG  radio_button['item.dlgcnt'];  /*boolean table of dialog radio buttons where 1 dialog = 1 radion button */'
  336. do i = 1 to item.dlgcnt
  337.    queue 'MRESULT EXPENTRY dlgproc'i'(HWND, ULONG, MPARAM, MPARAM);'
  338. end
  339. do i = 1 to item.dlgcnt
  340.     if i = 1  then   queue 'enum en_radio_button { en_rb_' || dlg.nm.i
  341.     else queue '                                          ,  en_rb_' || dlg.nm.i
  342. end
  343. if item.dlgcnt > 0 then queue '              }; /* end enum list of radio buttons, one button for each dialog */'
  344. queue ' '
  345. if item.filework = 1 then do
  346. queue '   FILEDLG pfdFiledlg;      /* File dialog info structure           */'
  347. queue '   char pszFileTitle[10] = "Open File"; /* Title of File dialog              */'
  348. queue '   char pszFullFile[CCHMAXPATH] = "*.*";/* File filter string       */'
  349. queue ' '
  350. end
  351. queue 'HAB hab;'
  352. queue 'HWND  hwndmain, hwndCl;'
  353. queue 'main(int argc, char *argv)'
  354. queue '{'
  355. queue 'QMSG qmsg;'
  356. queue ' HMQ hmq;'
  357. queue ' HPS hps;'
  358. queue ' ULONG fcfData = FCF_TITLEBAR | FCF_SYSMENU | FCF_MENU |'
  359. if item.pointer = 1 then queue '          FCF_ICON |'
  360. if item.accel    = 1 then queue '          FCF_ACCELTABLE |'
  361. queue '           FCF_SIZEBORDER | FCF_MINMAX  | FCF_SYSMODAL |'
  362. queue '           FCF_SHELLPOSITION  | FCF_TASKLIST;'
  363. queue ' '
  364. if item.filework = 1 then do
  365. queue 'memset(&pfdFiledlg, 0, sizeof(FILEDLG));'
  366. queue ' pfdFiledlg.cbSize = sizeof(FILEDLG); '
  367. queue ' pfdFiledlg.fl = FDS_HELPBUTTON | FDS_CENTER | FDS_OPEN_DIALOG;'
  368. queue ' pfdFiledlg.pszTitle = pszFileTitle;      /* Dialog title string      */'
  369. queue ' strcpy(pfdFiledlg.szFullFile, pszFullFile); /* Initial path,    file name or file filter       */'
  370. queue ' '
  371. end
  372. queue ' hab = WinInitialize(0ul);'
  373. queue ' hmq = WinCreateMsgQueue(hab,0ul);'
  374. queue ' WinRegisterClass(hab ,"'win.nm.1'",winproc1,CS_SIZEREDRAW ,0);'
  375. queue ' hwndmain = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE,'
  376. queue '   &fcfData,"'win.nm.1'","'win.nm.1'",'
  377. queue '   0l,(HMODULE)NULL,'win.nm.1',&hwndCl);'
  378. queue ' while ( WinGetMsg(hab,&qmsg, 0ul,0ul,0ul))'
  379. queue '    WinDispatchMsg( hab, &qmsg );'
  380. queue ' WinDestroyWindow(hwndCl);'
  381. queue ' WinDestroyMsgQueue( hmq );'
  382. queue ' WinTerminate( hab );'
  383. queue '}'
  384. queue ''
  385. do i = 1 to item.wincnt
  386. queue 'MRESULT EXPENTRY winproc'i'(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)'
  387. queue ' {'
  388. queue '   ULONG rc;'
  389. queue '   HPS hps;'
  390. queue '   RECTL rectl;'
  391. queue '   switch(msg)'
  392. queue '     {'
  393. queue '    case WM_COMMAND:'
  394. queue '       switch (SHORT1FROMMP(mp1))'
  395. queue '           { /* menu pulldowns and choices*/'
  396. do j = win.first.i to win.last.i
  397.    if item.typ.j = DLGINCLUDE then iterate
  398.    if item.typ.j \= pointer & item.type.j \= dlginclude then do
  399.      queue '       case ' strip(item.nm.j)': /* 'item.typ.j' */'
  400.    if item.fn.j = flist.2 then,
  401.      queue '        WinPostMsg(hwnd,WM_QUIT,0l,0l);'
  402.    else  if item.fn.j = flist.3 then do
  403.      queue '        if (MBID_YES  =='
  404.      queue '            WinMessageBox('
  405.      queue '                HWND_DESKTOP, hwnd,'
  406.      queue '                   "Window Will Close\nDo You Want To?",'
  407.      queue '                    "Close With Warning",0,'
  408.      queue '                    MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION|MB_MOVEABLE))'
  409.      queue '                            WinPostMsg(hwnd,WM_QUIT,0l,0l);'
  410.      end
  411.    else  if item.fn.j = flist.4 then,
  412.      queue '         WinFileDlg(HWND_DESKTOP, hwndmain, &pfdFiledlg);'
  413.    else  if item.fn.j = flist.5 then,
  414.       queue '      /* no help yet */'
  415.    else if item.fn.j \= '' then do
  416.         do l = 1 to item.wincnt
  417.            if item.fn.j = win.nm.l  then  do
  418.              queue '         WinRegisterClass(hab ,"'win.nm.1 '" ,(PFNWP)winproc1 ,CS_SIZEREDRAW ,0ul);'
  419.              queue '          hwnd1 = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE,'
  420.              queue '           &fcfData,"'win.nm.1 '","'win.nm.1 ' ",'
  421.              queue '             0ul,0ul,'win.nm.1 ',(PHWND)&hwndcl);'
  422.              iterate                                                                
  423.  
  424.            end
  425.          end
  426.          do l = 1 to item.dlgcnt
  427.            if item.fn.j = dlg.nm.l  then  do
  428.              queue '              WinDlgBox(HWND_DESKTOP',
  429.                 ',hwndmain,dlgproc'l',(HMODULE)0,'dlg.nm.l',NULL);'
  430.               iterate
  431.              end
  432.           end
  433.      end
  434.      queue '         break;'
  435.    end
  436. end
  437. queue '      }'
  438. queue '    break;'
  439. queue '   case WM_CONTROL:'
  440. queue '    break;'
  441. queue '   case WM_CREATE:'
  442. queue '    break;'
  443. queue '   case WM_PAINT:'
  444. queue '    hps = WinBeginPaint(hwnd,0ul,0ul);'
  445. queue '    WinQueryWindowRect(hwnd,&rectl);'
  446. queue '    WinFillRect(hps,&rectl,CLR_BLUE);'
  447. queue '    WinEndPaint(hps);'
  448. queue '    return(FALSE);'
  449. queue '    break;'
  450. queue '    }'
  451. queue ' return(WinDefWindowProc(hwnd,msg,mp1,mp2));'
  452. queue '}'
  453. queue ''
  454. end
  455. do i = 1 to item.dlgcnt
  456. queue 'MRESULT EXPENTRY dlgproc'i'(HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)'
  457. queue '{'
  458. queue ' switch(msg)'
  459. queue ' {'
  460. queue '   case WM_INITDLG:'
  461. do j = dlg.first.i to dlg.last.i
  462.   if pos('ENTRYFIELD',item.typ.j) > 0 then do
  463.          queue '           WinSendDlgItemMsg(hwnd,'item.nm.j ','
  464.          queue '                 EM_SETTEXTLIMIT, '
  465.          queue '                     MPFROM2SHORT(' || item.sz.j || ',0),NULL);'
  466.          queue '           WinSetDlgItemText(hwnd,' || item.nm.j || ', sz_' || item.nm.j || ');'
  467.      end  /* Do */
  468. end
  469. do j = dlg.first.i to dlg.last.i
  470.  if pos('MLE',item.typ.j) = 0 then iterate
  471.    queue '             if (ul_length_' || item.nm.j || ')'
  472.    queue '                  WinSetDlgItemText(hwnd,' || item.nm.j || ', sz_' || item.nm.j || ');'
  473. end
  474. foundone = 0
  475.  do j = dlg.first.i to dlg.last.i
  476.   if pos('CHECKBOX',item.typ.j) > 0 then do
  477.          queue '           WinSendDlgItemMsg(hwnd,'item.nm.j ','
  478.           queue '                 BM_SETCHECK, '
  479.           queue '                     MPFROM2SHORT(check_box[en_cb_' || item.nm.j || '],0),NULL);'
  480.      end  /* Do */
  481. end
  482. queue '        if  (radio_button[' || i-1 || '])  /* this radio button is on */'
  483. queue '                WinSendDlgItemMsg(hwnd,radio_button[' || i-1 || '],'
  484. queue '                       BM_SETCHECK, '
  485. queue '                          MPFROM2SHORT(TRUE,0),NULL);'
  486. queue '    break;'
  487. queue '   case WM_CLOSE:'
  488. queue '    break;'
  489. queue '   case WM_CONTROL:'
  490. queue '     switch ( SHORT1FROMMP(mp1) )'
  491. queue '        {'
  492. do j = dlg.first.i to dlg.last.i
  493.    if item.typ.j = CONTROL then do
  494.       queue '          case' strip(item.nm.j,b)': /* 'item.typ.j '*/'
  495.       if item.fn.j = flist.2 then     queue '                WinDismissDlg(hwnd,0);'
  496.       else  if item.fn.j = flist.3 then do
  497.         queue '                if (MBID_YES  !='
  498.         queue '                    WinMessageBox('
  499.         queue '                        HWND_DESKTOP, hwnd,'
  500.         queue '                           "Dialog Will Close\nDo You Want To?",'
  501.         queue '                            "Close With Warning",0,'
  502.         queue '                            MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION|MB_MOVEABLE))'
  503.         queue '                                return(FALSE);'
  504.         queue '                         WinDismissDlg(hwnd,0);'
  505.        end
  506.      else   if item.fn.j = flist.4 then     queue '                WinFileDlg(HWND_DESKTOP, hwndmain, &pfdFiledlg);'
  507.      else  if item.fn.j = flist.5 then       queue '      /* no help yet */'
  508.      else if item.fn.j \= '' then do
  509.        do l = 1 to item.wincnt
  510.              if item.fn.j = win.nm.l  then  do
  511.                queue '               WinRegisterClass(hab ,"'win.nm.1 '" ,(PFNWP)winproc1 ,CS_SIZEREDRAW ,0ul);'
  512.                queue '                hwnd1 = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE,'
  513.                queue '                &fcfData,"'win.nm.1 '","'win.nm.1 ' ",'
  514.                queue '                  0ul,0ul,'win.nm.1 ',(PHWND)&hwndcl);'
  515.                iterate
  516.             end
  517.          end
  518.        do l = 1 to item.dlgcnt
  519.            if item.fn.j = dlg.nm.l  then  do
  520.              queue '                 WinDlgBox(HWND_DESKTOP,hwnd,dlgproc'l',(HMODULE)0,'dlg.nm.l',NULL);'
  521.               iterate
  522.            end
  523.        end
  524.      end
  525.      queue '              break;'
  526.      end /* typ.h = CONTROL */
  527. else do
  528.      if  'CHECKBOX' = item.typ.j  then do
  529.           queue '          case' strip(item.nm.j,b)': /* 'item.typ.j '*/'
  530.           queue '             if (check_box[en_cb_' || item.nm.j || '])'
  531.           queue '                  check_box[en_cb_' || item.nm.j || '] = FALSE;'
  532.           queue '             else    check_box[en_cb_' || item.nm.j || '] = TRUE;'
  533.           queue '             WinSendDlgItemMsg(hwnd,'item.nm.j ','
  534.           queue '                   BM_SETCHECK, '
  535.           queue '                       MPFROM2SHORT(check_box[en_cb_' || item.nm.j || '],0),NULL);'
  536.           queue '              break;'
  537.        end
  538.      if 'RADIOBUTTON' = item.typ.j  then do
  539.           queue '          case' strip(item.nm.j,b)': /* 'item.typ.j '*/'
  540.           queue '             WinSendDlgItemMsg(hwnd,radio_button[' || i-1 || '],'
  541.           queue '                   BM_SETCHECK, '
  542.           queue '                       MPFROM2SHORT(FALSE,0),NULL);'
  543.           queue '                   radio_button[' || i-1 || '] = ' item.nm.j || ';'
  544.           queue '              WinSendDlgItemMsg(hwnd,radio_button[' || i-1 || '],'
  545.           queue '                   BM_SETCHECK, '
  546.           queue '                       MPFROM2SHORT(TRUE,0),NULL);'
  547.           queue '              break;'
  548.       end
  549.      if  'ENTRYFIELD' = item.typ.j then do
  550.           queue '          case' strip(item.nm.j,b)': /* 'item.typ.j '*/'
  551.           queue '               if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)'
  552.           queue '                   WinQueryDlgItemText(hwnd,' || item.nm.j || ',' || item.sz.j || ',sz_' || item.nm.j || ');'
  553.           queue '              break;'
  554.      end 
  555.     if 'MLE' = item.typ.j  then do
  556.           queue '          case' strip(item.nm.j,b)': /* 'item.typ.j '*/'
  557.           queue '               if (SHORT2FROMMP(mp1) == MLN_KILLFOCUS) {'
  558.           queue '                  ul_length_' || item.nm.j || ' ='
  559.           queue '                       WinQueryDlgItemTextLength(hwnd,' || item.nm.j || ');'
  560.           queue '                  if (ul_length_' || item.nm.j || ') {'
  561.           queue '                       if (sz_' || item.nm.j || ')  '
  562.           queue '                         free (sz_' || item.nm.j || ');'
  563.           queue '                     sz_' || item.nm.j || '= malloc(++ul_length_' || item.nm.j || ');'
  564.           queue '                     WinQueryDlgItemText(hwnd,' || item.nm.j || ',ul_length_' || item.nm.j || ' ,sz_' || item.nm.j || ');'
  565.           queue '                      }'
  566.           queue '                   else {    /* if there was something there; it is gone now */'
  567.           queue '                       if (sz_' || item.nm.j || ')  '
  568.           queue '                         free (sz_' || item.nm.j || ');'
  569.           queue '                        ul_length_' || item.nm.j || ' = 0;'
  570.           queue '                      }'
  571.           queue '                   }'
  572.           queue '              break;'
  573.      end
  574.   end /* else do */
  575. end /* do j = */
  576. queue '          }'
  577. queue '    break;'
  578. queue '   case WM_COMMAND:'
  579. queue '     switch ( SHORT1FROMMP(mp1) )'
  580. queue '        {'
  581. do j = dlg.first.i to dlg.last.i
  582.    if item.typ.j \= POINTER & item.typ.j \= DLGINCLUDE & item.typ.j \= CONTROL then do
  583.      queue '          case' strip(item.nm.j,b)': /* 'item.typ.j '*/'
  584.      if item.fn.j = flist.2 then,
  585.      queue '                WinDismissDlg(hwnd,0);'
  586.      else  if item.fn.j = flist.3 then do
  587.      queue '                if (MBID_YES  !='
  588.      queue '                    WinMessageBox('
  589.      queue '                        HWND_DESKTOP, hwnd,'
  590.      queue '                           "Dialog Will Close\nDo You Want To?",'
  591.      queue '                            "Close With Warning",0,'
  592.      queue '                             MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION|MB_MOVEABLE))'
  593.      queue '                               return(FALSE);'
  594.      queue '                 WinDismissDlg(hwnd,0);'
  595.      end
  596.      else if item.fn.j = flist.4 then,
  597.      queue '                WinFileDlg(HWND_DESKTOP, hwndmain, &pfdFiledlg);'
  598.      else  if item.fn.j = flist.5 then,
  599.      queue '      /* no help yet */'
  600.      else if item.fn.j \= '' then do
  601.        do l = 1 to item.wincnt
  602.         if item.fn.j = win.nm.l  then  do
  603.          queue '               WinRegisterClass(hab ,"'win.nm.1 '" ,(PFNWP)winproc1 ,CS_SIZEREDRAW ,0ul);'
  604.          queue '                hwnd1 = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE,'
  605.          queue '                &fcfData,"'win.nm.1 '","'win.nm.1 ' ",'
  606.          queue '                  0ul,0ul,'win.nm.1 ',(PHWND)&hwndcl);'
  607.          iterate
  608.          end
  609.        end
  610.         do l = 1 to item.dlgcnt
  611.         if item.fn.j = dlg.nm.l  then  do
  612.           queue '                 WinDlgBox(HWND_DESKTOP',
  613.              ',hwnd,dlgproc'l',(HMODULE)0,'dlg.nm.l',NULL);'
  614.            iterate
  615.            end
  616.        end
  617.       end
  618.       else do
  619.             if  'AUTOCHECKBOX' = item.typ.j  then,
  620.                   queue '             check_box[en_cb_' || item.nm.j || '] = WinQueryButtonCheckstate(hwnd,'item.nm.j');'
  621.             if 'AUTORADIOBUTTON' = item.typ.j  then do
  622.                  queue '              if (WinQueryButtonCheckstate(hwnd,'item.nm.j') )'
  623.                  queue '                   radio_button[' || i-1 || '] = ' item.nm.j || ';'
  624.                 end
  625.          end
  626.        queue '              break;'
  627.     end
  628.    end
  629. queue '      }'
  630. queue '   default:'
  631. queue '      return(WinDefDlgProc(hwnd,msg,mp1,mp2));'
  632. queue '      break;'
  633. queue '  }'
  634. queue '  return (FALSE);'
  635. queue '}'
  636. queue ''
  637. end
  638. 'del ' filec
  639. say stream(filec, 'c',' OPEN')
  640. do queued()
  641. parse pull cline
  642. call lineout filec, cline
  643. end /* do */
  644. say stream(filec,'c','CLOSE')
  645. return
  646.  
  647. savecontrols: procedure expose item. win. dlg. ffile cfile
  648. call VDialogPos 15, 45
  649. lp = lastpos('\',ffile)
  650. if lp = 0 then cffile = '\*.rcc'
  651. else cffile=substr(ffile,1,lp)'*.rcc'
  652. button = VFileBox('Save to a .rcc file...', cffile, ifile)
  653. if button = CANCEL then return
  654. rfile = ifile.vstring
  655. ' del ' rfile
  656. say stream(rfile, 'c',' OPEN write')
  657. outstring =  ffile','filec','item.wincnt','item.dlgcnt','item.filework
  658. call lineout rfile, outstring, 1
  659. do i = 1 to item.wincnt
  660.     outstring = win.nm.i','win.first.i','win.last.i
  661.     call lineout rfile, outstring
  662.     do j = win.first.i to win.last.i
  663.         outstring = item.nm.j','item.typ.j','item.sz.j','item.fn.j
  664.         call lineout rfile, outstring
  665.      end
  666. end
  667. do i = 1 to item.dlgcnt
  668.       outstring =  dlg.nm.i ','dlg.first.i','dlg.last.i
  669.       call lineout rfile, outstring
  670.       do j = dlg.first.i to dlg.last.i
  671.         outstring = item.nm.j','item.typ.j','item.sz.j','item.fn.j
  672.         call lineout rfile,  outstring 
  673.       end
  674. end
  675. call lineout rfile, item.inc
  676. say stream(rfile,'c','CLOSE')
  677. return
  678.  
  679. loadcontrols: procedure expose item. win. dlg. ffile filec
  680. call VDialogPos 15, 45
  681. lp = lastpos('\',ffile)
  682. if lp = 0 then cffile = '\*.rcc'
  683. else cffile=substr(file,1,lp)'*.rcc'
  684. button = VFileBox('Load from a .rcc file...', cffile, ifile)
  685. if button = CANCEL then return
  686. rfile = ifile.vstring
  687. say stream(rfile, 'c','OPEN')
  688. parse value linein(rfile) with ffile','filec','item.wincnt','item.dlgcnt','item.filework
  689. do i = 1 to item.wincnt
  690.     parse value linein(rfile) with win.nm.i','win.first.i','win.last.i
  691.     do j = win.first.i to win.last.i
  692.        parse value linein(rfile) with item.nm.j','item.sz.j','item.typ.j','item.fn.j
  693.     end
  694. end
  695. do i = 1 to item.dlgcnt
  696.     parse value linein(rfile) with dlg.nm.i','dlg.first.i','dlg.last.i
  697.     do j = dlg.first.i to dlg.last.i
  698.        parse value linein(rfile) with item.nm.j','item.sz.j','item.typ.j','item.fn.j
  699.     end
  700. end
  701. parse value linein(rfile) with item.inc ','
  702. say stream(rfile,'c','CLOSE')
  703. return
  704.  
  705.  
  706. buildqueue: procedure 
  707. arg file
  708. inln = ''
  709. linec = 0
  710. say file
  711. tabchar = D2C(9);
  712. linein(file,1,0)
  713. do while lines(file) > 0
  714.    linec = linec + 1
  715.    inl = linein(file)
  716.    l = length(inl)
  717.    if l < 2 then iterate /* too short anyways */
  718.    do forever
  719.     tab = pos(tabchar,inl);
  720.     if  tab = 0 then leave
  721.     if tab = 1 then inl = ' ' || substr(inl,2,l)
  722.     else if tabl = l then inl = substr(inl,1,l-1) || ' '
  723.     else inl = substr(inl,1,tab-1) || " " || substr(inl,tab+1,l)
  724.    end
  725.    inln = inln || strip(inl,b)
  726.    l = length(inln)
  727.    if l = 0 then iterate
  728.    if substr(inln,1,2) = '/*' then do
  729.      inln = ''
  730.      iterate
  731.    end
  732.    if substr(inln,l,1) \=','| substr(inln,l,1) = '|'  then do
  733.      parse var inln first second therest
  734.      if first = 'rcinclude' then do
  735.        lp = lastpos('\',file)
  736.        nfile = substr(file,1,lp) || second
  737.        call   buildqueue nfile
  738.        inln = ''
  739.       end  /* Do */
  740.      else do
  741.         queue inln
  742.         inln = ''
  743.       end
  744.    end  /* Do */
  745. end /* do */
  746. return
  747.  
  748. CLEANUP:
  749.    call VExit
  750.  
  751. exit
  752.