Function XMoBlock() Foundation

Builds a block for the XModem protocol.

Syntax
XMoBlock( <cString>     , ;
          <nBlocknumber>, ;
          [<lCRC>]      , ;  // Default: .F.
          [<nMode>]       ;  // Default: 1
        ) --> cXModemBlock
Return

Returns an XModem block if the block could be built or a null string ("") in case of an error.

Description

Parameters:

<cString> the string to be put in the block. If the string contains less than 128 (1024) bytes it will be padded with CHR(0) bytes. If it contains more than 128 (1024) bytes it will be truncated to the appropriate length.
<nBlocknumber> the number of the block
<lCRC> if .T. 16-bit CRC will be used otherwise a 8-bit checksum will be used
<nMode> specifies the block length

1 -> 128-byte blocks

2 -> 1024-byte blocks

128-byte-blocks

----------------

Each block of the transfer in checksum mode looks like:

<SOH><blk #><255-blk #><--128 data bytes--><cksum> 

in which: 
<SOH>         = 01 hex 
<blk #>       = binary number, starts at 01 increments by 1, and 
                wraps 0FFH to 00H (not to 01) 
<255-blk #>   = blk # after going thru 8080 "CMA" instr, i.e. 
                each bit complemented in the 8-bit block number. 
                Formally, this is the "ones complement". 
<cksum>       = the sum of the data bytes only.  Toss any carry. 

Each block of the transfer in CRC mode looks like:

<SOH><blk #><255-blk #><--128 data bytes--><CRC hi><CRC lo> 

in which: 
<SOH>        = 01 hex 
<blk #>      = binary number, starts at 01 increments by 1, and 
               wraps 0FFH to 00H (not to 01) 
<255-blk #>  = ones complement of blk #. 
<CRC hi>     = byte containing the 8 high order coefficients 
               of the CRC. 
<CRC lo>     = byte containing the 8 low order coefficients 
               of the CRC. 

1024-byte-blocks

-----------------

Each block of the transfer in checksum mode looks like:

<STX><blk #><255-blk #><--1024 data bytes--><cksum> 

<STX>         = 02 hex 
<blk #>       = binary number, starts at 01 increments by 1, and 
                wraps 0FFH to 00H (not to 01) 
<255-blk #>   = blk # after going thru 8080 "CMA" instruction, i.e. 
                each bit complemented in the 8-bit block number. 
                Formally, this is the "ones complement". 
<cksum>       = the sum of the data bytes only.  Toss any carry. 

Each block of the transfer in CRC mode looks like:

<STX><blk #><255-blk #><--1024 data bytes--><CRC hi><CRC lo> 

in which: 
<STX>        = 02 hex 
<blk #>      = binary number, starts at 01 increments by 1, and 
               wraps 0FFH to 00H (not to 01) 
<255-blk #>  = ones complement of blk #. 
<CRC hi>     = byte containing the 8 high order coefficients 
               of the CRC. 
<CRC lo>     = byte containing the 8 low order coefficients 
               of the CRC. 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.