Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Re: User Interface for CC1M2.01 Kategorie: C-Control I V1.2/2.0 (von Windt H.J. - 22.10.2004 1:51)
 Als Antwort auf User Interface for CC1M2.01 von Windt H.J. - 14.10.2004 8:58

'-------------------------------------------------------------------------------------------------------------------------'
'          *************************************************************************************************'
'          *                                      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 ENTER.'
'Binary, type &b or &B and then the binary code and press enter, exam. &b1010101010101010 or &B1010101010101010 ENTER.'
'Hex, type &h or &H and then the hex code and press enter, exam &hffff or &HFFFF ENTER.'
'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.'
'BACKSPACE works on all inputs except for ascii, ascii will enter the code for BACKSPACE'
'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 BACKSPACE'
if data = 13 then return                             'look for ascii code for ENTER'
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 number if ascii code for BACKSPACE is recieved'
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 ENTER'
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 number if ascii code for BACKSPACE is recieved'
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 ENTER and make number negative if so'
if data = 13 then return                             'look for ascii code for ENTER'
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 b'
if data = 66 then goto input_binary                      'look for ascii code for B'
if data = 104 then goto input_hex                        'look for ascii code for h'
if data = 72 then goto input_hex                         'look for ascii code for H'
if data = 97 then goto input_ascii                       'look for ascii code for a'
if data = 65 then goto input_ascii                       'look for ascii code for A'
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 BACKSPACE is recieved'
if data = 8 then digit = digit -1
if digit = 1 then goto check_for_hex_or_bin_or_ascii_loop  'go back if b or B is no longer displayed'
if data = 8 then goto input_binary_loop
if data = 13 then return                                   'look for ascii code for ENTER'
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 BACKSPACE is recieved'
if data = 8 then digit = digit -1
if digit = 1 then goto check_for_hex_or_bin_or_ascii_loop 'go back if h or H is no longer displayed'
if data = 8 then goto input_hex_loop

if data = 13 then return                                                                         'look for ascii code for ENTER'
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

Bisherige Antworten: