home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / db22re.zip / DIRSCAN.CMD < prev    next >
OS/2 REXX Batch file  |  1993-03-09  |  4KB  |  122 lines

  1. /*
  2.  ┌──────────────────────────────────────────────────────────────────┐
  3.  │  Name       : dirscan.cmd                                        │
  4.  │  Purpose    : database directory scan                            │
  5.  │  Platform   : DB2/2                                              │
  6.  │  Author     : Jeff Fisher                                        │
  7.  │               IBM Toronto Development Lab                        │
  8.  │  Disclaimer : This "sample" code is for demonstrations only, no  │
  9.  │               warrenties are made or implied as to correct       │
  10.  │               function. You should carefully test this code in   │
  11.  │               your own environment before using it.              │
  12.  │                                                                  │
  13.  └──────────────────────────────────────────────────────────────────┘
  14. */
  15.  
  16.  
  17. address cmd '@echo off'
  18. call SetColor
  19. address cmd 'CLS'
  20.  
  21. Menu:
  22.  
  23.     say
  24.     say
  25.     say c.gre '*****************************'
  26.     say c.yel '   Database Directory Scan'
  27.     say
  28.     say c.gre '  Enter:'c.nor' Drive 'c.gre'or'c.nor' X 'c.gre'to EXIT'
  29.     say
  30.     say c.gre '*****************************'
  31.  
  32.     say c.nor
  33.     pull drive
  34.  
  35.     if drive = 'X'     then signal EndProg
  36.     if drive = ' ' then
  37.         do
  38.             say
  39.             say c.red 'Invalid response: try again'
  40.             say
  41.             signal menu
  42.         end
  43.  
  44.     call DirScan
  45.  
  46.     signal menu
  47.  
  48. DirScan:
  49.     step = 'open database directory'
  50.     call SQLDBS 'OPEN DATABASE DIRECTORY ON' drive 'using :scanvar'
  51.     if SQLCA.SQLCODE \= 0 then signal ErrorSQL
  52.  
  53.     scan_flag = 'Y'
  54.  
  55.     address cmd 'CLS'
  56.     say
  57.  
  58.     do i=1 to scanvar.2
  59.         step = 'get database directory entry'
  60.         call SQLDBS 'GET DATABASE DIRECTORY ENTRY :scanvar.1 USING :entry'
  61.         if SQLCA.SQLCODE \= 0 then signal ErrorSQL
  62.  
  63.         say
  64.         say c.gre '-------------------------------------------'
  65.         say c.itcya 'Database:' entry.1 'Alias:' entry.2'Drive:' entry.3
  66.         say '  Internal name:' entry.4
  67.         say '  Node name    :' entry.5
  68.         say '  Dbtype       :' entry.6
  69.         say '  Comment      :' entry.7
  70.         say '  Codepage     :' entry.8
  71.         say '  Enttype      :' entry.9
  72.         say c.gre '-------------------------------------------'
  73.         say c.nor
  74.         pause
  75.     end
  76.  
  77.     step = 'close database directory'
  78.     call SQLDBS 'CLOSE DATABASE DIRECTORY :scanvar.1'
  79.     if SQLCA.SQLCODE \= 0 then signal ErrorSQL
  80.  
  81.     address cmd 'CLS'
  82.  
  83.     return
  84.  
  85. EndProg:
  86.     say c.nor
  87.  
  88.     if scan_flag = 'Y' then
  89.         do
  90.             call SQLDBS 'CLOSE DATABASE DIRECTORY :scanvar.1'
  91.         end
  92.  
  93.     address cmd 'CLS'
  94.     if RC \= 0 then signal ErrorSQL
  95.  
  96.     exit
  97.  
  98.  
  99. ErrorSQL:
  100.     say c.red
  101.     call beep 220,1000
  102.     say
  103.     say '        >>>  SQL has returned a fatal condition code'
  104.     say '             step          = ' step
  105.     say '             SQLCODE       = ' SQLCA.SQLCODE
  106.     say '             MSG           = ' SQLMSG
  107.     say
  108.     pause
  109.     signal Menu
  110.  
  111.  
  112. SetColor:
  113.     ansii.esc      = '1B'x
  114.     c.nor          = ansii.esc || '[0m'
  115.     c.hih          = ansii.esc || '[1m'
  116.     c.red          = c.nor || ansii.esc || '[31m'
  117.     c.gre          = c.nor || ansii.esc || '[32m'
  118.     c.yel          = c.hih || ansii.esc || '[33m'
  119.     c.itblu        = c.hih || ansii.esc || '[34m'
  120.     c.itcya        = c.hih || ansii.esc || '[36m'
  121.     return 0
  122.