Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Blitz BASIC
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples== A [["Hello, World!" program]] that prints to the screen, waits until a key is pressed, and then terminates: <syntaxhighlight lang="blitzbasic"> Print "Hello, World!" ; Prints to the screen. WaitKey() ; Pauses execution until a key is pressed. End ; Ends Program. </syntaxhighlight>Program that demonstrates the declaration of variables using the three main data types ([[String (computer science)|strings]], [[Integer (computer science)|integers]] and [[Floating-point arithmetic|floats]]) and printing them onto the screen:<syntaxhighlight lang="blitzbasic"> name$ = "John" ; Create a string variable ($) age = 36 ; Create an integer variable (No Suffix) temperature# = 27.3 ; Create a float variable (#) print "My name is " + name$ + " and I am " + age + " years old." print "Today, the temperature is " + temperature# + " degrees." Waitkey() ; Pauses execution until a key is pressed. End ; Ends program. </syntaxhighlight> Program that creates a windowed application that shows the current time in binary and decimal format. See below for the BlitzMax and BlitzBasic versions: <!-- Copy, modify and redistribute these sources with no limit --> {| class="wikitable nowrap" ! BlitzBasic version ! BlitzMax version |-style="vertical-align:bottom" | <syntaxhighlight lang="BlitzBasic"> AppTitle "Binary Clock" Graphics 150,80,16,3 ;create a timer that means the main loop will be ;executed twice a second secondtimer=CreateTimer(2) Repeat Hour = Left(CurrentTime$(),2) Minute = Mid(CurrentTime$(),4,2) Second = Right(CurrentTime$(),2) If Hour >= 12 Then PM = 1 If Hour > 12 Then Hour = Hour - 12 If Hour = 0 Then Hour = 12 ;should do this otherwise the PM dot will be ;left up once the clock rolls past midnight! Cls Color(0,255,0) ;make the text green for the PM part If PM = 1 Then Text 5,5,"PM" ;set the text colour back to white for the rest Color(255,255,255) For bit=0 To 5 xpos=20*(6-bit) binaryMask=2^bit ;do hours If (bit<4) If (hour And binaryMask) Text xpos,5,"1" Else Text xpos,5,"0" EndIf EndIf ;do the minutes If (minute And binaryMask) Text xpos,25,"1" Else Text xpos,25,"0" EndIf ;do the seconds If (second And binaryMask) Text xpos,45,"1" Else Text xpos,45,"0" EndIf Next ;make the text red for the decimal time Color(255,0,0) Text 5,65,"Decimal: " + CurrentTime$() ;set the text back to white for the rest Color(255,255,255) ;will wait half a second WaitTimer(secondTimer) Forever </syntaxhighlight> | <syntaxhighlight lang="BlitzMax"> Import BRL.Timer Import BRL.TimerDefault AppTitle = "Binary Clock" Graphics 145,85 'create a timer that means the main loop will be 'executed twice a second Local secondtimer:TTimer = CreateTimer(2) Local Hour:Int Local Minute:Int Local Second:Int Local PM:Int local bit:Int local xpos:Int Local binaryMask:Int Repeat Hour = CurrentTime()[..2].ToInt() Minute = CurrentTime()[4..6].ToInt() Second = CurrentTime()[6..].ToInt() If Hour >= 12 Then PM = 1 If Hour > 12 Then Hour = Hour - 12 If Hour = 0 Then Hour = 12 'should do this otherwise the PM dot will be 'Left up once the clock rolls past midnight! Cls SetColor(0,255,0) 'make the text green For the PM part If PM = 1 Then DrawText "PM",5,5 'set the text colour back To white For the rest SetColor(255,255,255) For bit=0 Until 6 xpos=20*(6-bit) binaryMask=2^bit 'do hours If (bit < 4) If (hour & binaryMask) DrawText "1",xpos,5 Else DrawText "0",xpos,5 EndIf EndIf 'do the minutes If (minute & binaryMask) DrawText "1", xpos,25 Else DrawText "0", xpos,25 EndIf 'do the seconds If (second & binaryMask) DrawText "1",xpos,45 Else DrawText "0",xpos,45 EndIf Next 'make the text red For the decimal time SetColor(255,0,0) DrawText "Decimal: " + CurrentTime(),5,65 'set the text back To white For the rest SetColor(255,255,255) Flip 'will wait half a second WaitTimer(secondTimer) If KeyHit(KEY_ESCAPE) Then Exit Forever </syntaxhighlight> |}
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Blitz BASIC
(section)
Add topic