if_then.bas

来自「82 sample programs written in BASCOM-805」· BAS 代码 · 共 41 行

BAS
41
字号
'--------------------------------------------------------------
'                     (c) 1997-2000 MCS Electronics
'--------------------------------------------------------------
'  file: IF_THEN.BAS
'  demo: IF, THEN, ELSE
'--------------------------------------------------------------
Dim A As Byte , B1 As Byte

Input "Number " , A                                           'ask for number
If A = 1 Then                                                 'test number
   Print "You guested it!"
End If

If A = 0 Then                                                 'test again
   Print "Wrong"                                              'thats wrong
Else                                                          'print this if a is not 0
   Print "Almost?"
End If

Rem You Can Nest If Then Statements Like This
B1 = 0
If A = 1 Then
  If B1 = 0 Then
     Print "B1=0"
  End If
Else
  Print "A is not 0"
End If

Input "Number " , A
If A = 1 Then                                                 '
  Print "Ok"
Elseif A = 2 Then                                             'use elseif for more tests
  Print "2" : A = 3
Elseif A = 3 Then
  Print "3"
End If

If A.1 = 1 Then Print "Bit 1 set"

End

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?