kytschBASIC

Put down that phone!
Please view me on real computer.

DEF

Defining a variable of various types.

string

Defining a string and using the variable

Example

DEF test$="kytschBASIC is awesome!"

PRINT test$

Output

kytschBASIC is awesome!

integer

Defining an integer and using the variable

Example

DEF test%=1337

PRINT test%

Output

1337

double

Defining a double and using the variable

Example

DEF test#=1337.11

PRINT test#

Output

1337.11

double to two decimal places

Filtering a double to two decimal places

Example

DEF test#=TWODP(1337.737)



REM or do it on the PRINT

PRINT TWODP(test#)



PRINT test#

Output

1337.74

Mixed

Defining a variable where the type is mixed, unknown or for example a result set.

Example

DATA

	REM Open the database connection from the config file labelled kytschBASIC.

	DOPEN "kytschBASIC"



	REM Read from the menu table in the database.

	DREAD "menu"



	REM Select all entries from the menu table.

	DSELECT "*"



	REM Condition the select to those that aren't deleted.

	DWHERE "(slug=:header OR slug=:footer) AND deleted_at IS NULL"



	REM Bind the slug string to be used in the query.

	DBIND header="header", footer="footer"



	REM Sort the results by their name alphabetically.

	DSORT "name ASC"



	REM Fetch the results and assign them to menu variable.

	DFETCH menu&

END DATA



REM Loop through the results stored in menu& variable.

FOR item& IN menu&

	SWRITE

		PRINT item&("id")

		PRINT ": "

		PRINT item&("name")

	END SWRITE

NEXT

Output

7: Database

3: Heading

1: Home

4: Media

5: Tables

2: Text

6: Variables