مروری بر مطالب این تاپیک:
دستور PRINT برای چاپ(از علامت سئوال هم میشه بجای آن استفاده کرد).
کد:
اگر سمی کلون بعد یک چاپ بگذاریم چاپ بعدی را در ادامه خواهیم داشت.
دستور CLS برای پاک کردن صفحه.
دستور INPUT برای ورودی گرفتن از کاربر:
در کدهای زیر طرز گرفتن رشته و عدد را می بینید.
کد:
کد:
INPUT "Enter your name: ", Name$
کد:
کد:
INPUT "Enter a number: ", Number
شرط:
کد:
کد:
CLS
INPUT "Enter your name: ", Name$
IF Name$="Mike" THEN
PRINT "Go Away!"
ELSE
PRINT "Hello, "; Name$; ". How are you today?"
END IF
کد:
کد:
CLS
INPUT "Enter a number: ", Number
IF Number < 100 THEN
PRINT "Your number was less than 100"
ELSE
PRINT "Your number was greater than or equal to 100"
END IF
SELECT CASE :
کد:
کد:
CLS
INPUT "Enter your name: ", Name$
SELECT CASE Name$
CASE "Ted"
PRINT "Greetings, oh powerful master"
CASE "Mike"
PRINT "Go away!"
CASE ELSE
PRINT "Hello, "; Name$; ". How are you?"
END SELECT
عدد راندوم:
کد:
کد:
CLS
RANDOMIZE TIMER
PRINT RND
PRINT RND
کد:
کد:
CLS
RANDOMIZE TIMER
INPUT "Press ENTER to roll dice...", A$
PRINT
Die1 = INT(RND * 6 + 1)
Die2 = INT(RND * 6 + 1)
PRINT "Die 1: "; Die1
PRINT "Die 2: "; Die2
حلقه WHILE - در حقیقت DO...LOOP WHILE :
کد:
کد:
CLS
DO
INPUT "Enter the first number: ", A
INPUT "Enter the second number: ", B
PRINT "The answer is: "; A * B
INPUT "Would you like to do it again (y/n)? ", Answer$
LOOP WHILE Answer$="y"
با Or :
کد:
کد:
LOOP WHILE Answer$="y" OR Answer$="Y"
لفت و رایت:
کد:
رنگ و چشمک زدن:
کد:
کد:
CLS
COLOR 2, 0
PRINT "That's ";
COLOR 3, 0
PRINT "more ";
COLOR 5, 0
PRINT "like it!"
کد:
کد:
0 - Black
1 - Blue
2 - Green
3 - Cyan
4 - Red
5 - Magenta
6 - Yellow
7 - White
کد:
کد:
CLS
COLOR 28, 0
PRINT "*** WARNING ***"
COLOR 15, 0
PRINT "Programming can be too much fun!"
FOR...NEXT :
کد:
کد:
CLS
FOR I = 1 TO 10
PRINT I
NEXT I
Sound :
کد:
کد:
CLS
INPUT "Press Enter to hear a beep", A$
BEEP
کد:
کد:
FOR I = 4000 TO 1000 STEP -5
SOUND I, .1
NEXT I
کد:
کد:
PLAY "e8 d8 c8 d8 e8 e8 e4"
کد:
کد:
PLAY "c8 d8 e8 f8 g8 a8 b8 > c4"
کد:
کد:
PLAY "T180 <d8d8d8 T120 g2>d2"
PLAY "T180 c8<b8a8 T120 >g2d4"
PLAY "T180 c8<b8a8 T120 >g2d4"
PLAY "T180 c8<b8>c8 T120 <a2>"
LOCATE :
کد:
کد:
CLS
LOCATE 5, 10
PRINT "Here"
LOCATE 20, 70
PRINT "There"
WIDTH :
کد:
کد:
SCREEN 0
WIDTH 40
CLS
PRINT "Wow! This is big!"
INPUT "Press <Enter> to go back", A$
WIDTH 80
PRINT "That's more like it."
CHR$:
کد:
کد:
CLS
PRINT CHR$(1); CHR$(2)
کد:
کد:
CLS
FOR I = 32 to 255
PRINT I; CHR$(I); " ";
NEXT I