Hartismere School

An outstanding coeducational secondary school and sixth form college

JustBasic Hint Sheet

To turn text into UPPERCASE:

text$ = UPPER$(text$)

To get the length of some text:

length = LEN(someText$)


To get the position of a letter in some text:

position = INSTR(someText$, letter$)

To get one letter from inside some text:

letter$ = MID$(someText$, position, 1)

To double-up some text:

someText$ = someText$ + someText$

To loop through each letter in some text:

for i = 1 TO LEN(someText$)
    letter$ = MID$(someText, i, 1)
next

To create a simple number function:

function aNumber()
    aNumber = 100
end function

To create a simple text function:

function aWord$()
    aWord$ = "Hello"
end function

A function that adds two numbers:

function TwoNumbers(number1, number2)
    TwoNumbers = number1 + number2
end function


A function that joins two words:

function TwoWords$(word1$, word2$)
    TwoWords$ = word1$ + word2$
end function

A routine to load text from a text file and store it in a string variable:

OPEN "N:\InputFile.txt" for INPUT as #1    
    fileContents$ = INPUT$(#1, LOF(#1))
CLOSE #1

A routine to save text into a text file:

OPEN "N:\OutputFile.txt" for OUTPUT as #1    
    #1 textToSave$
CLOSE #1