home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / CLIPPER / SCRNUZ / RPTOSCRN.PRG < prev    next >
Text File  |  1991-12-13  |  8KB  |  293 lines

  1. *.............................................................................
  2. *
  3. *   Program Name: RPTOSCRN.PRG      Copyright: EDON Corporation
  4. *   Date Created: 11/27/90           Language: Clipper S'87
  5. *   Time Created: 12:09:27             Author: Ed Phillips
  6. *           Desc: Routines for "Report to Screen" capability
  7. *.............................................................................
  8.  
  9.  
  10. *----------------------------
  11. *         Author: Ed Phillips
  12. *   Date Created: 11/27/90
  13. *   Time Created: 07:22:59
  14. *----------------------------
  15. FUNCTION MakScrnDBF
  16.    PARAMETERS line_len
  17.    PRIVATE work[1], ret_val, workfile
  18.  
  19.    IF Type('line_len') != 'N'
  20.       line_len = 178
  21.    ENDIF                                         && IF Type('line_len') != 'N'
  22.  
  23.    work[1] = 'RPT_LINE  C'+Str(line_len,3,0)
  24.    workfile = Timetofile("dbf")
  25.  
  26.    CreateDBF(workfile, work)
  27.    ret_val = Subs(workfile,1,At('.',workfile)-1)
  28. RETURN (ret_val)
  29.  
  30.  
  31. *----------------------------
  32. *         Author: Ed Phillips
  33. *   Date Created: 11/27/90
  34. *   Time Created: 09:50:59
  35. *----------------------------
  36. FUNCTION RptToDBF
  37.    PARAMETERS filename
  38.    PRIVATE work
  39.  
  40.    work = filename+'.prn'
  41.    SELECT 0
  42.    USE (filename) EXCLUSIVE
  43.    APPEND FROM (work) SDF
  44.    GO TOP
  45.  
  46. RETURN(Reccount())
  47.  
  48.  
  49. *----------------------------
  50. *         Author: Ed Phillips
  51. *   Date Created: 11/27/90
  52. *   Time Created: 09:59:51
  53. *----------------------------
  54. FUNCTION CleanRPT
  55.    PARAMETERS filename
  56.  
  57.    IF File(filename+'.dbf')
  58.       ERASE &filename..dbf
  59.    ENDIF                                         && IF File(filename+'.dbf')
  60.  
  61.    IF File(filename+'.prn')
  62.       ERASE &filename..prn
  63.    ENDIF                                         && IF File(filename+'.prn')
  64.  
  65.    IF File(filename+'.ntx')
  66.       ERASE &filename..ntx
  67.    ENDIF
  68.  
  69. RETURN(.T.)
  70.  
  71.  
  72. *----------------------------
  73. *         Author: Ed Phillips
  74. *   Date Created: 11/27/90
  75. *   Time Created: 10:02:47
  76. *----------------------------
  77. FUNCTION Brpt
  78.    PARAMETERS t, l, b, r, line_len, filename, _color
  79.  
  80.    IF Type("line_len") != "N"
  81.       line_len = 178
  82.    ENDIF                                            && IF Type("line_len") != "N"
  83.  
  84.    IF Type("_color") = "U"
  85.       _color = c_pop
  86.    ENDIF                                            && IF Type("_color") = "U"
  87.  
  88.    nrows = b - t - 1
  89.    ncols = r - l - 1
  90.    top = t + 1
  91.    bot = b - 1
  92.    lt = l + 1
  93.    rt = r - 1
  94.    offset = 1
  95.    num_in_buf = 0
  96.    line_num = 0
  97.    more_to_read = .t.
  98.    next_char = 1
  99.    block_num = 1
  100.    last_line = Reccount()
  101.    last_scrn = .f.
  102.    vhelp = Chr(24)+Chr(25)+Chr(27)+Chr(26)+'<PgUp> <PgDn> <Home> <End> <Alt-G>, <Esc> when done'
  103.  
  104.    oldcolor = Setcolor(_color)
  105.    Scroll(t-1,l,b,r,0)
  106.    @ t,l TO b,r
  107.  
  108.    BEGIN SEQUENCE
  109.       GO TOP
  110.       line_num = Recno()
  111.       DispView()
  112.       DO WHILE .T.
  113.          @ t-1,l SAY "Line: "+Str(line_num,4,0)+Space(2)+If(last_line > 0, Str(last_line,4),'')+Space(4)+"Offset: "+Str(offset,3)
  114.          last_scrn = If(line_num+nrows > Reccount(), .t., .f.)
  115.          keystroke = Inkey(0)
  116.  
  117.          DO CASE
  118.             CASE keystroke = esc
  119.                BREAK
  120.             CASE keystroke = AltG
  121.                Setcolor(c_field)
  122.                @ 24,0 CLEAR
  123.                lnum = Recno()
  124.                @ 24,20 SAY 'GoTo Line Number:' GET lnum VALID ValRecNo(M->lnum)
  125.                READ
  126.                GO lnum
  127.                line_num = lnum
  128.                Setcolor(_color)
  129.                DispView()
  130.             CASE keystroke = end_key
  131.                EndKey()
  132.             CASE keystroke = home
  133.                HomeKey()
  134.             CASE keystroke = rtarrow                && pan right
  135.                offset = offset + 9
  136.                IF offset >= line_len - 9
  137.                   offset = offset - 9
  138.                   Alert()
  139.                ELSE
  140.                   DispView()
  141.                ENDIF                                && IF offset >= line_len
  142.             CASE keystroke = ltarrow                && pan left
  143.                offset = offset - 9
  144.                IF offset <= -8
  145.                   offset = 1
  146.                   Alert()
  147.                ELSE
  148.                   DispView()
  149.                ENDIF                                && IF offset < 1
  150.             CASE keystroke = dnarrow
  151.                DownArrow()
  152.             CASE keystroke = pgdn
  153.                PageDown()
  154.             CASE keystroke = uparrow
  155.                IF line_num > 1
  156.                   Scroll(top,lt,bot,rt,-1)
  157.                   SKIP -1
  158.                   line_num = Recno()
  159.                   @ top,lt SAY Subs(Rpt_line,offset,ncols)
  160.                ELSE
  161.                   Alert()
  162.                ENDIF                             && IF next_char <= num_in_buf .OR. more_to_read
  163.             CASE keystroke = pgup
  164.                PageUp()
  165.          ENDCASE                                    && DO CASE
  166.       ENDDO                                         && DO WHILE .T.
  167.    END                                              && BEGIN SEQUENCE
  168.    USE
  169. RETURN(.T.)
  170.  
  171. *----------------------------
  172. *         Author: Ed Phillips
  173. *   Date Created: 11/27/90
  174. *   Time Created: 10:52:28
  175. *----------------------------
  176. FUNCTION DispView
  177.    PRIVATE i, oldrec, output
  178.  
  179.    output = 'SCREEN'
  180.    oldrec = Recno()
  181.    Scroll(top,lt,bot,rt,0)                       && clear window
  182.    @ top,lt SAY Subs(rpt_line,offset,ncols)
  183.    SKIP
  184.    FOR i = 2 TO nrows
  185.       @ Row()+1,lt SAY Subs(rpt_line,offset,ncols)
  186.       SKIP
  187.       IF Eof()
  188.          last_scrn = .t.
  189.          EXIT
  190.       ENDIF                                      && IF Eof()
  191.    NEXT                                          && FOR i = 1 TO nrows
  192.    Sayhelp(vhelp)
  193.    GO oldrec
  194. RETURN(.T.)
  195.  
  196. *----------------------------
  197. *         Author: Ed Phillips
  198. *   Date Created: 11/27/90
  199. *   Time Created: 10:56:27
  200. *----------------------------
  201. FUNCTION EndKey
  202.    PRIVATE oldrec
  203.    oldrec = Recno()
  204.    GO BOTTOM
  205.    SKIP -(nrows-1)
  206.    IF oldrec != Recno()
  207.       line_num = Recno()
  208.       DispView()
  209.    ELSE
  210.       Alert()
  211.    ENDIF                                         && IF oldrec != Recno()
  212. RETURN(.T.)
  213.  
  214. *----------------------------
  215. *         Author: Ed Phillips
  216. *   Date Created: 11/27/90
  217. *   Time Created: 10:59:55
  218. *----------------------------
  219. FUNCTION HomeKey
  220.    IF line_num > 1
  221.       GO TOP
  222.       line_num = Recno()
  223.       DispView()
  224.    ELSE
  225.       Alert()
  226.    ENDIF                                         && IF line_num > 1
  227. RETURN(.T.)
  228.  
  229. *----------------------------
  230. *         Author: Ed Phillips
  231. *   Date Created: 11/27/90
  232. *   Time Created: 11:04:03
  233. *----------------------------
  234. FUNCTION DownArrow
  235.    IF ! last_scrn
  236.       Scroll(top,lt,bot,rt,1)
  237.       line_num = line_num + 1
  238.       SKIP nrows
  239.       @ bot,lt SAY Subs(Rpt_line,offset,ncols)
  240.       GO line_num
  241.    ELSE
  242.       Alert()
  243.    ENDIF                                         && IF ! last_scrn
  244. RETURN(.T.)
  245.  
  246. *----------------------------
  247. *         Author: Ed Phillips
  248. *   Date Created: 11/27/90
  249. *   Time Created: 11:08:20
  250. *----------------------------
  251. FUNCTION PageDown
  252.    IF ! last_scrn
  253.       SKIP nrows-1
  254.       line_num = Recno()
  255.       DispView()
  256.       GO line_num
  257.    ELSE
  258.       Alert()
  259.    ENDIF                                         && IF ! last_scrn
  260. RETURN(.T.)
  261.  
  262. *----------------------------
  263. *         Author: Ed Phillips
  264. *   Date Created: 11/27/90
  265. *   Time Created: 11:12:09
  266. *----------------------------
  267. FUNCTION PageUp
  268.    IF line_num > 1
  269.       SKIP -(nrows - 1)
  270.       line_num = Recno()
  271.       DispView()
  272.    ELSE
  273.       Alert()
  274.    ENDIF                                         && IF line_num > 1
  275. RETURN(.T.)
  276.  
  277. *----------------------------
  278. *         Author: Ed Phillips
  279. *   Date Created: 11/27/90
  280. *   Time Created: 11:53:39
  281. *----------------------------
  282. FUNCTION ValRecNo
  283.    PARAMETERS recno
  284.    PRIVATE ret_val
  285.  
  286.    ret_val = .t.
  287.    IF M->recno < 1 .OR. M->recno > Reccount()
  288.       Sayerr( 'Range is 1 to '+Ltrim(Str(Reccount(),7,0)) )
  289.       ret_val = .f.
  290.    ENDIF                                         && IF M->recno < 1 .OR. M->recno > Reccount()
  291. RETURN (ret_val)
  292. * EOF: RPTOSCRN.PRG
  293.