home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / RCDO_C02.ZIP / RC-DO-C.CMD < prev    next >
OS/2 REXX Batch file  |  1992-12-01  |  22KB  |  662 lines

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