home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / RCDOC4.ZIP / RC-DO-C.CMD < prev    next >
OS/2 REXX Batch file  |  1993-01-05  |  27KB  |  771 lines

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