
|
INFO - FAQ - CC2-Forum - CCPro-Forum |
|
'-------------------------------------------------------------------------------------------------------------------------' ' *************************************************************************************************' ' * WINDT SYSTEMS *' ' * INPUT BUG WORKAROUND v1.21 for the C-Control 1 Unit M2.01 *' ' * H.J. WINDT *' ' * 2004 *' ' *************************************************************************************************' '-------------------------------------------------------------------------------------------------------------------------' 'This program works around the input bug of the CC1 U M2.01.' 'Via a terminal program variables can be entered in 4 different codes -- decimal, binary, hex and ascii.' 'Download the RS232 TERMINAL at www.b-kainka.de/pcmessfaq.htm' 'Decimal, type in the positive or negative number and press enter, exam. 1234 or -1234 'Binary, type &b or &B and then the binary code and press enter, exam. &b1010101010101010 or &B1010101010101010 'Hex, type &h or &H and then the hex code and press enter, exam &hffff or &HFFFF 'Ascii, type &a or &A and then the letter, number or symbol, exam. &ah or &Ah, gives the ascii code for h.' 'There is no difference for upper and lower case letters for hex codes, exam. &hF = dec 15 and &hf = dec 15.' ' 'Feel free to use and share this software in any way you want!' '****************************************************** VARIABLES ********************************************************' define data word[1] define number word[2] define digit byte[5] '*************************************************************************************************************************' #start print" Enter Number" gosub input_number_via_232 print"number recieved =" print number goto start #input_number_via_232 number = 0 digit = 0 get data 'get 8 bit ascii code' if data = 8 then goto input_number_via_232 'look for ascii code for if data = 13 then return 'look for ascii code for if data = 38 then goto check_for_hex_or_bin_or_ascii 'look for ascii code for <&>' if data = 45 then goto input_negative_dec 'look for ascii code for <->' #input_positive_dec digit = digit + 1 data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number * 10 + data else number = data 'build number' #input_positive_backspace_loop get data 'get 8 bit ascii code' if data = 8 then number = number / 10 'debuild nuumber if ascii code for if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if no more digits are displayed' if data = 8 then goto input_positive_backspace_loop if data = 13 then return 'look for ascii code for goto input_positive_dec #input_negative_dec digit = digit + 1 #input_negative_backspace_loop get data 'get 8 bit ascii code' if data = 8 then number = number / 10 'debuild nuumber if ascii code for if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if <-> is no longer displayed' if data = 8 then goto input_negative_backspace_loop if data = 13 then number = number * -1 'look for ascii code for if data = 13 then return 'look for ascii code for data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number * 10 + data else number = data 'build number' goto input_negative_dec #check_for_hex_or_bin_or_ascii digit = digit + 1 #check_for_hex_or_bin_or_ascii_loop get data 'get 8 bit ascii code' if data = 8 then digit = digit - 1 if digit = 0 then goto input_number_via_232 'go back if <&> is no longer displayed' if data = 8 then goto check_for_hex_or_bin_or_ascii_loop if data = 98 then goto input_binary 'look for ascii code for ' if data = 66 then goto input_binary 'look for ascii code for ' if data = 104 then goto input_hex 'look for ascii code for if data = 72 then goto input_hex 'look for ascii code for if data = 97 then goto input_ascii 'look for ascii code for ' if data = 65 then goto input_ascii 'look for ascii code for ' number = 0 'if wrong letter is pressed then number = 0' get data 'wait for key to be pressed' return #input_binary digit = digit + 1 #input_binary_loop get data 'get 8 bit ascii code' if data = 8 then number = number shr 1 'debuild number if ascii code for if data = 8 then digit = digit -1 if digit = 1 then goto check_for_hex_or_bin_or_ascii_loop 'go back if or is no longer displayed' if data = 8 then goto input_binary_loop if data = 13 then return 'look for ascii code for data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number shl 1 or (data and 1) else number = (data and 1) 'build number' goto input_binary #input_hex digit = digit + 1 #input_hex_loop get data 'get 8 bit ascii code' if data = 8 then number = number shr 4 'debuild number if ascii code for if data = 8 then digit = digit -1 if digit = 1 then goto check_for_hex_or_bin_or_ascii_loop 'go back if if data = 8 then goto input_hex_loop if data = 13 then return 'look for ascii code for if data > 70 then data = data - 87 else if data > 57 then data = data - 55 else data = data - 48 'translate ascii code into decimal' if number <> 0 then number = number shl 4 or data else number = data 'build number' goto input_hex #input_ascii get number 'get 8 bit ascii code/ build number' return |
| Antwort schreiben |