Second implementation of my own programming language called NovaBASIC. Made in C# .NET 8, using Blazor as front-end.
Standard operations in NovaBASIC:
LET i = 50
IMMUTABLE j = 100
LET myArray = NEW[10]
FOR LET i = 0 TO 10
PRINT i
END
FOR LET i = 0 TO 10 STEP 2
PRINT i
END
LET j = 0
WHILE j < 10
PRINT j
j = j + 1
ENDWHILE
LET h = 10
REPEAT
PRINT h
h = h + 1
UNTIL h > 20
FUNC myFunc(arrRef, index)
arrRef[index] = 20
ENDFUNC
LET myArray = NEW[5]
myFunc(REF myArray, 4)
LET i = 6
IF i % 2 == 0 THEN
PRINT "Value " + i + " is dividable by 2."
ELSEIF i % 3 == 0 THEN
PRINT "Value " + i + " is dividable by 3."
ENDIF
LET dayOfWeek = "Friday"
SWITCH dayOfWeek
CASE "Monday":
PRINT "Start of the workweek"
BREAK
CASE "Friday":
PRINT "End of the workweek"
BREAK
DEFAULT:
PRINT "Middle of the workweek"
BREAK
ENDSWITCH
FUNC myFunc(param)
GUARD param < 20 ELSE
PRINT "Too much!"
RETURN null
ENDGUARD
RETURN param * 50
ENDFUNC
LET i = 10
LET j = 20
myFunc(i)
myFunc(j)
STRUCT Person
Name
ENDSTRUCT
FUNC GetNameLength(p)
GUARD p IS Person ELSE
PRINT "Parameter must be a 'Person'!"
RETURN -1
ENDGUARD
RETURN COUNT(p.Name)
ENDFUNC
PRINT GetNameLength(NEW Person("Bob Ross"))
PRINT GetNameLength(25)
LET arr = NEW[10]
LET firstTwo = arr[:3]
LET lastSeven = arr[3:]
LET between = arr[2:5]
LET inTwo = arr[1:10:2]
//File1.nova
IMMUTABLE myConst = 3.14
STRUCT myStruct
Val
ENDSTRUCT
EXPORT
myConst,
myStruct
ENDEXPORT
//File2.nova
FUNC myFunc(var1)
PRINT var1
ENDFUNC
EXPORT
myFunc
ENDEXPORT
//File3.nova
IMPORT FROM "File1"
IMPORT "MyFunc" FROM "File2"
LET i = NEW myStruct(myConst)
myFunc(i)