* * ADDBLOCK.KEX * * KEXX macro to sum the numbers in the currently marked box block and write * the result at the cursor position. * * Works with: * * KEDIT for Windows 1.5 * KEDIT 5.0 for DOS * KEDIT 5.0 for OS/2 * if block.1() = 'NONE' then do 'emsg ADDBLOCK Error 1: You forgot to mark a box block' exit 1 end if block.1() \= 'BOX' then do 'emsg ADDBLOCK Error 2: ADDBLOCK works with box blocks only' exit 2 end if \block() then do 'emsg ADDBLOCK Error 3: Box block must be in current file' exit 3 end sum = 0 LineNum = line.1() "sos save" 'sos blockstart' size = block.4() - block.2() + 1 do size number = substr(curline.3(), block.3(), block.5() - block.3() + 1) if number = ' ' then do 'down 1' iterate end if datatype(number) \= 'NUM' then do 'emsg ADDBLOCK Error 4: Invalid KEXX number... ['number']' exit 4 end sum = sum + number 'down 1' end ':'LineNum "sos restore" 'text' sum