MariaBasic 1.9.9.5 Program Structure:



1. Coding convention (s)


(<string constant> is a single quoted literal)

(<num constant> is a number literal having [0-9,.] )

(<varname> is a string literal having [_,a-z,A-Z,0-9] + type declaration [%|&|#|$])

(type declaration [%|&|#|$] where % EQ integer data type , where & EQ 2x integer data type , where # EQ double data type , and $ EQ <=256 char data type)  

(logical operator (s) are and , or , xor)

(relation operator (s) are > , < , = , >= , <= , <> )


2. Program body


1.Declarations:

2. Statements | Simple Block Statements | Nested Block Statements | Declarations | Comments

3. end Statement


- Comments:


rem <string constant>


- Declarations:


variable declaration (s):
{
[varname$=’<string constant>|’]|[varname%=<num constant>|0]|[varname&=<num constant>|0]| [varname#=<num constant>|0]
}


- Statements:

relation expression logical evaluation statement:

{

varname[%|&]=(varname[%|&|#|$][=,<>,>,<,>=,<=]varname[%|&|#|$]

[ or , and , xor ]

[ varname[%|&|#|$][=,<>,>,<,>=,<=]varname[%|&|#|$])

}

calculation statement:

{

varname[%|&|#]=[[varname[%|&|#]|[<num constant>]][^,*,/,+,-][[varname[%|&|#]|[<num constant>]]

}

string concatenation statement:

{

varname$=varname$+ varname$

}

string function statement (s):

{

varname[%|&]=len$( varname$)

varname[%|&|#]=val$( varname$)

varname$=trim$( varname$)

varname$=left$( varname$, <num constant>)

varname$=right$( varname$, <num constant>)

varname$=mid$( varname$, <num constant>, <num constant>)

varname$=format$( varname[%|&|#],<string constant>)

varname[%|&|#]=round$(varname#)

}

file operation statement (s):

{

open varname$ for [input]|[output] as #<num constant>

input #<num constant>, varname$

print #<num constant>, [<string constant>| varname[%|&|#|$][,]][;]

close #<num constant>

}

console output statement:

{

print [<string constant>| varname[%|&|#|$][,]][;]

}

- Simple Blocks:

simple if end if block:

{

if (<single relation expression>) then

<statements>

end if

}

Simple while wend Block:

{

while (<single relation expression>)

<statements>

wend

}

Simple for next Block:

{

for varname[%|&]=[[<num constant>]| varname[%|&]] to [<num constant>| varname[%|&]]

<statements>

next varname[%|&]

}

Nested Block Statement (s) (up to Level 3.)

Nested type 1. Block:

{

if () then

<statements>

end if

            for to

<statements>

            if () then

<statements>

                        end if

                        <statements>

            if () then

<statements>

                        end if

<statements>

            next

<statements>

            if () then

<statements>

            if () then

<statements>

                        end if

            <statements>

            if () then

<statements>

                        end if

<statements>

            end if

<statements>

while ()

<statements>

                        if () then

<statements>

                        end if

<statements>

                        if () then

<statements>

                        end if

<statements>

wend

<statements>

end if

}

Nested type 2. Block:

{

for to

<statements>

            for to

<statements>

            if () then

<statements>

                        end if

                        <statements>

            if () then

<statements>

                        end if

<statements>

            next

<statements>

            if () then

<statements>

            if () then

<statements>

                        end if

            <statements>

            if () then

<statements>

                        end if

<statements>

            end if

<statements>

while ()

<statements>

                        if () then

<statements>

                        end if

<statements>

                        if () then

<statements>

                        end if

<statements>

wend

<statements>

next

}

Nested type 3. Block:

{

while ()

<statements>

            for to

<statements>

            if () then

<statements>

                        end if

                        <statements>

            if () then

<statements>

                        end if

<statements>

            next

<statements>

            if () then

<statements>

            if () then

<statements>

                        end if

            <statements>

            if () then

<statements>

                        end if

<statements>

            end if

<statements>

while ()

<statements>

                        if () then

<statements>

                        end if

<statements>

                        if () then

<statements>

                        end if

<statements>

wend

<statements>

wend

            }

            3. End of Program

{end}