Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper Tools . Books 1-3 - <b>xmoblock()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 XMOBLOCK()
 Generates a block for XMODEM transmission
------------------------------------------------------------------------------
 Syntax

     XMOBLOCK(<cString>,<nBlockNumber>,[<lCRC>],
        [<nMode>]) --> cXModemBlock

 Arguments

     <cString>  Designates a character string of 128 or 1024 (depending
     on <nMode>) characters.  Excess characters are cut off; missing
     characters are filled with CHR(0).

     <nBlockNumber>  Designates the related block number.

     <lCRC>  Designates whether an XMODEM block is to be formed with a
     checksum (.F.) or with a 16-bit CRC (.T.).  The default value (.F.) is a
     checksum.

     <nMode>  Designates different block types.  Mode 1 designates a 128
     byte block with start character CHR(1).  Mode 2 designates a 1kByte
     block with start character CHR(2).  The default value is a mode 1, 128
     byte block.

 Returns

     This function returns an XMODEM block that is "ready to go".

 Description

     This function generates a data block according to XMODEM conventions,
     which can then be output directly using COM_SEND().  The block number
     and the packet verification procedure that you choose can be designated.
     The function automatically takes into account the fact that after block
     number 255, XMODEM waits for 0 again (block number %256).  So you can go
     as high as you like with your variables.

     An X-MODEM block has the following construction:

     SOH+<BN>+<Complement of BN>+128 data bytes+1 byte CS
     or:
     SOH+<BN>+<Complement of BN>+128 data bytes+2 byte CRC


     This is the construction for a 1k byte block:

     STX+<BN>+<Complement of BN>+1024 data bytes+1 byte CS
     or:
     STX+<BN>+<Complement of BN>+1024 data bytes+2 byte CRC

     BN = Block number, CS = checksum, and CRC = Cyclic Redundancy Check.

 Notes

     .  Verification of the 8-bit checksum corresponds to the
        NUMLOW(ASCII-SUM(Data)) function call.

     .  A programming sample using XMODEM protocols under CA-Clipper
        can be found in the following example program.

 Example

     This is an example of a simplified XMODEM transfer.  Initialization of
     the port is assumed:

     nBlockNum := 0                       // 1st block
     lChkMode  := .T.                     // Use CRC
     nBlkSize  := 128                     // XMODEM block size
     nPointer  := 0                       // Start point in file

     cData  := FILESTR("TEST.TXT", nBlkSize, nPointer)// Read data

     DO WHILE LEN(cData) > 0
        COM_SEND;
        (1, XMOBLOCK(cData, nBlockNum, lChkMode))   // Send block
        nBlockNum := nBlockNum +1                   // Next block
        nPointer  := nPointer  +nBlkSize            // File pointer
        cData     := FILESTR;
        ("TEST.TXT", nBlkSize, nPointer)            // Read data
     ENDDO


See Also: COM_CRC()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson