home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / spm2.zip / spmapp03.cmd < prev    next >
OS/2 REXX Batch file  |  1993-10-20  |  4KB  |  188 lines

  1. /* */
  2.   if Pop() <> 0 then exit 9903
  3.  
  4.   Drive = filespec('Drive',OUTFILE)
  5.   Path  = filespec('Path', OUTFILE)
  6.   Name  = filespec('Name', OUTFILE)
  7.  
  8.   if Name = '' then Name = 'SPMCTRGP.H'
  9.  
  10.   mapfile = Drive||Path||Name
  11.  
  12.   say GetMsg(23,mapfile,INIFILE)
  13.  
  14.   say GetMsg(8,'03')
  15.  
  16.   x = Types()
  17.  
  18.   '@del' mapfile
  19.  
  20.   if stream(mapfile,'c','query exists') <> ''
  21.   then
  22.     do
  23.       say GetMsg(22,mapfile)
  24.       exit 20
  25.     end
  26.  
  27.   IF STREAM(MAPFILE,'C','OPEN WRITE') <> 'READY:'
  28.   then
  29.     do
  30.       say GetMsg(10,mapfile)
  31.       exit 10
  32.     end
  33.  
  34.   x = Retrieve('SPM','VERSION','Ver')
  35.  
  36.   cpgd = s2d(substr(Ver,1,2))
  37.  
  38.   str = translate(substr(Ver,27),' ',',')
  39.  
  40.   spmvrm = word(str,1)
  41.   os2vrm = word(str,2)
  42.  
  43.   x = PunchHeader()
  44.  
  45.   x = Retrieve('SPM','ELEMENTS','PgdList')
  46.   x = Retrieve('SPM','NAMES','PgNames')
  47.   x = Retrieve('SPM','DESC','PgDesc')
  48.  
  49.   do i = 1 to cpgd
  50.     Pgd = substr(PgdList,(i*8)-7,8)
  51.     Ord = s2d(substr(Pgd,1,2))
  52.     PName = szstr(PgNames,s2d(substr(Pgd,5,2))+2)
  53.  
  54.     if substr(Pgd,1,2) = substr(Pgd,3,2)
  55.     then
  56.       do
  57.         Grp = '_'||Ord
  58.  
  59.         x = Retrieve(Grp,'ELEMENTS','Sgd')
  60.         x = Retrieve(Grp,'NAMES','Names')
  61.         x = Retrieve(Grp,'TAGS','Tags')
  62.         x = Retrieve(Grp,'DESC','Descriptions')
  63.  
  64.         x = PunchGroup()
  65.       end
  66.     else
  67.       do
  68.         x = PunchAlias()
  69.       end
  70.   end
  71.  
  72.   x = PunchTrailer()
  73.  
  74.   x = stream(mapfile,'c','close')
  75.  
  76.   say ' '
  77.   say GetMsg(9,'03')
  78.  
  79.   return 0
  80.  
  81. /* * * * * * * * * */
  82.  
  83. PunchHeader:
  84.   x = lineout(mapfile,' /* generate date/time '||date()||' '||time()||' */')
  85.   x = lineout(mapfile,' ')
  86.   x = lineout(mapfile,'#ifndef SPM_COUNTERS_DEFINED ')
  87.   x = lineout(mapfile,'#define SPM_COUNTERS_DEFINED ')
  88.   x = lineout(mapfile,' ')
  89.  
  90.   x = SPMAPP05(mapfile)
  91.  
  92.   x = lineout(mapfile,' ')
  93.   x = lineout(mapfile,' /* spm level' spmvrm', os2 level' os2vrm '*/')
  94.  
  95.   return 0
  96.  
  97. /* * * * * * * * * */
  98.  
  99. PunchGroup:
  100.   PDesc = szstr(PgDesc,s2d(substr(Pgd,7,2))+2)
  101.   STag = szstr(Tags,2)
  102.   BName = PName
  103.  
  104.   x = PutDot() /* say '.. Ordinal 'Ord '"'PName'" tag 'STag */
  105.  
  106.   x = lineout(mapfile,' ')
  107.   x = lineout(mapfile,'#ifndef SPMOrdinal_'||STag)
  108.   x = lineout(mapfile,'#define SPMOrdinal_'||STag||' '||Ord)
  109.   x = lineout(mapfile,' typedef')
  110.   x = lineout(mapfile,'  struct _'||STag||' {   /* "'||PName||'" - "'||PDesc||'" */')
  111.  
  112.   ctEL = s2d(substr(Sgd,9,2))
  113.  
  114.   do j = 1 to ctEL
  115.     Sel = substr(Sgd,(j*8)+3,8)
  116.  
  117.     fsType = s2d(substr(Sel,2,1))
  118.     Type = TypeFld.fsType
  119.  
  120.     Name = szstr(Names,s2d(substr(Sel,3,2))+2)
  121.     Tag = szstr(Tags,s2d(substr(Sel,5,2))+2)
  122.     Desc = szstr(Descriptions,s2d(substr(Sel,7,2))+2)
  123.  
  124.     x = lineout(mapfile,'   '||Type||' '||Tag||';   /* "'||Name||'" - "'||Desc||'" */')
  125.   end
  126.  
  127.   x = lineout(mapfile,'#ifdef SPMCtrGpExtension_'||STag)
  128.   x = lineout(mapfile,'       SPMCtrGpExtension_'||STag)
  129.   x = lineout(mapfile,'#endif')
  130.   x = lineout(mapfile,'  } '||STag||';')
  131.   x = lineout(mapfile,'#endif')
  132.  
  133.   return 0
  134.  
  135. /* * * * * * * * * */
  136.  
  137. PunchAlias:
  138.   msg = 'Ordinal '||Ord||' "'||PName||'" is an alias for "'||BName||'"'
  139.   x = PutDot()  /* say '..' msg */
  140.   x = lineout(mapfile,'  /* '||msg||' */')
  141.   return 0
  142.  
  143. /* * * * * * * * * */
  144.  
  145. PunchTrailer:
  146.   x = lineout(mapfile,' ')
  147.   x = lineout(mapfile,'#endif /* end of SPM_COUNTERS_DEFINED */')
  148.   return 0
  149.  
  150. /* * * * * * * * * */
  151.  
  152. Types:
  153.   x = Retrieve('DCL','fieldtyp','Types')
  154.  
  155.   Tc = s2d(substr(Types,1,2))
  156.   Td = substr(Types,3,Tc*4)
  157.   Tn = substr(Types,3+length(Td))
  158.  
  159.   j = 4 * Tc
  160.   q = 0
  161.  
  162.   do i = 1 to j by 4
  163.     TypeFld.q = szstr(Tn,s2d(substr(Td,i,2))+2)
  164.     q = q + 1
  165.   end
  166.  
  167.   return 0
  168.  
  169. /* * * * * * * * * */
  170.  
  171. Retrieve:
  172.   parse arg _app,_key,_item
  173.  
  174.   _data = SysIni(INIFILE,_app,_key)
  175.  
  176.   if _data = 'ERROR:'
  177.   then
  178.     do
  179.       say GetMsg(14,_app,_key)
  180.       exit 14
  181.     end
  182.   else
  183.     do
  184.       interpret _item '= _data'
  185.       return 0
  186.     end
  187.  
  188.