Category:Craft Basic: Difference between revisions

no edit summary
(Created page with "{{stub}}{{language|Craft Basic}} [http://basicgames.xyz/index.php?page=article&id=16 Craft Basic homepage] Craft Basic is a BASIC interpreter for Windows 95 and up. It features an interactive IDE allowing code to be ran on the fly. Documentation and several example programs are included. Learn programming easily and develop software for Windows! Simple commands are included for game development. You may easily display bitmap files. Wav files are easy to play. Even th...")
 
No edit summary
Line 1:
{{stub}}{{language|Craft Basic}}
 
[http://basicgames.xyz/index.php?page=article&id=16 Craft Basic homepage]<br>
<br>
About:<br>
<br>
Craft Basic is a BASIC interpreter for Windows 95 and up.<br>
<br>
Tested on 95, XP, and 10.<br>
<br>
* learn programming<br>
* make simple games<br>
* write code interactively<br>
* perform complex calculations
* display cool graphics<br>
* build windows with forms<br>
* write useful scripts<br>
* and more...<br>
<br>
Memory:<br>
<br>
Maximum lines of code is 10000.<br>
Maximum operands in an expression is 200.<br>
Maximum variables is 500.<br>
Maximum arrays is 500 with 1000 maximum elements each.<br>
Maximum declared functions is 100.<br>
<br>
Expressions:<br>
<br>
Operator precedence is !, *, /, %, +, -, <, >, <=, >=, =, <>, XOR, AND, OR, ^<br>
AND may be written as &.<br>
OR may be written as |.<br>
XOR may be written as ~.<br>
! is the not operator.<br>
% is the mod operator.<br>
^ is the power operator.<br>
Functions have no precedence over any operators.<br>
Floating point numbers are supported.<br>
The negative operator is supported.<br>
Parentheses may be used to override order of operations.<br>
White space is optional.<br>
<br>
Variables:<br>
<br>
Variables and arrays are double precision.<br>
<br>
Variable names a-z are pre defined.<br>
All other variable names may consist of numbers and letters only.<br>
Define variables by using let varname=0 with 0 as any value.<br>
The define command may be used to bulk let commands together.<br>
Omit the let and Use commas to separate the definitions.<br>
<br>
Define arrays by using dim arrayname[arraysize].<br>
The arraysize can be a variable or value.<br>
Arrays are zero indexed and may only be one dimension.<br>
<br>
Custom Defined Functions:<br>
<br>
Define functions with the define command.<br>
Function definitions may be mixed in with variable definitions.<br>
All definitions are separated by commas.<br>
Functions are a customizable array of expression strings.<br>
Functions may be named similarly to variables.<br>
Function names must be written in parenthesis without space between.<br>
Functions are artery, but may use global variables.<br>
<br>
The functions may be used anywhere in expressions.<br>
The return value is the evaluation of the function string.<br>
<br>
There's no precedence for custom functions.<br>
Functions may only be defined once. More than once wastes memory.<br>
<br>
Pre Defined Functions:<br>
<br>
There are artery and unary pre defined functions.<br>
<br>
Artery functions must be written in parenthesis without space between.<br>
<br>
Unary functions must have a colon in front of it without space between.<br>
Unary functions pass whatever comes in front of it as a parameter.<br>
<br>
Pre defined functions have no precedence.<br>
Precedence must be established with parenthesis for unary functions.<br>
Wrap the unary function and it's parameter in parenthesis when needed.<br>
This way, full expressions may be used as parameters for the function.<br>
<br>
For example, let x=int:10/3 works fine, but not if int:(rnd)*3 = 1 then.<br>
It must be written as if (int:(rnd)*3)=1 then.<br>
<br>
Syntax:<br>
<br>
Input may optionally have a prompt with double quotes, comma, variable.<br>
Arrays and functions may be used wherever expressions are used.<br>
Arrays may by used with the input and button commands.<br>
<br>
Output may be combined in print, alert, and title using commas.<br>
Output may include numbers, expressions, and double quoted text.<br>
Output may also include the word comma to display a comma.<br>
<br>
Distribution:<br>
<br>
Craft Basic may be used as a scripting language by associating .bas files.<br>
If you prefer to distribute the program as an .exe, follow these steps.<br>
First, copy and paste Craft Basic.exe to the distribution directory.<br>
Then copy your programs .bas file to the same directory.<br>
Rename Craft Basic.exe to match the .bas file.<br>
Change the .bas file extension to a .run file.<br>
The result should look like myprogram.exe and myprogram.run.<br>
When you run the resulting exe, your program will execute automatically.<br>
Now you may include a readme and zip it up.<br>
<br>
Known issues:<br>
<br>
For some reason, -2^2 doesn't evaluate correctly.<br>
If you hold down ctrl R for a long time, the program will crash.<br>
<br>
Want to help fix an issue? Found a new problem?<br>
<br>
Contact me at: ptrworkmails@gmail.com<br>
<br>
Language keywords:<br>
<br>
DEFINE variable=expression,variable=expression,variable=expression,etc...<br>
DEFINE FN (FUNCNAME) AS expression,FN (FUNCNAME) AS expression,FN (FUNCNAME) AS expression, etc...<br>
(short command: DEF)<br>
<br>
IF expression THEN LABELNAME<br>
(if short command: ?)<br>
<br>
IF expression THEN<br>
ENDIF<br>
(endif short command: ??)<br>
<br>
DO<br>
LOOP expression<br>
(loops while condition is true)<br>
(loop with no parameter for an infinite loop)<br>
<br>
LET variable=expression<br>
(short command: #)<br><br>
<br>
DIM variable[variable OR literal number]<br>
<br>
PRINT expression OR comma OR "TEXT"<br>
(short command: @)<br>
(use commas to combine outputs)<br>
(use the word comma between commas to display commas)<br>
<br>
INPUT "PROMPT",variable<br>
(short command: IN)<br>
(the prompt is optional)<br>
<br>
GOTO LABELNAME<br>
(short command: .)<br>
<br>
LABEL LABELNAME<br>
<br>
GOSUB SUBNAME<br>
(short command: ..)<br>
<br>
SUB SUBNAME<br>
<br>
RETURN<br>
(short command: ...)<br>
<br>
TITLE expression OR comma OR "TEXT"<br>
<br>
ALERT expression OR comma OR "TEXT""<br>
(short command: @@)<br>
<br>
BUTTON variable,BUTTON CODE<br>
(short command: BTN)<br>
<br>
DRAWBMP FILE.BMP,expression,expression<br>
(short command: BMP)<br>
(don't use quotes in the filename)<br>
<br>
PLAYWAV FILE.WAV<br>
(short command: WAV)<br>
(don't use quotes in the filename)<br>
<br>
CURSOR expression,expression<br>
(short command: CR)<br>
<br>
RESIZE expression,expression,expression,expression<br>
<br>
CENTER<br>
<br>
DOT expression,expression<br>
<br>
LINE expression,expression,expression,expression<br>
<br>
OVAL expression,expression,expression,expression<br>
<br>
RECT expression,expression,expression,expression<br>
<br>
FGCOLOR expression,expression,expression<br>
(short command: FG)<br>
<br>
BGCOLOR expression,expression,expression<br>
(short command: BG)<br>
<br>
FILL ON/OFF<br>
<br>
WAIT<br>
(short command: WT)<br>
<br>
CLS<br>
(short command: X)
 
GETHDC<br>
Craft Basic is a BASIC interpreter for Windows 95 and up.
(use before drawing commands)<br>
 
<br>
It features an interactive IDE allowing code to be ran on the fly. Documentation and several example programs are included. Learn programming easily and develop software for Windows!
RELHDC<br>
 
(use after drawing commands/after GETHDC calls)<br>
Simple commands are included for game development. You may easily display bitmap files. Wav files are easy to play. Even the keyboard buttons are simple to read. There's also the simple and traditional print and input commands. Single dimensional arrays are supported.
<br>
 
MASK OF/OFF<br>
Operator precedence is !, *, /, %, +, -, <, >, <=, >=, =, <>, XOR, AND, OR, and ^. AND may be written as &. OR may be written as |. XOR may be written as ~. ! is the not operator. % is the mod operator. ^ is the power operator. Functions have no precedence over any operators. Floating point numbers are supported. The negative operator is supported. Parentheses may be used to override order of operations. Supported functions include (RND), (CLOCK), INT:, SIN:, COS:, and TAN:.
(drawing transparency. defaults to off)<br>
 
<br>
Craft Basic may be used as a scripting language by associating .bas files. If you prefer to distribute the program as an .exe, follow these steps. First, copy and paste Craft Basic.exe to the distribution directory. Then copy your programs .bas file to the same directory. Rename Craft Basic.exe to match the .bas file. Change the .bas file extension to a .run file. The result should look like myprogram.exe and myprogram.run. When you run the resulting exe, your program will execute automatically. Now you may include a readme and zip it up.
BUTTONFORM expression, expression, expression, expression<br>
(generate new button form with specified coordinates and size)<br>
(use formid to select the form handle)<br>
(use formtext to prepare the form text)<br>
<br>
STATICFORM expression, expression, expression, expression<br>
(generate new static form with specified coordinates and size)<br>
(use formid to select the form handle)<br><br>
(use formtext to prepare the form text)<br>
<br>
UPDATEFORM<br>
(applies formtext to selected formid)<br>
<br>
COLORFORM<br>
(applies the last set foreground and background colors to the selected formid)<br>
<br>
FORMID expression<br>
(set the id to be used by form commands)<br>
<br>
FORMTEXT expression OR comma OR "TEXT"<br>
(set the text to be used by form commands)<br>
<br>
RUN "windowsprogram.exe","windowsparameters",comma,expression,comma etc.....<br>
(the first parameter is the program to run)<br>
(the following parameters are formatted like print and combined)<br>
<br>
END<br>
<br>
REM<br>
(short command: ')<br>
<br>
(CLOCK)<br>
(function returns milliseconds since boot)<br>
(must include the parentheses without spaces)<br>
<br>
(RND)<br>
(function returns random number)<br>
(must include the parentheses without spaces)<br>
<br>
(MOUSEX)<br>
(function returns mouse x coordinate relative to window)<br>
(must include the parentheses without spaces)<br>
<br>
(MOUSEY)<br>
(function returns mouse t coordinate relative to window)<br>
<br>
(MOUSEB)<br>
(function returns 1 if left mouse button is pressed or 2 for right)<br>
(returns 0 when no mouse button is clicked)<br>
<br>
(FORMS)<br>
(function returns id of any form that has been clicked)<br>
(returns 0 when no form is clicked)<br>
<br>
ABS:<br>
(function returns absolute value of whatever comes after the colon)<br>
<br>
INT:<br>
(function returns integer of whatever comes after the colon)<br>
<br>
SQRT:<br>
(function returns square root of whatever comes after the colon)<br>
<br>
SIN:<br>
(function returns sine of whatever comes after the colon)<br>
<br>
COS:<br>
(function returns cosine of whatever comes after the colon)<br>
<br>
TAN:<br>
(function returns tangent of whatever comes after the colon)<br>
<br>
ATN:<br>
(function returns arctangent of whatever comes after the colon)<br>
<br>
LOG:<br>
(function returns logarithm of whatever comes after the colon)<br>
305

edits