home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / C / JAZDOC / JAZLIB.DOC < prev   
Text File  |  1993-12-01  |  71KB  |  2,735 lines

  1.  
  2. (c) JAZSOFT 1986 by Jack A. Zucker
  3.  
  4. If you are interested in getting support for these
  5. routines or are just feeling plain guilty for using them
  6. without paying for them, feel free to send a donation of
  7. whatever you can afford. ($25.00 would be appreciated).
  8. My address is:
  9.  
  10. JazSoft
  11. Jack A. Zucker
  12. 10318 Broom Lane
  13. Seabrook, Md. 20706
  14.  
  15. You may leave messages to me concerning problems, advice, etc on
  16. Robert Blacher's Ibm Pc board at
  17. (301) 547-2008
  18. or if you are really desperate at my house at
  19.  
  20. (301) 794-5950 or
  21. (301) 794-8763.
  22.  
  23.  
  24. If you get my answering machine, Please leave a message and your phone
  25. number, but be forewarned... I will not call you long distance unless
  26. you tell me to call collect. Sorry about this but I called one guy and
  27. spent a half hour talking to him then found out he lived in Ontario,Ca.!!!!
  28. Thanks, and I hope you enjoy.
  29. -Jaz
  30.  
  31.  
  32.  
  33.  
  34.  
  35.             DOS FUNCTIONS AND FILE HANDLING
  36.  
  37. 1. JZCLSFIL    Close a file handle
  38.  
  39.     This functions closes a previously opened file handle.
  40.  
  41.     werror = jzclsfil(whandle);
  42.  
  43.     int werror        -1 if an error occurred,
  44.                  0 if everything went according to plan.
  45.  
  46.     int whandle        The opened file handle.
  47.  
  48. 2. JZCPYFIL    Copy a file
  49.  
  50.     This function copies one file spec to another file spec.
  51.     Wildcards may also be used in the file spec.
  52.  
  53.     jzcpyfil(wsource,wdestin);
  54.  
  55.     char *wsource        Source file specification
  56.  
  57.     char *wdestin        Destination file specification
  58.  
  59. 3. JZCRTFIL    Create a file handle
  60.  
  61.     This function creates a file handle or truncates an existing
  62.     one.
  63.  
  64.     werror = jzcrtfil(wname,wattr);
  65.  
  66.     int werror        -1 if an error occurred,
  67.                  otherwise a valid dos file handle
  68.  
  69.     char *wname        File spec to create/truncate
  70.  
  71.     int wattr        File attribute to create file with.
  72.                 0 or 32 is the normal file attribute.
  73.  
  74. 4. JZDOSFLG    Return the vector of the "in dos" flag.
  75.  
  76.     This function returns the address of the "in dos" flag. This
  77.     is valuable in resident programs to determine whether or not
  78.     dos commands can be run when a program is interupted. Normally,
  79.     if the in dos flag <> 0 then a dos call is in progress and dos
  80.     i/o may NOT be performed.
  81.  
  82.     jzdosflg(&wvector);
  83.  
  84.     TVECTOR wvector     This struct is defined in JAZ.H and contains
  85.                 an segment and offset field. This can be
  86.                 converted to a far pointer and used to reference
  87.                 the in dos flag.
  88.  
  89.     EX.
  90.  
  91.       #include <jaz.h>
  92.       TVECTOR wvector;
  93.  
  94.       jzdosflg(&wvector);
  95.  
  96.       if (memb(wvector.segment,wvector.offset))
  97.         printf("\nIn the middle of a dos function call.");
  98.  
  99. 5. JZDOSVER    Return the dos major and minor version.
  100.  
  101.     This function returns an integer equal to the dos version.
  102.     The Low byte will be the major version and the High byte will
  103.     be the minor version.
  104.  
  105.     wversion = jzdosver();
  106.  
  107.     int wversion        The version of dos you are running.
  108.                 i.e. 0A03 (hex) for dos 3.1
  109.  
  110.     EX.
  111.  
  112.       int wversion;
  113.  
  114.       wversion = jzdosver();        /* get dos version */
  115.  
  116.       /**
  117.        ** exit this mythical program
  118.        ** if the dos version is below 2.0
  119.        **/
  120.  
  121.       if ((wversion & 0xFF) < 2) {
  122.         printf("\nMust have 2.0 or greater to run this program.");
  123.         exit(1);
  124.       }
  125.  
  126. 6. JZDSKFRE    Return the free space remaining on the disk.
  127.  
  128.     This function returns file allocation table information regarding
  129.     free space remaining on the specified disk.
  130.  
  131.     jzdskfre(&wfat,wdrive);
  132.  
  133.     TFAT wfat        This structure is defined in JAZ.H. It
  134.                 contains fields for free, total, and
  135.                 used.
  136.  
  137.     int wdrive;        This should be:
  138.                 0 : default drive
  139.                 1 : A:
  140.                 2 : B:
  141.                 3 : C:
  142.                 etc.
  143.  
  144.     EX.
  145.  
  146.       #include <jaz.h>
  147.  
  148.       TFAT wfat;
  149.  
  150.       jzdskfre(&wfat,0);    /* get free space on default drive */
  151.  
  152.       if (wfat.free < 360000L)
  153.         printf("\nThis disk is not empty!");
  154.  
  155. 7. JZDSKSTS    Return a disk status code
  156.  
  157.     Return a disk status code for the specified drive. This
  158.     will not cause an "Abort , Retry, Ignore" error and is
  159.     good for determining whether or not a disk is formatted
  160.     or the drive door is open.
  161.  
  162.     wstatus = jzdsksts(wdrive);
  163.  
  164.     int wstatus        $80  -     Timeout
  165.                 $40  -     Bad Seek
  166.                 $20  -     Nec Controller failed
  167.                 $10  -     Bad Crc
  168.                  $8  -     Attempt to cross 64k boundry
  169.                  $4  -     Sector not found
  170.                  $3  -     write protect
  171.                  $2  -     address mark not found
  172.                  $1  -     bad command
  173.                  $0  -     Succsessful
  174.  
  175.     int wdrive        0..3 for floppy diskette drives A,B,C,D
  176.                 $80..$83 for fixed disk drives    C,D,E,F ETC.
  177.  
  178.  
  179. 8. JZFAT    Get file allocation table information.
  180.  
  181.     Returns Sect/Allocation unit , total Clusters, bytes/sectors
  182.     for the specified drive.
  183.  
  184.     wid = jzfat(wdrive,§_alloc,§_size,&cluster);
  185.  
  186.     char far *wid    Far pointer to FAT id byte
  187.  
  188.     int wdrive    0 : Default drive
  189.             1 : Drive A
  190.             2 : Drive B
  191.             3 : Drive C
  192.                 etc
  193.  
  194.     unsigned
  195.     int sect_alloc    Sectors per allocation unit. (Sect/Cluster)
  196.  
  197.     unsigned
  198.     int sect_size    Bytes per sector
  199.  
  200.     unsigned
  201.     int clusters    Total Clusters on disk
  202.  
  203. 9. JZFNDFST    Find first matching file
  204.  
  205.     This function finds the first matching file given a file
  206.     specification i.e. *.c
  207.  
  208.     werror = jzfndfst(wmask,wattr,&wdta);
  209.  
  210.     int werror    returns 0 if a match was found, otherwise there
  211.             are no files matching the mask specification.
  212.  
  213.     char *wmask    File specification i.e. "*.DOC"
  214.  
  215.     int wattr    Attribute to search for.
  216.             1 : Read Only
  217.             2 : Hidden
  218.             4 : System
  219.             8 : Volume Label
  220.                16 : Sub-Directory
  221.                32 : Archive
  222.                These may be "OR"ed together to get combinations.
  223.                Use 0 for normal files, 0xFF for ALL files
  224.  
  225.     TDIR wdta;     Structure defined in jzdirect.h which defines the
  226.                disk transfer address buffer, with various directory
  227.                fields.
  228.  
  229. 10. JZFNDNXT    Find next matching file
  230.  
  231.     Find the next matching file after initially calling jzfndfst.
  232.  
  233.     werror = jzfndnxt(&wdta);
  234.  
  235.     int werror    returns 0 if a match was found, otherwise ther
  236.             are no more files matching the mask specification.
  237.  
  238.     TDIR wdta    Structure defined in jzdirect.h which defines the
  239.             disk transfer address buffer, with various directory
  240.             fields.
  241.  
  242.  
  243.     EX.
  244.       #include <jzdirect.h>
  245.  
  246.       int werror;        /* return error code */
  247.       TDIR wdta;        /* disk directory buffer */
  248.  
  249.       werror = jzfndfst("*.*",0,&wdta);   /* list all files in directory */
  250.  
  251.       while (werror == 0) {
  252.         printf("\n%s",wdir.name);
  253.         werror = jzfndnxt(&wdta);
  254.       }
  255.  
  256. 11. JZGETATR    Get a files attribute
  257.  
  258.     Return the attribute for a given file.
  259.  
  260.     wattr = jzgetatr(wfilename);
  261.  
  262.     int wattr    Attribute returned for file
  263.                -1 : Error (Probably file not found)
  264.             1 : Read Only
  265.             2 : Hidden
  266.             4 : System
  267.             8 : Volume Label
  268.                16 : Sub-Directory
  269.                32 : Archive
  270.  
  271.     char
  272.     *wfilename    File name to return attribute for
  273.  
  274. 12. JZGETDAT    Return the system date
  275.  
  276.     Return the system date as a string. i.e. 01-25-1986
  277.     Make sure to reserve enough space for the entire date.
  278.     at least 11 chars (including the null terminator)
  279.  
  280.     jzgetdat(wdate);
  281.  
  282.     char *wdate    : date string returned here
  283.  
  284. 13. JZGETDR    Return the current working directory.
  285.  
  286.     Return the working sub-directory as a string.The string will
  287.     not have a "\" char after it so if you want to use this for
  288.     searches, you must concatenate a "\" to it, especially if you
  289.     are in the root dir as it may return "".
  290.  
  291.     jzgetdr(wdir);
  292.  
  293.     char *wdir    Current working sub-directory string on return
  294.  
  295. 14. JZGETDRV    Get logged drive
  296.  
  297.     Return the current logged drive.
  298.  
  299.     wdrive = jzgetdrv();
  300.  
  301.     int wdrive    0 : Drive A
  302.             1 : Drive B
  303.             2 : Drive C
  304.             etc..
  305.  
  306. 15. JZGETDTA    Get the disk transfer address
  307.  
  308.     Return the current disk transfer address from Dos. This is needed
  309.     by the directory routines which change the DTA. They save the address
  310.     in a work variable , then change it for the directory call, then
  311.     restore it. This is necessary 'cuz some of the high level file
  312.     access routines use the DTA as the file buffer!
  313.  
  314.     jzgetdta(wofs,wseg);
  315.  
  316.     int wofs    Offset of DTA address
  317.  
  318.     int wseg    segment of DTA address
  319.  
  320. 16. JZGETFCB    Get an unopened FCB
  321.  
  322.     Return an unopened FCB record given a drive and file name.
  323.     The unopened FCB contains detailed info on the file including
  324.     the starting cluster number. See JZCHKDSK for info on where
  325.     to use this routine.
  326.  
  327.     werror = jzgetfcb(&wfcb,wfilename,wdrive);
  328.  
  329.     int werror    -1 if an error occurred,
  330.              0 if everything went according to plan.
  331.  
  332.     TFCB wfcb    File control block record defined in JAZ.H
  333.  
  334.     char
  335.     *wfilename    File name to get FCB for. Paths are NOT allowed!
  336.  
  337.     int wdrive    1 : Drive A
  338.             2 : Drive B
  339.             3 : Drive C
  340.             etc...
  341.  
  342.  
  343. 17. JZGETINT    Get an interrupt vector
  344.  
  345.     Return the segment/offset address of a given interrupt number
  346.  
  347.     jzgetint(wint,&wvec);
  348.  
  349.     int wint    Interrupt number to get address of
  350.  
  351.     TVEC wvec    Segment offset record defined in JAZ.H
  352.  
  353. 18. JZGETMEM    Allocate memory
  354.  
  355.     Return a segment pointer to a block of free memory.
  356.  
  357.     werror = jzgetmem(wbytes,&wpointer);
  358.  
  359.     int werror    -1 if an error occurred,
  360.              0 if everything went according to plan.
  361.  
  362.     unsigned
  363.     int wbytes    Number of bytes requested to allocate
  364.  
  365.     unsigned
  366.     int wpointer    Pointer to segment of free memory.
  367.  
  368. 19. JZGETTIM    Get the system time
  369.  
  370.     Return the system time as a string: 19:05:22 . Make sure to
  371.     allocate at least 9 chars for the string length.
  372.  
  373.     jzgettim(wtime);
  374.  
  375.     char *wtime    Time string to be returned.
  376.  
  377. 20. JZGETVOL    Get the volume label of a drive
  378.  
  379.     Get the volume label for the specified drive;
  380.  
  381.     wptr = jzgetvol(wdrive,wvolume);
  382.  
  383.     char *wptr    Pointer to wvolume argument for using in
  384.             expressions. Null pointer if error occured.
  385.  
  386.     wdrive        0 : Drive A
  387.             1 : Drive B
  388.             2 : Drive C
  389.             etc.
  390.  
  391.     char
  392.     *wvolume    String for volume label. Make sure to allocate
  393.             at least 13 chars for this string.
  394.  
  395. 21. JZLOGDRV    Change the logged drive.
  396.  
  397.     Set the current logged drive.
  398.  
  399.     wnumdrives = jzlogdrv(wdrive);
  400.  
  401.     int
  402.     wnumdrives    Returns the number of drives in the system
  403.  
  404.     int wdrive    0 : Drive A
  405.             1 : Drive B
  406.             2 : Drive C
  407.             etc
  408.  
  409. 22. JZOPNFIL    Open a file handle
  410.  
  411.     Open a file handle for read/write access
  412.  
  413.     werror = jzopnfil(wname,wmode);
  414.  
  415.     int werror    -1 if an error occurred,
  416.              otherwise a valid dos file handle
  417.  
  418.     char *wname    File name to open
  419.  
  420.     int wmode    0 : read only
  421.             1 : write only
  422.             2 : read/write
  423.             et. al.
  424.  
  425. 23. JZPOPDIR    Pop a directory
  426.  
  427.     Pop a directory from the directory stack and change the
  428.     current logged directory to it.
  429.  
  430.     jzpopdir(&whead,wpopdrive);
  431.  
  432.     TSTKHEAD
  433.     whead        Head of stack structure defined in JAZ.H
  434.  
  435.     int wpopdrive    1 : Pop the drive as well as the directory
  436.             0 : Don't pop the drive, Only the directory.
  437.  
  438. 24. JZPSHDIR    Push a directory
  439.  
  440.     Push a directory and drive onto the directory stack for subsequent
  441.     use by jzpopdir.
  442.  
  443.     jzpshdir(&whead);
  444.  
  445.     TSTKHEAD
  446.     whead        Head of stack structure defined in JAZ.H
  447.  
  448. 25. JZREDFIL    Read from a file handle.
  449.  
  450.     Read data from a file handle into a buffer. This is a fairly
  451.     high speed disk access method, very useful for copying files and
  452.     such.
  453.  
  454.     wnum = jzredfil(whandle,wbuf,wamt);
  455.  
  456.     unsigned
  457.     int wnum    Actual number of bytes read from the file. A value
  458.             of < wamt (or 0) means end of file.
  459.  
  460.     int whandle    The handle of the previously opened file from a call
  461.             to jzopnfil/jzcrtfil
  462.  
  463.     char *wbuf    Buffer to read the data into. Usually an array or
  464.             pointer to char.
  465.  
  466.     unsigned
  467.     int wamt    The number of bytes requested to read.
  468.  
  469. 26. JZSEKFIL    Seek into a file.
  470.  
  471.     Seek to a position into a file. (Random Access). There are 3
  472.     methods of seeking:
  473.     0 : Seek relative to beginning of file.
  474.     1 : Seek relative to Current file position
  475.     2 : Seek relative to End of File
  476.  
  477.     Note that negative offsets are not allowed !.
  478.  
  479.     wpos = jzsekfil(whandle,woffset,wmethod);
  480.  
  481.     long wpos    Position of the file pointer in bytes relative
  482.             to the beginning of the file.
  483.  
  484.     int whandle    The handle of the previously opened file from a call
  485.             to jzopnfil/jzcrtfil
  486.  
  487.     unsigned int
  488.     woffset     Offset of bytes to seek from one of the
  489.             methods specified in wmethod.
  490.  
  491.     int wmethod    0 : Seek relative to beginning of file.
  492.             1 : Seek relative to Current file position
  493.             2 : Seek relative to End of File
  494.  
  495.  
  496.     EX.
  497.  
  498.       /* how to seek to the end of the file minus one */
  499.       /* difficult 'cuz negative offsets not allowed  */
  500.  
  501.       int whandle;
  502.       long fsize,jzsekfil();
  503.  
  504.       . . . . .
  505.  
  506.       /* assume file was already opened at this point */
  507.  
  508.       fsize = jzsekfil(whandle,0L,2);        /* seek to end of file */
  509.       if (fsize) {
  510.         fsize --;                    /* subtract 1 from size */
  511.         jzsekfil(whandle,fsize,0);            /* seek to eof - 1 */
  512.       }
  513.  
  514. 27. JZSETATR    Set a files attributes
  515.  
  516.     Set the attributes of a given file .
  517.  
  518.     werror = jzsetatr(wname,wattr);
  519.  
  520.     int werror    -1 if an error occurred,
  521.              0 if everything went according to plan.
  522.  
  523.     char *wname    File name with which to set attributes
  524.  
  525.     int wattr    Attribute used to set for file. These may
  526.             be *or* ed together.
  527.              1 : Read Only
  528.              2 : Hidden
  529.              4 : System
  530.              8 : Volume Label
  531.             16 : Sub-Directory
  532.             32 : Archive
  533.  
  534. 28. JZSETDTA    Set the disk transfer address
  535.  
  536.     This function sets the disk transfer address to the given
  537.     buffer (relative to DS). Used internally for jzfndfst &
  538.     jzfndnxt.
  539.  
  540.     jzsetdta(&wdta);
  541.  
  542.     TDTA wdta    Disk transfer structure to point DTA to.
  543.  
  544. 29. JZSETINT    Set an interrupt vector
  545.  
  546.     Set the vector for a particular interrupt of your specification.
  547.     Useful for redirecting interrupts to your routines.
  548.  
  549.     jzsetint(wint,wvec);
  550.  
  551.     int wint    Interrupt vector number to set.
  552.  
  553.     TVECTOR wvec    Structure where segment and offset fields
  554.             are already filled in.
  555.  
  556.     EX.
  557.  
  558.     TVECTOR wvec;
  559.     int prtsc();
  560.  
  561.     wvec.segment = getcs();
  562.     wvec.offset = prtsc;        /* get address of new print screen */
  563.  
  564.     jzsetint(5,wvec);
  565.  
  566. 30. JZTRMRES    Terminate and stay resident
  567.  
  568.     Terminate the current process but leaving the program resident
  569.     in memory.
  570.  
  571.     jztrmres();
  572.  
  573. 31. JZUNQFIL    Return a unique file handle/name.
  574.  
  575.     This routine is functionally equivalent to JZOPNFIL
  576.     except it returns a handle pointing to a file name
  577.     that does not already exist. Very useful for temp
  578.     files.
  579.  
  580.     whandle = jzunqfil(wpath,wattr);
  581.  
  582.     int whandle    -1 if an error occurred,
  583.              otherwise a valid dos file handle.
  584.  
  585.     char *wpath    String containing the path to put the
  586.             unique file. This must end in a "\" and
  587.             must be a variable as the file name will
  588.             be placed in this variable.
  589.  
  590.     int wattr    Attribute used to
  591.             create the unique file name
  592.              1 : Read Only
  593.              2 : Hidden
  594.              4 : System
  595.              8 : Volume Label
  596.             16 : Sub-Directory
  597.             32 : Archive
  598.  
  599. 32. JZWRTFIL    Write data to a file handle.
  600.  
  601.     Write data from a buffer to a file handle. Like jzredfil, this
  602.     routine is useful for high speed data transfer.
  603.  
  604.     wnum = jzwrtfil(whandle,wbuf,wamt);
  605.  
  606.     unsigned
  607.     int wnum    Actual number of bytes written to the file.
  608.  
  609.     int whandle    The handle of the previously opened file from a call
  610.             to jzopnfil/jzcrtfil
  611.  
  612.     char *wbuf    Buffer to write the data from. Usually an array or
  613.             pointer to char.
  614.  
  615.     unsigned
  616.     int wamt    The number of bytes requested to write.
  617.  
  618.  
  619. 33. TRUNCATE    Truncate a file.
  620.  
  621.     Truncate a file to a certain size.
  622.  
  623.     werror = truncate(wname,wsize);
  624.  
  625.     int werror    -1 if an error occurred,
  626.              0 if everything went according to plan.
  627.  
  628.     char *wname    File name to truncate
  629.  
  630.     long wsize    New Size of the file.
  631.  
  632.  
  633.  
  634.             STRING HANDLING
  635.  
  636. 1.  INDEX    Return the index of a character in a string.
  637.  
  638.     Return the index position of the occurance of a character
  639.     in a substring or -1 if the character was not found.
  640.  
  641.     wpos = index(wsource,wch);
  642.  
  643.     int wpos    index of occurance of character wch in the string
  644.             wsource. Returns -1 if no occurance.
  645.  
  646.     char *wsource    Pointer to the source string to search.
  647.  
  648.     int wch     Character to do the search for.
  649.  
  650. 2.  JZCHRPOS    Return the index of a character in a string.
  651.  
  652.     Return the index position of the occurance of a character
  653.     in a substring or -1 if the character was not found.
  654.  
  655.     wpos = jzchrpos(wsource,wch);
  656.  
  657.     int wpos    index of occurance of character wch in the string
  658.             wsource. Returns -1 if no occurance.
  659.  
  660.     char *wsource    Pointer to the source string to search.
  661.  
  662.     int wch     Character to do the search for.
  663.  
  664. 3.  JZCHRSTR    Concatenate a character onto a string
  665.  
  666.     This function performs the task of appending a single char
  667.     to a string (which strcat will not do). It appends a null
  668.     terminating character to the end of the source string to
  669.     maintain string compatibility.
  670.  
  671.     jzchrstr(wsource,wch);
  672.  
  673.     char *wsource    Source string to concatenate character to
  674.  
  675.     int wch     Character to concatenate to wsource.
  676.  
  677. 4.  JZCNTSTR    Return a centered string.
  678.  
  679.     This function returns a string padded with blanks to be
  680.     centered in a give field width. Note that the maximum limit
  681.     on string size for this routine is 255. The routine itself
  682.     does NO range checking so it is up to the application itself
  683.     to insure that this does not happen. This routine uses a static
  684.     buffer for the pointer to return so subsequent calls to the routine
  685.     destroy the previous contents of the returned pointer!
  686.  
  687.     wptr = jzcntstr(wsource,wnum);
  688.  
  689.     char *wptr    pointer to centered string.
  690.  
  691.     char *wsource    String to have centered.
  692.  
  693.     wnum        Width of field to center on.
  694.  
  695. 5.  JZDLTSTR    Delete a substring from another string.
  696.  
  697.     Give a starting and ending position, this routine will remove
  698.     a portion of a string.
  699.  
  700.     wnum = jzdltstr(wsource,wfrom,fto);
  701.  
  702.     int wnum    Number of chars actually deleted.
  703.  
  704.     char *wsource    String to delete chars from.
  705.  
  706.     int wfrom    Starting index to delete from
  707.  
  708.     int wto     Ending index to delete to
  709.  
  710. 6.  JZGETPCE    Get delimited piece of substring
  711.  
  712.     This routine returns the "n"th piece of a delimited string.
  713.     i.e. Jaz;10318 Broom Lane;Seabrook;Md;20706
  714.     the 3rd ";" piece of the string is "Seabrook"
  715.  
  716.     wptr = jzgetpce(wsource,wdestin,wdel,wnum);
  717.  
  718.     char *wptr    Pointer to wdestin, the destination piece.
  719.  
  720.     char *wsource    The source string with delimiters
  721.  
  722.     char *wdestin    The destination string.
  723.  
  724.     int wdel    The character used as a delimiter
  725.  
  726.     int wnum    Which piece do you want?
  727.  
  728. 7.  JZINSSTR    Insert a string into another string.
  729.  
  730.     This routine does a string insert of one string into another at
  731.     a given starting position. Note that if wstart is > than the
  732.     length of the source string, blanks will be appended.
  733.  
  734.     jzinsstr(wdestin,wsource,wstart);
  735.  
  736.     char *wdestin    Pointer to destination string (to be inserted).
  737.  
  738.     char *wsource    Pointer to string to insert
  739.  
  740.     int wstart    Index of position to start inserting.
  741.  
  742. 8.  JZLFTSTR    Return the left n chars from a string
  743.  
  744.     This routine returns the left n chars of a given string.
  745.     note that this routine uses a static 255 byte buffer for the pointer to
  746.     return so subsequent calls to the routine destroy the
  747.     previous contents of the returned pointer!
  748.  
  749.     wptr = jzlftstr(wstr,wnum);
  750.  
  751.     char *wptr    Pointer to static buffer containing the left string.
  752.  
  753.     char *wstr    Source string
  754.  
  755.     int wnum    The number of chars you want from the source string.
  756.  
  757. 9.  JZMIDSTR    Return the middle n chars from a string.
  758.  
  759.     Given a starting position and a length, return the mid chars from
  760.     a given string.
  761.     note that this routine uses a static 255 byte buffer for the pointer to
  762.     return so subsequent calls to the routine destroy the
  763.     previous contents of the returned pointer!
  764.  
  765.     wptr = jzmidstr(wstr,wstart,wlen);
  766.  
  767.     char *wptr    pointer to static buffer containing the sub string
  768.  
  769.     char *wstr    Source string
  770.  
  771.     int wstart    Starting index of sub string
  772.  
  773.     int wlen    Length of substring.
  774.  
  775. 10. JZPAD    Pad a string
  776.  
  777.     This routine pads a given string with a given char.
  778.     Note that this routine uses a static 255 byte buffer for the pointer to
  779.     return so subsequent calls to the routine destroy the
  780.     previous contents of the returned pointer!
  781.  
  782.     wptr = jzpad(wstr,wch);
  783.  
  784.     char *wptr    Pointer to static buffer containing padded string.
  785.  
  786.     char *wstr    Source string to pad.
  787.  
  788.     int wch     Character to pad with.
  789.  
  790. 11. JZPRSFIL    Parse a path\file
  791.  
  792.     This routine parses a path name into a seperate file name and
  793.     path name with the path name ending in a "\".
  794.  
  795.     jzprsfil(wfull,wpath,wfile);
  796.  
  797.     char *wfull    Full path. i.e. "\\MSC\\JAZ\\JZSEARCH.EXE"
  798.  
  799.     char *wpath    Returned Path portion of wfull
  800.  
  801.     char *wfile    Returned file name portion of wfull
  802.  
  803. 12. JZRGTJST    Right justify a string
  804.  
  805.     This routine right justifies a given string. Effectively padding to
  806.     the right.
  807.     Note that this routine uses a static 255 byte buffer for the pointer to
  808.     return so subsequent calls to the routine destroy the
  809.     previous contents of the returned pointer!
  810.  
  811.     wptr = jzrgtjst(wstr,wnum);
  812.  
  813.     char *wptr    Pointer to static buffer containing padded string.
  814.  
  815.     char *wstr    Source string to pad.
  816.  
  817.     int wch     Character to pad with.
  818.  
  819. 13. JZRGTSTR    Return the right n chars of a string
  820.  
  821.     This routine returns the rightmost n chars of a given string.
  822.     Note that this routine uses a static 255 byte buffer for the pointer to
  823.     return so subsequent calls to the routine destroy the
  824.     previous contents of the returned pointer!
  825.  
  826.     wptr = jzrgtstr(wstr,wnum);
  827.  
  828.     char *wptr    Pointer to static buffer containing the left string.
  829.  
  830.     char *wstr    Source string
  831.  
  832.     int wnum    The number of chars you want from the source string.
  833.  
  834. 14. JZRPLSTR    Replace chars in a string.
  835.  
  836.     This routine replaces characters in a string with a given substring.
  837.  
  838.     jzrplstr(wdestin,wsource,wstart,wlen);
  839.  
  840.     char *wdestin    Destination string to insert into.
  841.  
  842.     char *wsource    Source string to insert.
  843.  
  844.     int wstart    Starting index to replace.
  845.  
  846.     int wlen    Length of chars to insert.
  847.  
  848. 15. JZSTRCAT    Concatenate multiple strings
  849.  
  850.     This routine concatenates multiple strings together in one shot.
  851.  
  852.     jzstrcat(wsource,wstr1,wstr2,NULL);
  853.  
  854.     char *wsource    String to concatenate onto
  855.  
  856.     char *wstr1    Strings to concatenate
  857.          *wstr2
  858.          etc...
  859.  
  860.     char NULL    The Routine stops when it detects a null string.
  861.             You may use 0 here but it's less portable.
  862.  
  863. 16. JZSTRPOS    Return a pointer to a substring
  864.  
  865.     Returns a pointer to a substring within another string or null
  866.     if not found.
  867.  
  868.     wptr = jzstrpos(wobject,wtarget);
  869.  
  870.     char *wptr    Pointer to occurance of wobject in wtarget or null
  871.             if not found.
  872.  
  873.     char *wobject    String we are searching for
  874.  
  875.     char *wtarget    String we are searching.
  876.  
  877. 17. JZWLDCRD    Wild card file search
  878.  
  879.     This routine implements a very simplistic wild card match on
  880.     two strings.
  881.  
  882.     wmatch = jzwldcrd(wsource,wwild);
  883.  
  884.     int wmatch    1 : if match
  885.             0 : if no match
  886.  
  887.     char *wsource    Source string we are checking
  888.  
  889.     char *wwild    Wild card string
  890.  
  891. 18. LITERAL    Parse a user string
  892.  
  893.     Convert a user string with escape sequences to an internal string.
  894.      /**/ delineate comments
  895.      \x1b translates to char(0x1b)
  896.      \27  translates to char(27)
  897.      \"   translates to "
  898.      \'   translates to '
  899.      \\   translates to \
  900.  
  901.      literal(wsource,wdestin);
  902.  
  903.      char *wsource    Original string with esc sequences
  904.  
  905.      char *wdestin    Destination string with expansions.
  906.  
  907. 19. RINDEX    Return the rear index of a char in a string.
  908.  
  909.     Return the last occurance of a char within a string or
  910.     -1 if not found.
  911.  
  912.     wpos = rindex(wsource,wch);
  913.  
  914.     int wpos    index position of occurance of last wch in wsource
  915.             or -1 if wch was not found.
  916.  
  917.     char *wsource    String to do the search on
  918.  
  919.     int wch     Char we are searching for.
  920.  
  921. 20. TABTOSP    Convert tabs to spaces
  922.  
  923.     Expand tab chars in a string to spaces given that the default tabs
  924.     are 1,9,17,25,33,41 etc.
  925.  
  926.     wptr = tabtosp(wsource,wdestin);
  927.  
  928.     char *wptr    Returned Pointer to wdestin.
  929.  
  930.     char *wsource    Source string with tabs in it.
  931.  
  932.     char *wdestin    Destination string without tabs.
  933.  
  934.  
  935.  
  936.         LOW LEVEL OPERATING SYSTEM ROUTINES
  937.  
  938.  
  939. 1.  CLI     Clear interrupts
  940.  
  941.     Clear the interrupt flag disabling interrupts
  942.  
  943.     cls();
  944.  
  945. 2.  DISKINFO    Get low level disk info
  946.     This routine gets low level disk info directly from the
  947.     boot sector. This will NOT work on a ram disk. It will
  948.     work only on MSDOS diskettes version 2.0 and above may not
  949.     work on some variations of MSDOS.
  950.  
  951.     werror = diskinfo(&wdiskblk,wdrive);
  952.  
  953.     int werror    Dos disk error code. Anything <> 0 means some
  954.             kind of error occured.
  955.  
  956.     TDISKBLK
  957.     wdiskblk    Disk block structure defined in JAZ.H . This record
  958.             contains fields for many low level disk paramters.
  959.  
  960.     int wdrive    0 : Drive A
  961.             1 : Drive B
  962.             2 : Drive C
  963.             etc.
  964.  
  965. 3.  DOSREADS    Read disk sectors
  966.  
  967.     Directly read sectors from the disk. This routine bypasses the
  968.     Abort, Retry, Ignore message that you usually get from dos so
  969.     you can use it as a disk status check.
  970.  
  971.     werror = dosreads(wdrive,wsector,wamt,wbuf);
  972.  
  973.     int werror    Dos error code for read. It will be 0 if no error
  974.             occurred, otherwise a dos error code.
  975.  
  976.     int wdrive    0 : Drive A
  977.             1 : Drive B
  978.             2 : Drive C
  979.             etc.
  980.  
  981.     int wsector    Starting sector number.
  982.  
  983.     int wamt    Number of sectors to read
  984.  
  985.     char *wbuf    Buffer to read data into.
  986.  
  987. 4.  DOSWRITS    Write Disk Sectors
  988.  
  989.     Directly write sectors to the disk. This routine bypasses the
  990.     Abort, Retry, Ignore message that you usually get from dos so
  991.     you can use it as a disk status check.
  992.  
  993.     werror = doswrits(wdrive,wsector,wamt,wbuf);
  994.  
  995.     int werror    Dos error code for write. It will be 0 if no error
  996.             occurred, otherwise a dos error code.
  997.  
  998.     int wdrive    0 : Drive A
  999.             1 : Drive B
  1000.             2 : Drive C
  1001.             etc.
  1002.  
  1003.     int wsector    Starting sector number.
  1004.  
  1005.     int wamt    Number of sectors to write
  1006.  
  1007.     char *wbuf    Buffer to write data from
  1008.  
  1009. 5.  GETCS    Get the code segment value
  1010.  
  1011.     Return the segment value for the code segment.
  1012.  
  1013.     wcode = getcs();
  1014.  
  1015.     int wcode    Value to be returned for the code segment
  1016.  
  1017. 6.  GETDS    Get the data segment value
  1018.  
  1019.     Return the segment value for the data segment.
  1020.  
  1021.     wcode = getds();
  1022.  
  1023.     int wcode    Value to be returned for the data segment
  1024.  
  1025. 7.  GETES    Get the extra segment value
  1026.  
  1027.     Return the segment value for the extra segment.
  1028.  
  1029.     wcode = getes();
  1030.  
  1031.     int wcode    Value to be returned for the extra segment
  1032.  
  1033. 8.  GETSS    Get the stack segment value
  1034.  
  1035.     Return the segment value for the stack segment.
  1036.  
  1037.     wcode = getss();
  1038.  
  1039.     int wcode    Value to be returned for the extra segment
  1040.  
  1041. 9.  INSINT24    Install a critical error handler
  1042.  
  1043.     This routine installs the critical error handler in place
  1044.     of the normal one, eliminating those pesky abort, retry, ignore
  1045.     messages.
  1046.     Note that you must call int24err() after every i/o call or you
  1047.     run the risk of hanging your system on a critical error.
  1048.  
  1049.     insint24();
  1050.  
  1051. 10. INT24ERR    Return an int 24 error code
  1052.  
  1053.     This routine fetches the error code (if any) after an i/o call
  1054.     after. The insint24 routine must have been previously called.
  1055.  
  1056.     werror = int24err();
  1057.  
  1058.     int werror    0 if No i/o error otherwise a dos error code.
  1059.             Check the Dos Ref Manual for a description of
  1060.             error codes and thier meanings.
  1061.  
  1062. 11. INT24HND    Critical error dispatcher
  1063.  
  1064.     This is the internal low level critical error dispatcher.
  1065.     The file name is INT24HND.ASM
  1066.  
  1067. 12. INTR    Interrupt Gate
  1068.  
  1069.     This routine provides a way to make bios and dos calls in a similar
  1070.     fashion to Turbo Pascal (Tm). See also MSDOS (under MISC MACROS).
  1071.  
  1072.     intr(&wreg);
  1073.  
  1074.     TREG wreg    Register structure for passing to dos or bios.
  1075.  
  1076. 13. JZBIGFAT    Determine FAT SIZE
  1077.  
  1078.     Return 1 if FAT is 16 bit, otherwise, return 0
  1079.     See JZCHKDSK.DMO for ideas on this one
  1080.  
  1081.     wbig = jzbigfat(wtotalsect,wsectsize);
  1082.  
  1083.     int wbig    Returns
  1084.             1 : 16 bit fat
  1085.             0 : 12 bit fat
  1086.  
  1087.     int
  1088.     wtotalsect    : This must be the total sectors on disk.
  1089.  
  1090.     int
  1091.     wsectsize    : This must be the amount of bytes/sector on disk.
  1092.  
  1093. 14. JZFATEOF    Determine if at end of cluster chain for file
  1094.  
  1095.     Return true if at the end of a files cluster chain.
  1096.     See JZCHKDSK.DMO for ideas on this one
  1097.  
  1098.     weof = jzfateof(wcluster,wbig);
  1099.  
  1100.     int weof    Returns:
  1101.             1 : End of file cluster chain
  1102.             0 : More to go.
  1103.  
  1104.     unsigned int
  1105.     wcluster    Cluster number we are currently looking at
  1106.  
  1107.     int wbig    1 : 16 bit fat
  1108.             0 : 12 bit fat
  1109.  
  1110. 15. JZGETCLS    Convert Fat index to Cluster number
  1111.  
  1112.     Given a FAT array, return the cluster number for a particular index.
  1113.     See JZCHKDSK.DMO for ideas on this one
  1114.  
  1115.     wcluster = jzgetcls(wfat,wcluster,wbig);
  1116.  
  1117.     int wcluster    Returned cluster number
  1118.  
  1119.     char *wfat    Buffer of file allocation stuff
  1120.  
  1121.     int wcluster    Current cluster number
  1122.  
  1123.     int wbig    1 : 16 bit fat
  1124.             0 : 12 bit fat
  1125.  
  1126. 16. JZGETDIR    Get a pointer to the disk directories
  1127.  
  1128.     Return pointer to disk directories and the number of root
  1129.     directory entires.
  1130.  
  1131.     jzgetdir(&wdir,wdrive,&wnum);
  1132.  
  1133.     TDIR *wdir    Pointer to low level directory information.
  1134.             Note that we must supply the routine a pointer
  1135.             to a pointer.
  1136.  
  1137.     int wdrive    0 : Drive A
  1138.             1 : Drive B
  1139.             2 : Drive C
  1140.  
  1141.     int wnum    Returned Number of root directory entries.
  1142.  
  1143. 17. JZGETFAT    Get a pointer to the FAT
  1144.  
  1145.     Return a pointer to the file allocation for the specified
  1146.     disk drive.
  1147.  
  1148.     jzgetfat(&wfat,wdrive);
  1149.  
  1150.     char *wfat    Returned pointer to a file allocation table. Note
  1151.             that this argument is a pointer to a pointer.
  1152.  
  1153.     int wdrive    0 : Drive A
  1154.             1 : Drive B
  1155.             2 : Drive C
  1156.  
  1157. 18. JZINSINT    Install a generic interrupt handler
  1158.  
  1159.     This routine installs an interrupt into the generic interrupt
  1160.     handler routine: JZINTHND.
  1161.  
  1162.     jzinsint(wint,wfunction);
  1163.  
  1164.     int wint    Interrupt number to define/redefine
  1165.  
  1166.     int
  1167.     wfunction()    Address of function to call when this interrupt
  1168.             vector is invoked.
  1169.  
  1170.     EX.
  1171.  
  1172.       #include <jaz.h>
  1173.       #include <jzscreen.h>
  1174.  
  1175.       int clock();
  1176.       int gcount = 17;              /* clock tic counter */
  1177.  
  1178.       #define TIMER 0x1C
  1179.  
  1180.       main()
  1181.       {
  1182.  
  1183.         jzinsint(TIMER,clock);       /* install the new timer interrupt */
  1184.  
  1185.         jztrmres();           /* terminate but stay resident */
  1186.  
  1187.       }
  1188.  
  1189.       clock()
  1190.       {
  1191.          char wstr[9];
  1192.  
  1193.        /* clock tics 18.2 times a second */
  1194.          if (gcount >= 17) {
  1195.            jzbiostm(wstr);
  1196.            jzscrprn(wstr,0,72,RED);
  1197.            gcount = 0;
  1198.          }
  1199.          else
  1200.            gcount ++;
  1201.       }
  1202.  
  1203.  
  1204. 19. JZINTHND    Generic Interrupt Dispatcher
  1205.  
  1206.     This routine handles the low level pushes, pops, and stack
  1207.     manipulation for a generic interrupt handler.
  1208.     The file name is JZINTHND.ASM
  1209.  
  1210.  
  1211. 20. READSECT    Read sectors from bios
  1212.  
  1213.     This routine uses bios to directly read sectors from the disk.
  1214.     It bypasses dos so you don't get the abort, retry, ignore
  1215.     messages.
  1216.  
  1217.     werror = readsect(wnum,wtrack,wsector,whead,wdrive,wbuf)
  1218.  
  1219.     int werror    0 if no error occurred, otherwise one of the following
  1220.             error codes:
  1221.             $80  -     Timeout
  1222.             $40  -     Bad Seek
  1223.             $20  -     Nec Controller failed
  1224.             $10  -     Bad Crc
  1225.              $8  -     Attempt to cross 64k boundry
  1226.              $4  -     Sector not found
  1227.              $3  -     write protect
  1228.              $2  -     address mark not found
  1229.              $1  -     bad command
  1230.  
  1231.     int wnum    Number of sectors to read 0..255
  1232.  
  1233.     int wtrack    Starting Track number
  1234.  
  1235.     int wsector    Starting Sector number
  1236.  
  1237.     int whead    Head number
  1238.  
  1239.     int wdrive    Should be set to one of the following:
  1240.             0..3 for floppy diskette drives A,B,C,D
  1241.             $80..$83 for fixed disk drives    C,D,E,F ETC.
  1242.  
  1243.     char *wbuf    Buffer to read data into. Make sure it is at least
  1244.             wnum * wsectorsize bytes long.
  1245.  
  1246. 21. STI     Set the interrupt flag
  1247.  
  1248.     Set the interrupt flag, enabling interrupts.
  1249.  
  1250.     sti();
  1251.  
  1252.  
  1253.                 UTILITY ROUTINES
  1254.  
  1255. 1.  GETCRC    Get a crc code for a buffer
  1256.  
  1257.     This routine returns a Cyclic Redundancy Check code for a given
  1258.     buffer.
  1259.  
  1260.     wcrc = getcrc(wbuf,wlen);
  1261.  
  1262.     unsigned int
  1263.     wcrc        Crc Code returned from function.
  1264.  
  1265.     char *wbuf    Pointer to data buffer to check.
  1266.  
  1267.     int wlen    sizeof (wbuf)
  1268.  
  1269. 2.  JZBEEP    Sound a beep to the console
  1270.  
  1271.     This routine sounds a slightly more pleasant beep to the
  1272.     console then the standard printf("%c",7);
  1273.  
  1274.     jzbeep();
  1275.  
  1276. 3.  JZBIOSTM    Return a "bios" time string.
  1277.  
  1278.     This routine returns a time string using the bios tic
  1279.     count instead of the dos function. This is handy during
  1280.     interrupt handlers where we cannot make dos calls.
  1281.  
  1282.     jzbiostm(wtime);
  1283.  
  1284.     char *wtime    Time string returned in the form HH:MM:SS
  1285.  
  1286. 4.  JZDELAY    Delay program execution
  1287.  
  1288.     Delay the current program for the specified number of clock
  1289.     tics.
  1290.  
  1291.     jzdelay(wtics);
  1292.  
  1293.     long wtics    Number of tics to delay. There are about 18
  1294.             clock tics in a second. Make sure you use a
  1295.             long value here or the high word may cause
  1296.             you to "hang" for a long time. (No Pun Intended)
  1297.  
  1298. 5.  JZINTDIR    Initialize the directory stack.
  1299.  
  1300.     This routine initializes the directory head structure in
  1301.     preperation for a call to jzpshdir.
  1302.  
  1303.     jzintdir(&wdirhead);
  1304.  
  1305.     TDIRHEAD
  1306.     wdirhead    Head of directory structure defined in JAZ.H
  1307.  
  1308.  
  1309. 6.  JZINTSTK    Initialize user stack
  1310.  
  1311.     This routine initializes the user stack in preperation
  1312.     for a call to jzpush
  1313.  
  1314.     jzintstk(&whead);
  1315.  
  1316.     TSTKHEAD
  1317.     whead        Record containing information pertaining
  1318.             to the user stack
  1319.  
  1320. 7.  JZPOP    Pop data from the user stack
  1321.  
  1322.     This routine allows data from the user stack to be "popped" into
  1323.     a variable. This is useful because data type is not a consideration
  1324.     and therefore variables can be popped to variables of other types.
  1325.  
  1326.     jzpop(&whead,wdata,wsize);
  1327.  
  1328.     TSTKHEAD
  1329.     whead        Record containing information pertaining
  1330.             to the user stack.
  1331.  
  1332.  
  1333.     char *wdata    This can actually be a pointer to any type
  1334.             of data. If type checking is enabled, you
  1335.             may have to use a cast.
  1336.     unsigned int
  1337.     wsize        Set this argument to 0 to receive the default
  1338.             size, which was specified when jzpush was
  1339.             called. Setting this value to something other
  1340.             than 0 will override the default and the number
  1341.             of bytes specified. Note that this does not pop
  1342.             other items off the stack, but merely takes more
  1343.             (or less) contiguous memory and places it in wdata.
  1344.  
  1345.  
  1346. 8.  JZPRNPTR    Print data from any data type
  1347.  
  1348.     This function allows byte by byte printing of a struct useful
  1349.     usually for debugging purposes.
  1350.  
  1351.     jzprnptr(wptr,wctrl,wlength);
  1352.  
  1353.     char *wptr    This can be any type of pointer to a structure,
  1354.             not just char. You may have to use a cast if
  1355.             you use strong type checking.
  1356.  
  1357.     char *wctrl    This is the control string for the print.
  1358.             i.e.
  1359.             "\n%0004X" or
  1360.             "%c "      or
  1361.             "%d "      etc.
  1362.  
  1363.     int wlength    The length of the data object to print. Typically
  1364.             it would be sizeof(wptr);
  1365.  
  1366. 9.  JZPUSH    Push data onto the user stack
  1367.  
  1368.     This routine is used to push data onto the local stack where
  1369.     it can be popped off later.
  1370.  
  1371.     jzpush(&whead,wdata,wsize);
  1372.  
  1373.     TSTKPTR
  1374.     whead        Record containing information pertaining
  1375.             to the user stack.
  1376.  
  1377.     char *wdata    This can actually be a pointer to any type
  1378.             of data. If type checking is enabled, you
  1379.             may have to use a cast.
  1380.  
  1381.     unsigned int
  1382.     wsize        Set this argument to sizeof(wdata) usually unless
  1383.             you want more or less bytes to be saved on the stack.
  1384.  
  1385. 10. JZPUTPRN    Put Data to the LPT1 device
  1386.  
  1387.     This routine writes chars to LPT1 using bios. It returns the
  1388.     printer status word.
  1389.  
  1390.     wstatus = jzputprn(wch);
  1391.  
  1392.     int wstatus    Printer status word. See the bios tech ref manual
  1393.             for details about how to read this word.
  1394.  
  1395.     int wch     Character to write to the printer
  1396.  
  1397. 11. JZREBOOT    Reboot the computer
  1398.  
  1399.     This routine allows you to either perform a warm boot or a
  1400.     cold boot of the machine. The warm boot simulates a Ctrl-Alt-Del,
  1401.     and the cold boot simulates a power on with a memory and
  1402.     diagnostics check.
  1403.  
  1404.     jzreboot(wcode);
  1405.  
  1406.     int wcode    1 : cold boot
  1407.             0 : warm boot
  1408.  
  1409. 12. JZTIMER    Time an event
  1410.  
  1411.     This routine performs a timing of an event in seconds. This routine
  1412.     uses a static variable to store the bios tic count. Because of this
  1413.     it needs to be called once to initialize the tic count.
  1414.  
  1415.     welapse = jztimer();
  1416.  
  1417.     unsigned int
  1418.     welapse     Returned seconds since the last call to this
  1419.             routine.
  1420.  
  1421.     EX.
  1422.  
  1423.       main()
  1424.       {
  1425.  
  1426.         unsigned int w;
  1427.  
  1428.         jztimer();        /* initialize the timer */
  1429.  
  1430.         for (w = 0 ; w < 0xFFFF ; w ++)    /* loop for nothin' */
  1431.         ;
  1432.  
  1433.         printf("Execution of this loop took %d seconds!",jztimer());
  1434.       }
  1435.  
  1436. 13. MEMB    Return a byte of memory
  1437.  
  1438.     This function returns a byte of memory, given a segment,offset
  1439.     pair.
  1440.  
  1441.     wch = memb(wseg,wofs);
  1442.  
  1443.     int wch     Char returned from memory
  1444.  
  1445.     wseg        Segment value to read from
  1446.  
  1447.     wofs        Offset value to read from
  1448.  
  1449.     EX.
  1450.  
  1451.       if (memb(0x40,0x49) == 3)
  1452.         printf("I detect a color card in this computer!");
  1453.  
  1454. 14. MEMW    Return a word of memory
  1455.  
  1456.     This function returns a word of memory, given a segment
  1457.     pair.
  1458.  
  1459.     wch = memw(wseg,wofs);
  1460.  
  1461.     int wch     word returned from memory
  1462.  
  1463.     wseg        Segment value to read from
  1464.  
  1465.     wofs        Offset value to read from
  1466.  
  1467.     EX.
  1468.  
  1469.       wkeystatus = memw(0x40,0x17); /* get keyboard status word */
  1470.  
  1471. 15. MEML    Return a long of memory
  1472.  
  1473.     This function returns a long of memory, given a segment
  1474.     pair.
  1475.  
  1476.     wlong = meml(wseg,wofs);
  1477.  
  1478.     long wch    long returned from memory
  1479.  
  1480.     wseg        Segment value to read from
  1481.  
  1482.     wofs        Offset value to read from
  1483.  
  1484. 16. MODEMSTS    Return the modem status register
  1485.  
  1486.     This function returns the modem status word from bios.
  1487.  
  1488.     wstatus = modemsts(wport);
  1489.  
  1490.     int wstatus    Returned modem status word. Consult the bios tech
  1491.             ref manual for details.
  1492.  
  1493.     int wport    1 : port 1
  1494.             2 : port 2
  1495.  
  1496. 17. MOVE    Move bytes from one location to another.
  1497.  
  1498.     This routine does a block move in memory of two variables.
  1499.     It does not handle overlap. This routine only handles near
  1500.     objects in the small model compiler.
  1501.  
  1502.     move(wdestin,wsource,wnum);
  1503.  
  1504.     char *wdestin    Pointer to destin buffer. It can be any type of
  1505.             pointer.
  1506.  
  1507.     char *wsource    Pointer to source buffer, It can be any type of
  1508.             pointer.
  1509.  
  1510.     unsigned int
  1511.     wnum        Number of chars to move.
  1512.  
  1513.  
  1514. 18. POKEB    Poke a byte into memory
  1515.  
  1516.     This routine pokes a single byte into a specified memory location
  1517.     by segment,offset.
  1518.  
  1519.     poke(wseg,wofs,wch);
  1520.  
  1521.     int wseg    Segment value to poke into
  1522.  
  1523.     int wofs    Offset value to poke into
  1524.  
  1525.     int wch     Character to poke into memory
  1526.  
  1527.  
  1528. 19. POKEW    Poke a word into memory
  1529.  
  1530.     This routine pokes a single word into a specified memory location
  1531.     by segment,offset.
  1532.  
  1533.     poke(wseg,wofs,wch);
  1534.  
  1535.     int wseg    Segment value to poke into
  1536.  
  1537.     int wofs    Offset value to poke into
  1538.  
  1539.     int wch     Word to poke into memory
  1540.  
  1541. 20. RSPLIST    Create a list from response file
  1542.  
  1543.     This routine creates a linked list of data given a response
  1544.     file on the command line.
  1545.  
  1546.     whead = rsplist(wname);
  1547.  
  1548.     THEAD *whead    Pointer to head of structure. Data type defined
  1549.             in JAZ.H
  1550.  
  1551.     char *wname    File name to create the list from.
  1552.  
  1553. 21. SOUNDOFF    Turn the speaker off
  1554.  
  1555.     This routine turns the sound off after a call to soundon()
  1556.  
  1557.     soundoff();
  1558.  
  1559. 22. SOUNDON    Turn the speaker on
  1560.  
  1561.     This routine "Plays" the speaker at a specific frequency.
  1562.  
  1563.     soundon(whertz);
  1564.  
  1565.     int whertz    Frequency of pitch. 440 = A
  1566.  
  1567.  
  1568.             VIDEO/SCREEN/WINDOWING ROUTINES
  1569.             (ibm or close compatibles only)
  1570.  
  1571. 1.  CLS     Clear the display screen
  1572.  
  1573.     This function clears the display screen to a specified video
  1574.     attribute. This function does not home the cursor. The bit maps
  1575.     for an attribute can be determined based on the following bit
  1576.     pattern:
  1577.  
  1578.     BITS:
  1579.       7    6    5     4     3    2    1      0
  1580.     BLINK,RED,GREEN,BLUE,INTENSITY,RED,GREEN,BLUE
  1581.  
  1582.     The left nibble except for bit 7, pertains to the background,
  1583.     and the right nibble except for bit 3, pertains to the foregound
  1584.     color. These can be combined for any combination.
  1585.  
  1586.     cls(wattribute);
  1587.  
  1588.     int
  1589.     wattribute    The color attribute we want the screen cleared
  1590.             to.
  1591.  
  1592.     EX.
  1593.       cls(7);        /* clear the screen to normal color */
  1594.  
  1595. 2.  COLOR    Change the global color parameters
  1596.  
  1597.     This allows you to change the global foreground and background
  1598.     colors which are used by many of the windowing related routines.
  1599.     You will find various colors defined in JZSCREEN.H The are:
  1600.  
  1601.     BLACK         0
  1602.     BLUE         1
  1603.     GREEN         2
  1604.     CYAN         3
  1605.     RED         4
  1606.     MAGENTA      5
  1607.     BROWN         6
  1608.     LIGHTGRAY     7
  1609.     DARKGRAY     8
  1610.     LIGHTBLUE     9
  1611.     LIGHTGREEN    10
  1612.     LIGHTCYAN    11
  1613.     LIGHTRED    12
  1614.     LIGHTMAGENTA    13
  1615.     YELLOW        14
  1616.     WHITE        15
  1617.     BLINK           128
  1618.  
  1619.     color(wfore,wback);
  1620.  
  1621.     int wfore    The foreground color you wish to set
  1622.  
  1623.     int wback    The background color you wish to set
  1624.  
  1625. 3. JZAPPEND    Append a window to the window list
  1626.  
  1627.     This routine allows you to add a window onto the window list.
  1628.     It does not matter if the list is empty.
  1629.  
  1630.     savescreen = jzappend(&g_header,wattr,y1,x1,y2,x2,wnum);
  1631.  
  1632.     TWINDOW
  1633.     *savescreen    Returned pointer will point to the window structure
  1634.             which contains the dimensions of the window, colors
  1635.             contents, et al.
  1636.  
  1637.     THEADER
  1638.     g_header    This is the header record for the list. It is
  1639.             initialized in gscreen.h. If you want to use
  1640.             more than one window list, you must create your
  1641.             own header record and initialize it yourself.
  1642.  
  1643.     int wattr    This is the color attribute stored for the window.
  1644.  
  1645.     int y1        Upper left row axis
  1646.  
  1647.     int x1        Upper left column axis
  1648.  
  1649.     int y2        Lower right row axis
  1650.  
  1651.     int x2        Lower right column axis
  1652.  
  1653.     int wnum    This is an arbitrary number you assign to the window.
  1654.             After creating the window list, you can do searches
  1655.             on the list by number so it would be a good idea to
  1656.             have a unique number for each window.
  1657.  
  1658. 4. JZBIGLTR    Draw big letters on the screen
  1659.  
  1660.     This routine draws big letters 8 * 8 chars on the screen
  1661.     using the bit mapped character set in rom at address: 0xF000:FA6E.
  1662.     It prints the characters directly to the screen memory for speed.
  1663.  
  1664.     jzbigltr(wch,wrow,wcol,wdrawchr,wattr);
  1665.  
  1666.     int wch     This is the character you want to draw to the screen.
  1667.  
  1668.     int wrow    Row position to write to . 0..24
  1669.  
  1670.     int wcol    Column position to write to 0..79
  1671.  
  1672.     int wdrawchr    This is the character you want to use when drawing.
  1673.             For example, a good char to use on an IBM is 178
  1674.             which appears on the screen as '▓'.
  1675.  
  1676.     int wattr    Color attribute for the screen write.
  1677.  
  1678. 5.  JZBIGSTR    Draw a big string to the screen
  1679.  
  1680.     This routine calls jzbigltr to draw a string to the screen.
  1681.  
  1682.     jzbigstr(wstr,wrow,wcol,wdrawchr,wattr);
  1683.  
  1684.     char *wstr    String we want to display on the screen. There is
  1685.             room for 10 characters on a line.
  1686.  
  1687.     int wrow    Row position to write to . 0..24
  1688.  
  1689.     int wcol    Column position to write to 0..79
  1690.  
  1691.     int wdrawchr    This is the character you want to use when drawing.
  1692.             For example, a good char to use on an IBM is 178
  1693.             which appears on the screen as '▓'.
  1694.  
  1695.     int wattr    Color attribute for the screen write.
  1696.  
  1697. 6.  JZCLREOL    Clear to the end of the line
  1698.  
  1699.     This routine clears the line from the given position to the
  1700.     end of the line.
  1701.  
  1702.     jzclreol(wrow,wcol,wattr);
  1703.  
  1704.     int wrow    Row position to clear from
  1705.  
  1706.     int wcol    Column position to clear from
  1707.  
  1708.     int wattr    Attribute to clear line with
  1709.  
  1710. 7.  JZCLRSCR    Clear the current screen WINDOW
  1711.  
  1712.     This routine clears the ACTIVE window with the colors contained
  1713.     in the global color parameters . (You can change these with a
  1714.     call to color())
  1715.  
  1716.     jzclrscr();
  1717.  
  1718. 8.  JZCLRWND    Change the color of a window
  1719.  
  1720.     This routine allows you to change a windows colors without
  1721.     changing it's contents.
  1722.  
  1723.     jzclrwnd(wwindow,wattr);
  1724.  
  1725.     TWINDOW
  1726.     *wwindow    Pointer to window to change color of. Use wsearch()
  1727.             to return the pointer of a specified window #.
  1728.  
  1729.     int wattr    The new color attribute you wish to change the
  1730.             window to.
  1731.  
  1732. 9.  JZCLSWND    Close the current window
  1733.  
  1734.     Close a window, restore it's previous contents, and free up the
  1735.     memory taken up by the window struct and it's window buffer.
  1736.  
  1737.     wfound = jzclswnd(wnum);
  1738.  
  1739.     int wfound    Returns 1 if window was found, 0 if not found.
  1740.  
  1741.     int wnum    Number of the window to close.
  1742.  
  1743. 10. JZCPYWND    Copy one window to another.
  1744.  
  1745.     This procedure simply copies the window from the specified window
  1746.     number to the destination window.
  1747.  
  1748.     wcopy = jzcpywnd(worig,wnum);
  1749.  
  1750.     TWINDOW
  1751.     *wcopy        Returns pointer to which a new copy of a window is
  1752.             assigned. Null if wnum was not found.
  1753.  
  1754.     TWINDOW
  1755.     *worig        Original window to copy.
  1756.  
  1757.     wnum        Window number to assign the copy.
  1758.  
  1759. 11. JZDELETE    Delete a window from the list.
  1760.  
  1761.     Delete the specified window number from the list.
  1762.  
  1763.     jzdelete(wnum);
  1764.  
  1765.     int wnum    The number of the window which you wish to delete.
  1766.  
  1767. 12. JZDRWBOX    Draw a box to the display screen.
  1768.  
  1769.     This procedure draws a box on the screen like so...
  1770.  
  1771.  ┌────────────────────────────────────────────────────────────────────────────┐
  1772.  │                                          │
  1773.  │                                          │
  1774.  │                                          │
  1775.  │                                          │
  1776.  │                                          │
  1777.  │                                          │
  1778.  │                                          │
  1779.  │                                          │
  1780.  │                                          │
  1781.  └────────────────────────────────────────────────────────────────────────────┘
  1782.  
  1783.     jzdrwbox(wrow,wcol,wlen,wwidth,wattr);
  1784.  
  1785.     int wrow    Starting row position of upper left corner of box
  1786.  
  1787.     int wcol    Starting column position of upper left corner of box
  1788.  
  1789.     int wlen    Length of horizontal axis
  1790.  
  1791.     int wwidth    Width of vertical axis
  1792.  
  1793.     int wattr    Color attribute of the window box.
  1794.  
  1795. 13. JZDSPFLD    Display a field on the screen
  1796.  
  1797.     This routine displays a field at a given row,column position and
  1798.     a given color attribute with a given field width. If the string
  1799.     to be displayed has a length of less than the width, then the
  1800.     string is padded to the right with blanks.
  1801.  
  1802.     jzdspfld(wstr,wlen,wrow,wcol,wattr);
  1803.  
  1804.     char *wstr    String to display in the field.
  1805.  
  1806.     int wlen    Max length of the field.
  1807.  
  1808.     int wrow    Row position of the field
  1809.  
  1810.     int wcol    Column position of the field.
  1811.  
  1812.     int wattr    Color attribute of the field.
  1813.  
  1814. 14. JZGETCUR    Get cursor size and position
  1815.  
  1816.     Return the cursor starting and ending scan lines as well as
  1817.     it's absolute position on the screen.
  1818.  
  1819.     jzgetcur(&wrow,&wcol,&wstart,&wend);
  1820.  
  1821.     int wrow    Pointer to returned row position
  1822.  
  1823.     int wcol    Pointer to returned col position
  1824.  
  1825.     int wstart    Pointer to starting scan line of cursor
  1826.  
  1827.     int wend    Pointer to ending scan line of cursor
  1828.  
  1829. 15. JZGETMOD    Get the current screen mode
  1830.  
  1831.     Return the current screen mode.
  1832.  
  1833.     wmode = jzgetmod();
  1834.  
  1835.     int wmode    The returned mode of the screen.
  1836.  
  1837. 16. JZINSTR    Edit a string with editing keys.
  1838.  
  1839.     This routine provides a formatted editing for a field.
  1840.     It is similar in style to DBASE or WORDSTAR.
  1841.  
  1842.     wkey = instr(wstr,wlen,wrow,wcol,wattr,wtime,wkeystr);
  1843.  
  1844.     int wkey    This is the key that was pressed to end the input.
  1845.             It is usually the return key, but if you have
  1846.             activated other keys using wkeystr, it would be
  1847.             the scan code of an active key.
  1848.  
  1849.     int wlen    Max length of the field.
  1850.  
  1851.     int wrow    Starting row of field edit.
  1852.  
  1853.     int wcol    Starting col of field edit.
  1854.  
  1855.     int wattr    Color attribute of edit field.
  1856.  
  1857.     long wtime    Maximum amount of time with no keys
  1858.             being pressed. Edit will time out after
  1859.             wtime worth of inactivity and a return
  1860.             key is returned.
  1861.  
  1862.     char *wkeystr    String of scan codes to terminate the read on.
  1863.             i.e. If you want to activate the F1 key which
  1864.             would be "\x3B"
  1865.  
  1866.     EX.
  1867.  
  1868.     #define cESC "\001"
  1869.     #define ESCSCAN 1        /* scan code for escape code */
  1870.     main()
  1871.     {
  1872.       int w = 1,wch;
  1873.       char name[31],street[31],city[16],state[3],zip[6],phone[13];
  1874.  
  1875.       name[0] = 0;
  1876.       street[0] = 0;
  1877.       city[0] = 0;
  1878.       state[0] = 0;
  1879.       zip[0] = 0;
  1880.       phone[0] = 0;
  1881.  
  1882.       do {
  1883.         switch(w) {
  1884.           case 1 : wch = jzinstr(name,30,5,8,(CYAN << 4) + BLUE,60L,cESC);
  1885.                break;
  1886.           case 2 : wch = jzinstr(street,30,6,8,(CYAN << 4) + BLUE,60L,cESC);
  1887.                break;
  1888.           case 3 : wch = jzinstr(city,15,7,8,(CYAN << 4) + BLUE,60L,cESC);
  1889.                break;
  1890.           case 4 : wch = jzinstr(state,2,8,8,(CYAN << 4) + BLUE,60L,cESC);
  1891.                break;
  1892.           case 5 : wch = jzinstr(zip,5,9,8,(CYAN << 4) + BLUE,60L,cESC);
  1893.                break;
  1894.           case 6 : wch = jzinstr(phone,12,10,8,(CYAN << 4) + BLUE,60L,cESC);
  1895.                break;
  1896.         }
  1897.  
  1898.         switch (wch) {
  1899.           case CTRL_X :
  1900.           case CTRL_M : w = min(LAST,w+1);
  1901.                 break;
  1902.           case CTRL_E : w = max(FIRST,w-1);
  1903.                 break;
  1904.           case PGDN   : w = LAST;
  1905.                 break;
  1906.           case PGUP   : w = FIRST;
  1907.                 break;
  1908.           case ESCSCAN: return;
  1909.         }
  1910.       } while (-1);
  1911.     }
  1912.  
  1913. 17. JZINTWND    Initialize global window parms
  1914.  
  1915.     Initialize the various window parameters:
  1916.  
  1917.     jzintwnd(wrow1,wcol1,wrow2,wcol2,wattr)
  1918.  
  1919.     int wrow1    Set global upper left row position
  1920.  
  1921.     int wcol1    Set global upper right column position
  1922.  
  1923.     int wrow2    Set global lower right row position
  1924.  
  1925.     int wcol2    Set global lower right column position
  1926.  
  1927.     int wattr    Color attribute to set the window to.
  1928.  
  1929. 18. JZLOCCUR    Position the cursor
  1930.  
  1931.     This function positions the cursor on the display screen.
  1932.     It is an absolute cursor positioning, independant of window
  1933.     dimension.
  1934.  
  1935.     jzloccur(wrow,wcol);
  1936.  
  1937.     int wrow    Row position to set cursor to . 0..24
  1938.  
  1939.     int wcol    Column position to set cursor to . 0..79
  1940.  
  1941. 19. JZMENU    Display a menu on the screen.
  1942.  
  1943.     This routine displays a menu and returns the users choice. The
  1944.     style of menu is similar to the lotus menus where you use the
  1945.     arrow keys to scroll through the choices and select an item
  1946.     by pressing <enter> when that item is highlighted. This routine
  1947.     saves the users screen so that when the item is selected, the
  1948.     screen is restored to it's previous contents and the cursor is
  1949.     brought back to it's original position.
  1950.  
  1951.     wchoice = jzmenu(wlist,wfore,wback,wkeys)
  1952.  
  1953.     int wchoice    Returned value of the choice.
  1954.             0 = option 1
  1955.             1 = option 2
  1956.             2 = option 3
  1957.             etc..
  1958.  
  1959.     char **wlist    Pointer to a pointer of strings to display on
  1960.             the menu.
  1961.  
  1962.     int wfore    Foreground color of menu
  1963.  
  1964.     int wback    Background color of menu
  1965.  
  1966.     EX.
  1967.  
  1968.       char *wlist[] = {
  1969.       "THIS IS A TEST",
  1970.       "OF THE EMERGENCY",
  1971.       "BROADCAST SYSTEM",
  1972.       "IF THIS WERE A",
  1973.       "REAL EMERGENCY" ,
  1974.       "YOU WOULD HAVE",
  1975.       "BEEN NOTIFIED..." ,
  1976.       "WHY AM I TYPING THIS?",
  1977.       ""
  1978.       };
  1979.  
  1980.       #include <jzscreen.h>
  1981.       #include <gscreen.h>
  1982.  
  1983.       #define wkeystr "\x3B\x01"      /* scan codes for F1 and ESC */
  1984.       #define ESC 1           /* scan code for ESC */
  1985.       #define F1  0x3b          /* scan code for F1 */
  1986.  
  1987.       main()
  1988.       {
  1989.         int wchoice;
  1990.  
  1991.         wchoice = jzmenu(wlist,WHITE,BLUE,wkeystr);
  1992.  
  1993.         switch(wchoice) {
  1994.           case ESC : printf("\nThe Esc key was pressed");
  1995.              break;
  1996.           case F1  : printf("\nThe F1 key was pressed");
  1997.              break;
  1998.           default  : printf("\nYou picked item %d",wchoice);
  1999.              break;
  2000.         }
  2001.       }
  2002.  
  2003. 20. JZMOVWND    Move a window on the screen.
  2004.  
  2005.     This routine moves a windows position on the screen. It does
  2006.     NOT restore the previous contents of the original position.
  2007.  
  2008.     jzmovwnd(wptr,wrow,wcol);
  2009.  
  2010.     TWINDOW
  2011.     *wptr        Pointer to window structure to move.
  2012.  
  2013.     wrow        Row position to move window to
  2014.  
  2015.     wcol        Col position to move window to.
  2016.  
  2017. 21. JZOPNWND    Open a window on the screen
  2018.  
  2019.     This routine opens a screen window, drawing the box around the window,
  2020.     clearing the window screen to the selected attributes, and adding
  2021.     the window structure to the window list.
  2022.  
  2023.     wwindow = jzopnwnd(wnum,wrow,wcol,wlen,wwidth,wfore,wback);
  2024.  
  2025.     TWINDOW
  2026.     *wwindow    Returned pointer to window structure just created
  2027.  
  2028.     int wnum    Number to save for this window. This can be set
  2029.             to any number but you should have a unique number
  2030.             for each window you create.
  2031.  
  2032.     int wrow    Starting upper left row position of window.
  2033.  
  2034.     int wcol    Starting upper left col position of window
  2035.  
  2036.     int wwidth    Horizontal length of window
  2037.  
  2038.     int wlen    Vertical Length of window
  2039.  
  2040.     int wfore    Foreground color of window
  2041.  
  2042.     int wback    Background color of window
  2043.  
  2044. 22. JZPGECLR    Clear the given page
  2045.  
  2046.     This routine clears the given page to the specified color attribute.
  2047.  
  2048.     jzpgeclr(wpage,wattr);
  2049.  
  2050.     int wpage    A valid page number. On the CGA adapter card, this
  2051.             would be 0..3. There is only one page on the Mono
  2052.             card.
  2053.  
  2054.     int wattr    Color attribute to clear the screen to.
  2055.  
  2056. 23. JZPGEPRN    Print directly to a page
  2057.  
  2058.     This routine prints a string directly to video memory on
  2059.     the specified page number. This should not be used on a
  2060.     monochrome adapter.
  2061.  
  2062.     jzpgeprn(wstr,wrow,wcol,wattr,wpage);
  2063.  
  2064.     char *wstr    String pointer to print to the given page
  2065.  
  2066.     int wrow    Row position relative to page top to print to
  2067.  
  2068.     int wcol    Col position relative to page top to print to
  2069.  
  2070.     int wattr    Color attribute use when printing.
  2071.  
  2072.     int wpage    A valid page number. 0..3
  2073.  
  2074. 24. JZPLOT    Plot a dot to the graphics screen
  2075.  
  2076.     This function plots a pixal to the color graphics screen.
  2077.  
  2078.     jzplot(wrow,wcol,wattr);
  2079.  
  2080.     int wrow    Row position of pixel to plot
  2081.  
  2082.     int wcol    Col position of pixel to plot
  2083.  
  2084.     int wattr    Color attribute to plot dot with
  2085.  
  2086. 25. JZREDCHR    Read a char and attribute from screen
  2087.  
  2088.     This function reads a character and attribute from the current
  2089.     cursor position
  2090.  
  2091.     jzredchr(&wch,&wattr);
  2092.  
  2093.     int wch     Pointer to the returned character.
  2094.  
  2095.     int wattr    Pointer to the returned attribute
  2096.  
  2097. 26. JZREDSCR    Read a string from the screen.
  2098.  
  2099.     This function returns a string from a given screen position. It
  2100.     does not return attributes.
  2101.  
  2102.     jzredscr(wstr,wrow,wcol,wlen);
  2103.  
  2104.     char *wstr    Pointer to the string to be returned.
  2105.  
  2106.     int wrow    Starting row position to read from screen.
  2107.  
  2108.     int wcol    Starting col position to read from screen.
  2109.  
  2110.     int wlen    Length of string to read from screen.
  2111.  
  2112. 27. JZRSTWND    Restore a windows contents
  2113.  
  2114.     This routine restores a windows contents without removing the
  2115.     window from the window list.
  2116.  
  2117.     jzrstwnd(wwindow);
  2118.  
  2119.     TWINDOW
  2120.     *wwindow    Pointer to window to restore contents of
  2121.  
  2122. 28. JZSAVWND    Save a windows contents
  2123.  
  2124.     Save a windows contents into an existing window structure. The
  2125.     window buffer is NOT resized so if you change sizes of windows,
  2126.     be careful to realloc() the window buffer before calling this
  2127.     routine. This routine is useful during window moves.
  2128.  
  2129.     jzsavwnd(wwindow);
  2130.  
  2131.     TWINDOW
  2132.     *wwindow    Pointer to existing window struct to save.
  2133.  
  2134. 29. JZSCRLDN    Scroll a window down
  2135.  
  2136.     This routine calls bios to scroll a window down on the screen.
  2137.  
  2138.     jzscrldn(wyx1,wyx2,wnum,wattr);
  2139.  
  2140.     int wyx1    This integer contains the upper left row position
  2141.             of the window in the high byte and the upper left
  2142.             column position in the low byte.
  2143.  
  2144.     int wyx2    This integer contains the lower right row position
  2145.             of the window in the high byte and the lower right
  2146.             column position in the low byte.
  2147.  
  2148.     int wnum    Number of lines to scroll. At maximum, this number
  2149.             should be Y2 - Y1. Specify 0 to scroll the whole
  2150.             window, effectively clearing it. Specifying :
  2151.             Y2 - Y1 + 1, which is the actual number of lines
  2152.             in the window will garble up the screen on an
  2153.             IBM pc.
  2154.  
  2155. 30. JZSCRLUP    Scroll a window up
  2156.  
  2157.     This routine calls bios to scroll a window up on the screen.
  2158.  
  2159.     jzscrlup(wyx1,wyx2,wnum,wattr);
  2160.  
  2161.     int wyx1    This integer contains the upper left row position
  2162.             of the window in the high byte and the upper left
  2163.             column position in the low byte.
  2164.  
  2165.     int wyx2    This integer contains the lower right row position
  2166.             of the window in the high byte and the lower right
  2167.             column position in the low byte.
  2168.  
  2169.     int wnum    Number of lines to scroll. At maximum, this number
  2170.             should be Y2 - Y1. Specify 0 to scroll the whole
  2171.             window, effectively clearing it. Specifying :
  2172.             Y2 - Y1 + 1, which is the actual number of lines
  2173.             in the window will garble up the screen on an
  2174.             IBM pc.
  2175.  
  2176. 31. JZSCROFF    Disable the video screen (DO NOT USE WITH HERCULES CARDS)
  2177.  
  2178.     This disables the video signal to the screen, blanking (but not
  2179.     clearing) the display screen. This routine has been known to
  2180.     cause hardware damage to certain non - ibm video cards. I am
  2181.     not responsible if this happens to you!
  2182.  
  2183.     jzscroff();
  2184.  
  2185. 32. JZSCRON    Enable the video screen (DO NOT USE WITH HERCULES CARDS)
  2186.  
  2187.     This routine enables the video signal to the screen. Restoring
  2188.     it's previous contents. This routine has been known to
  2189.     cause hardware damage to certain non - ibm video cards. I am
  2190.     not responsible if this happens to you!
  2191.  
  2192.     jzscron();
  2193.  
  2194. 33. JZSCRPRN    Print directly to video memory
  2195.  
  2196.     This routine allows you to print directly to video memory
  2197.     specifying row,column and color. It also avoids snow on the
  2198.     ibm CGA card. It is a very fast routine, about 10 times faster
  2199.     than printf().
  2200.  
  2201.     jzscrprn(wstr,wrow,wcol,wattr);
  2202.  
  2203.     char *wstr    String to print to screen.
  2204.  
  2205.     int wrow    Row to print to
  2206.  
  2207.     int wcol    Column to print to
  2208.  
  2209.     int wattr    Color attribute to use when printing.
  2210.  
  2211. 34. JZSETCUR    Set the cursors size
  2212.  
  2213.     This routine allows you to adjust the cursors starting and
  2214.     ending scan lines. The cursor is mapped as follows:
  2215.  
  2216. Default Scan         Monochrome             Color
  2217.  
  2218.         0  . . . . . . . .           . . . . . . . .
  2219.         1  . . . . . . . .           . . . . . . . .
  2220.         2  . . . . . . . .           . . . . . . . .
  2221.         3  . . . . . . . .           . . . . . . . .
  2222.         4  . . . . . . . .           . . . . . . . .
  2223.         5  . . . . . . . .           . . . . . . . .
  2224.         6  . . . . . . . .    Start    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2225.         7  . . . . . . . .    End      ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2226.         8  . . . . . . . .
  2227.         9  . . . . . . . .
  2228.            10  . . . . . . . .
  2229. Start           11  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2230. End           12  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  2231.  
  2232.  
  2233.     jzsetcur(wstart,wend);
  2234.  
  2235.     int wstart    Starting scan line of cursor
  2236.  
  2237.     int wend    Ending scan line of cursor
  2238.  
  2239. 35. JZSETMDE    Set the screen mode
  2240.  
  2241.     Set the current screen mode.
  2242.  
  2243.     jzsetmde(wmode);
  2244.  
  2245.     int wmode    Valid screen mode.
  2246.  
  2247. 36. JZSETPGE    Activate a page
  2248.  
  2249.     This function activates a page of video memory.
  2250.  
  2251.     jzsetpge(wpage);
  2252.  
  2253.     int wpage    A page of CGA memory to activate. 0..3
  2254.  
  2255. 37. JZWNDASN    Assign values to a window structure
  2256.  
  2257.     This internal routine (used by jzappend) is a convenient way
  2258.     of assigning values to a window structure.
  2259.  
  2260.     jzwndasn(wwindow,wrow,wcol,wattr,wnum,wy1,wx1,wy2,wx2);
  2261.  
  2262.     TWINDOW
  2263.     *wwindow    Pointer to window to assign values to
  2264.  
  2265.     wrow        Row position to assign
  2266.  
  2267.     wcol        Col position to assign
  2268.  
  2269.     wattr        Attribute to assign
  2270.  
  2271.     wnum        Window number to assign
  2272.  
  2273.     wy1        Upper left row to assign
  2274.  
  2275.     wx1        Upper left col to assign
  2276.  
  2277.     wy2        Lower right row to assign
  2278.  
  2279.     wx2        Lower right col to assign
  2280.  
  2281. 38. JZWRITE    Write to the current window
  2282.  
  2283.     This function writes a string to the current window in the
  2284.     using the global color and window parameters.
  2285.  
  2286.     jzwrite(fstr);
  2287.  
  2288.     char *wstr    String to write
  2289.  
  2290. 39. JZWRTCHR    Write a char to the screen using bios
  2291.  
  2292.     This function writes a char to the screen using bios.
  2293.  
  2294.     jzwrtchr(wch,wattr,wnum);
  2295.  
  2296.     int wch     Character to write
  2297.  
  2298.     int wattr    Color attribute of char
  2299.  
  2300.     int wnum    Number of copies to write
  2301.  
  2302. 40.  JZWRTSTR    Write a string using bios
  2303.  
  2304.     This routine writes a string to the screen using the bios
  2305.     jzwrtchr call.
  2306.  
  2307.     jzwrtstr(wstr,wrow,wcol,wattr);
  2308.  
  2309.     char *wstr    String to write to screen.
  2310.  
  2311.     int wrow    Row to write to
  2312.  
  2313.     int wcol    Column to write to
  2314.  
  2315.     int wattr    Color attribute to use when writing.
  2316.  
  2317. 41. LOCATE    Position the cursor in the window
  2318.  
  2319.     This routine positions the cursor relative to the active window.
  2320.  
  2321.     locate(wrow,wcol);
  2322.  
  2323.     int wrow    Row position of cursor in the window
  2324.  
  2325.     int wcol    Col position of cursor in the window
  2326.  
  2327. 42. MOVEATTR    Move attributes to a screen window
  2328.  
  2329.     This routine move attributes only to a screen window which
  2330.     allows you to change the color of a window without affecting
  2331.     it's contents and avoiding snow.
  2332.  
  2333.     moveattr(wscreenseg,woffset,wnumrows,wnumcols,wattr);
  2334.  
  2335.     int
  2336.     wscreenseg    Segment address of active screen. Should be
  2337.             0xb800 for color, 0xb000 for mono.
  2338.  
  2339.     int woffset    Offset of screen position. Computed by
  2340.             row * 160 + (col << 1)
  2341.  
  2342.     int wnumrows    Number of rows in window
  2343.  
  2344.     int wnumcols    Number of cols in window
  2345.  
  2346.     int wattr    Attribute color of window
  2347.  
  2348. 43. MOVEB    Move a screen window to a buffer
  2349.  
  2350.     Internal routine (see jzsavwnd) to move screen memory to a
  2351.     buffer avoiding snow.
  2352.  
  2353.     moveb(wscreenseg,woffset,wbufseg,wbufofs,wnumrows,wnumcols);
  2354.  
  2355.     int
  2356.     wscreenseg    Segment address of active screen. Should be
  2357.             0xb800 for color, 0xb000 for mono.
  2358.  
  2359.     int woffset    Offset of screen position. Computed by
  2360.             row * 160 + (col << 1)
  2361.  
  2362.     int wbufseg    Segment address of destination buffer. getds()
  2363.             can be used here usually.
  2364.  
  2365.     int wbufofs    Offset address of buffer.
  2366.  
  2367.     int wnumrows    Number of rows in window
  2368.  
  2369.     int wnumcols    Number of cols in window
  2370.  
  2371. 44. MOVES    Move a buffer to screen memory
  2372.  
  2373.     This routine moves a buffer to a screen window avoiding snow.
  2374.  
  2375.     moves(wbufseg,wbufofs,wscreenseg,woffset,wnumrows,wnumcols);
  2376.  
  2377.     int wbufseg    Segment address of destination buffer. getds()
  2378.             can be used here usually.
  2379.  
  2380.     int wbufofs    Offset address of buffer.
  2381.  
  2382.     int
  2383.     wscreenseg    Segment address of active screen. Should be
  2384.             0xb800 for color, 0xb000 for mono.
  2385.  
  2386.     int woffset    Offset of screen position. Computed by
  2387.             row * 160 + (col << 1)
  2388.  
  2389.     int wnumrows    Number of rows in window
  2390.  
  2391.     int wnumcols    Number of cols in window
  2392.  
  2393. 45. WINDOW    Set the window dimensions
  2394.  
  2395.     This routine allows you to set the global window dimensions which
  2396.     are used for the various window write, and cursor positioning
  2397.     routines.
  2398.  
  2399.     window(wrow1,wcol1,wrow2,wcol2);
  2400.  
  2401.     int wrow1    Value to set upper left row
  2402.  
  2403.     int wcol1    Value to set upper left col
  2404.  
  2405.     int wrow2    Value to set lower right row
  2406.  
  2407.     int wcol2    Value to set lower right col
  2408.  
  2409. 46. WPRINTF    Printf function relative to window
  2410.  
  2411.     This routine provides for a printf that allows color and relativity
  2412.     to the current window dimension. It handles all data types except
  2413.     float. It does not allow redirection.
  2414.  
  2415.     wprintf("\n%d %c %s",wint,wchar,wstring);
  2416.  
  2417.     int wint    Sample integer
  2418.  
  2419.     int wchar    Sample char
  2420.  
  2421.     int wstring    Sample string
  2422.  
  2423. 47. WSEARCH    Search for a window
  2424.  
  2425.     Search for a specified window number and return it's pointer
  2426.  
  2427.     wptr = wsearch(wnum);
  2428.  
  2429.     TWINDOW
  2430.     *wptr        Returned pointer to window structure. Should be
  2431.             checked for null in case window is not found
  2432.  
  2433.     int wnum    Number of the window to search for.
  2434.  
  2435.  
  2436.                 KEYBOARD ROUTINES
  2437.  
  2438. 1.  JZINKEY    Return the char and scan code of a key
  2439.  
  2440.     This routine waits until a key is pressed and returns
  2441.     it's character and scan code. The character can be
  2442.     examined and if it is 0, the key was one of the special
  2443.     function keys, cursor keys, alt sequences, or shift sequences.
  2444.  
  2445.     wch = jzinkey(&wscan);
  2446.  
  2447.     int wch     Returned character that was pressed
  2448.  
  2449.     int wscan    Scan code of character that was pressed.
  2450.  
  2451. 2.  JZKEYPRS    Return 1 if a key is waiting
  2452.  
  2453.     This routine determines whether a key was pressed by calling
  2454.     a bios function to see whether a key is in the keyboard buffer.
  2455.  
  2456.     wkeypressed = jzkeyprs();
  2457.  
  2458.     int
  2459.     wkeypressed    Returns 1 if a key is pressed, otherwise 0
  2460.  
  2461. 3.  JZKEYSTS    Return the keyboard status record
  2462.  
  2463.     This routine returns a keyboard status record which can be looked
  2464.     at to determine which special keys are down such as insert, caps-lock,
  2465.     num-lock etc.
  2466.  
  2467.     jzkeysts(&wkey);
  2468.  
  2469.     TKEY wkey    Pointer to record containing key status info.
  2470.  
  2471.  
  2472.     EX.
  2473.  
  2474.       #include <jaz.h>
  2475.  
  2476.     main()
  2477.     {
  2478.       KEYSTATE wkey;
  2479.  
  2480.       jzkeysts(&wkey);    /* get key status */
  2481.  
  2482.       if (wkey.s.capslock)
  2483.         printf("\nCaps lock is on!");
  2484.     }
  2485.  
  2486. 4.  JZPUTKBD    Write chars to the keyboard buffer
  2487.  
  2488.     This function is capable of writing a string to the keyboard
  2489.     buffer. A maximum of 16 chars will be written.
  2490.  
  2491.     jzputkbd(wstr);
  2492.  
  2493.     char *wstr    String of chars to be written. If an extended char
  2494.             is to be written to the buffer, proceed it's scan code
  2495.             with a \xFF. i.e. jzputkbd("\xFF\x3B") would put
  2496.             the F1 key in the buffer. (0x3b is the scan code for
  2497.             the F1 key)
  2498.  
  2499.  
  2500.                    MISC MACROS
  2501.  
  2502. 1. LPOINTER    Gain access to far memory locations.    (JAZ.H)
  2503.  
  2504.     This macro allows access to far memory locations for useful
  2505.     in hardware intensize applications.
  2506.  
  2507.     wch = LPOINTER(char , wseg , wofs);
  2508.  
  2509.     char *wch    Pointer to whatever type is specified
  2510.  
  2511.     type char    This would be any valid type
  2512.  
  2513.     int wseg    Segment value to get pointer for
  2514.  
  2515.     int wofs    Offset value to get pointer for
  2516.  
  2517. 2.  MEMB    Gain access to far char locations    (JAZ.H)
  2518.  
  2519.     This macro allows access to far memory locations.
  2520.  
  2521.     wch = MEMB(wseg,wofs);
  2522.  
  2523.     int wch     Value returned from pointer
  2524.  
  2525.     int wseg    Segment value to point to
  2526.  
  2527.     int wofs    Offset value to point to
  2528.  
  2529. 3.  MEMW    Gain access to far word locations    (JAZ.H)
  2530.  
  2531.     This macro allows access to far memory locations.
  2532.  
  2533.     wch = MEMW(wseg,wofs);
  2534.  
  2535.     int wch     Value returned from pointer
  2536.  
  2537.     int wseg    Segment value to point to
  2538.  
  2539.     int wofs    Offset value to point to
  2540.  
  2541. 4.  MEML    Gain access to far long locations    (JAZ.H)
  2542.  
  2543.     This macro allows access to far memory locations.
  2544.  
  2545.     wch = MEML(wseg,wofs);
  2546.  
  2547.     long wch     Value returned from pointer
  2548.  
  2549.     int wseg    Segment value to point to
  2550.  
  2551.     int wofs    Offset value to point to
  2552.  
  2553. 5. SCROFS    Convert row and column position to a screen offset (JZSCREEN.H)
  2554.  
  2555.     This macro converts row and column to an absolute screen offset.
  2556.  
  2557.     wofs = SCROFS(wrow,wcol);
  2558.  
  2559.     int wofs    Returned offset
  2560.  
  2561.     int wrow    row position
  2562.  
  2563.     int wcol    Column position
  2564.  
  2565. 6.  MKATTR    Make a color attribute given fore and back ground. (JZSCREEN.H)
  2566.  
  2567.     This macro converts a foreground and background color to a video
  2568.     attribute useful in many of the screen functions.
  2569.  
  2570.     wattr = MKATTR(wback,wfore);
  2571.  
  2572.     int wattr    Returned video attribute
  2573.  
  2574.     int wback    Background color
  2575.  
  2576.     int wfore    Foreground color
  2577.  
  2578. 7.  CNTCOL    Centering fields  (JZSCREEN.H)
  2579.  
  2580.     This macro returns a column position with which to center a string
  2581.     in a given width.
  2582.  
  2583.     wcol = CNTCOL(wstr,wwidth);
  2584.  
  2585.     int wcol    Returned centered column
  2586.  
  2587.     char *wstr    String to provide centered column for
  2588.  
  2589.     int wwidth    Width of field.
  2590.  
  2591. 8.  CLEARKBD    Clear the keyboard buffer  (KEYS.H)
  2592.  
  2593.     This macro clears the keyboard buffer
  2594.  
  2595.     CLEARKBD
  2596.  
  2597. 9.  MSDOS    Provide an msdos function.    (JAZ.H)
  2598.  
  2599.     This macro simulates the msdos call like in Turbo Pascal.
  2600.  
  2601.     MSDOS(&wreg);
  2602.  
  2603.     TREG wreg    Pointer to structure of a register record.
  2604.  
  2605.  
  2606.                 DEMO PROGRAMS
  2607. Note:
  2608.   When compiling and linking these routines, make sure to use a compile spec
  2609.   similar to this :
  2610.   \msc\msc /Ox /Ze /Zp /I c:\msc\jaz %1/DLINT_ARGS;
  2611.  
  2612.   The "/Ze","/Zp" are absolutely neccessary for many of these programs.
  2613.  
  2614.   The link spec is not as critical (see link.bat) but many of the routines
  2615.   require a larger stack than the default. (Especially the interrupt handlers)
  2616.   Failure to use a large enough stack will result in the system hanging in
  2617.   many cases.
  2618.   -Jaz
  2619.  
  2620. 1.  BADSECT    Check and List bad sectors on A:
  2621.  
  2622. 2.  COPYFILE    Copy one file to another. Wildcards are supported.
  2623.         The syntax is COPYFILE <source spec> <destin spec>
  2624.  
  2625. 3.  DIRLST    Demonstration of a disk directory places in a binary
  2626.         tree and printed out. Use "/st:12000" when linking
  2627.  
  2628. 4.  JAZPRINT    Print multiple files with formatting. Demo of directory
  2629.         routines as well as buffer stream printing.
  2630.         formatting options.
  2631.        -d specifies double strike printing
  2632.        -e specifies emphasized printing
  2633.        -t specifies title of document + time and date
  2634.        -w specifies wide (compressed) listing
  2635.        -n specifies to number the lines
  2636.        -u specifies user chars to send (in hex). i.e jazprint *.* -u 1b471b45
  2637.        -mn specifies multiple copies where n is the number of copies
  2638.  
  2639. 5.  JZBACKGR    This program plays a dumb tune in the background of a
  2640.         DBASE like editing screen. It is a good demo of interrupt
  2641.         handlers, Input screens, and the sound routines.
  2642.  
  2643. 6.  JZBIGLTR    Demonstration of big printing.
  2644.  
  2645. 7.  JZCHKDSK    Program is similar to chkdsk but with many option. It will
  2646.         report on contiguous files/non contiguous files, bad sectors,
  2647.         etc. Link with "/ST:12000"
  2648.         Usage: JZCHKDSK <Options> <Path>
  2649.         Options: -c   List contiguous files
  2650.              -n   List non - contiguous files only
  2651.              -q   Quiet mode. Don't list files at all
  2652.              -b   List Bad Sectors
  2653.  
  2654. 8.  JZCLOCK    This program puts a resident clock on the screen in the upper
  2655.         right hand corner. It takes up a LOT of memory but is mainly
  2656.         a demo just to prove it can be done in MS-C. When I have 4.0,
  2657.         I will probably be able to significantly reduce the size of
  2658.         the resident code. Must be linked with "/ST:12000"
  2659.  
  2660. 9.  JZDIR    Incomplete demo of directly reading disk directory sectors.
  2661.  
  2662. 10. JZDIRLST    Demo of sorted directory with binary tree. Link with
  2663.         "/st:12000"
  2664.  
  2665. 11. JZEDTCHR    Demonstration of how to access the character set in rom.
  2666.         This routine allows you to edit and change the upper
  2667.         128 characters and install a pointer to your buffer. Use
  2668.         font.chr (a sample script char set) and have fun. Link
  2669.         with "/st:12000"
  2670.  
  2671. 12. JZFIND    This program finds files across sub-directories. It supports
  2672.         wild-cards in the file searches. i.e. jzfind *.doc
  2673.  
  2674. 13. JZMENU    Incomplete demo of menu routines and menu drivers.
  2675.  
  2676. 14. MENU    Simple demo of the jzmenu() function.
  2677.  
  2678. 15. JZPSHDIR    Demonstration of the jzpshdir,jzpopdir. This routine expects
  2679.         an A drive, B drive and C drive with the b:drive having a
  2680.         subdirectory named test. This routine simply does a few
  2681.         directory changes , pushing the dirs beforehand and poping
  2682.         them back to change directories and drives.
  2683.  
  2684. 16. JZPUSH    Simple demo of data conversion using jzpush and jzpop.
  2685.  
  2686. 17. JZPUTKBD    Demonstration of the jzputkbd routine allowing characters
  2687.         to be "written" to the keyboard buffer on IBM and close
  2688.         compatibles.
  2689.  
  2690. 18. JZSCREEN    Demo of big letters. Prints command line on screen.
  2691.  
  2692. 19. JZSEARCH    Search multiple files for the occurance of strings.
  2693.  
  2694.        Usage JZSEARCH [-uwcr] [filespec] [search string\\replace string]
  2695.        Options are as follows:\n");
  2696.        -u           Uppercase (Ignores case on search)
  2697.        -c           Display files on console
  2698.        -w           Whole words only. "MEM" won't be found in "MEMORY"
  2699.        -r           Replace string if found. Syntax for this is:"
  2700.        -p           Prompt for change before replacing
  2701.  
  2702. 20. JZSETATR    Allows setting attributes of files. Supports wildcards.
  2703.         Syntax is JZSETATR <file spec> <attribute>
  2704.  
  2705. 21. POPDIR    Stand alone popdir program. Uses a virtual stack technique.
  2706.  
  2707. 22. PUSHDIR    Stand alone pushdir program. Uses a virtual stack technique.
  2708.  
  2709. 23. RENFILE    Allows renaming of files across subdirecties. Allows
  2710.         wildcards. This one is not thouroghly tested yet so
  2711.         make sure you have a backup before proceeding here!
  2712.  
  2713.         USAGE:      renfile <old path\\old name> <new path>
  2714.  
  2715. 24. SCREEN    Demo of various screen and window related functions.
  2716.         This program is obsolete. Do NOT compile it. Run only
  2717.         if you received the executable along with the source.
  2718.         Calling conventions of many of the routines have changed
  2719.         since this was written.
  2720.  
  2721. 25. TRUNCFIL    Demo program to truncate a file. You specify the file name,
  2722.         the original size, and the new size.
  2723.  
  2724. 26. VIEW    This is a read only edit that saves the users screen before
  2725.         running. This means when you exit, your screen will appear
  2726.         just as it did before this program was run.
  2727.  
  2728. 27. WINDOW    This program demonstrates many of the screen and windowing
  2729.         functions available in the system. However the window moving
  2730.         is not very smooth at this point. I will be working on that
  2731.         very soon.
  2732.  
  2733.  
  2734.  
  2735.