Code: Select all
'include code in commandbox.bi.
#include once "commandbox.bi"
'include code in null.bi.
#include "NULL.bi"
'dim variables.
Dim Shared As ulongint a,b
Dim Shared As String again
'declare subrotines.
Declare Sub prime (Byref a As ulongint, Byref b As ulongint)
'define subrotines.
Sub prime (Byref a As ulongint, Byref b As ulongint)
While ((a / b) - Fix(a / b)) = 0
Print b
a = a / b
Wend
If b = 2 Then
b = 3
Else
b += 2
End If
If b <= a Then :prime a,b
End If
End Sub
'set the screen resolution.
Screenres 640, 300, 32
'start program actions.
start:
Input " Number to factor?",a
start2:
if a > 18446744073709551615 then error 2
if err =2 then print " Number too large." :goto start
b = 2
'if a equals something (other than a number).
If a = null (a) Then
Print " Please use numbers only!!!"
Goto start
End If
prime a,b
Print " Done!"
Print ""
'end program
quit:
Input " Start again?", again
'if the user types a number into the prompt, find the factors.
If Val(again) <> 0 Then
a = Val(again)
Goto start2
Elseif Lcase(again) = "n" Then
End 0
Else
Print " What??"
Print
Goto quit
Endif
Code: Select all
#include once "fbgfx.bi"
#define _common_colors_
' add more colors
'the colors that can be used
Enum colors
color_black = Rgb(0,0,0)
color_blue = Rgb(0,0,255)
color_cyan = Rgb(0,255,255)
color_lightgreen = Rgb(0,170,50)
color_darkgreen = Rgb(0,130,50)
color_green = Rgb(0,255,0)
color_yellow = Rgb(255,255,0)
color_gold = Rgb(217,220,0)
color_orange = Rgb(255,132,0)
color_red = Rgb(255,0,0)
color_lightgray = Rgb(200,200,200)
color_gray = Rgb(150,150,150)
color_darkgray = Rgb(100,100,100)
color_purple = Rgb(100,0,100)
color_velvet = Rgb(150,0,150)
color_white = Rgb(255,255,255)
End Enum
Code: Select all
'NULL-the value of nothing.
'in main program, use like this:
'if variable <> null(variable) then ....
Declare Function null Overload (Byref value As Ulongint) As Integer
Declare Function null Overload (Byref value As String) As Integer
Declare Function null (Byref value As Double) As Integer
Function null (Byref value As Ulongint) As Integer
If value = 0 Then
Return 0
Else
Return 1
Endif
End Function
Function null (Byref value As String) As Integer
If value <> "" Then
Return 1
Else
Return 0
Endif
End Function
Function null (Byref value As Double) As Integer
If value = 0 Then
Return 0
Else
Return 1
Endif
End Function