So below is the module of code I have created to verify a user input is between a range but this error keeps appearing below it ' statement expected but function found', any ideas anyone? Many thanks
function get_choice(var Options: integer): integer;
var
choice: integer;
begin
while (true) do
begin
write('choose option 1 to', Options);
try
readln(choice);
if (choice>=1) and (choice <=Options) then
get_choice := choice
else
write('invalid range');
except
write('not a number');
end;
end;


Each output expression must be of a type Char, one of the Integer types (Byte, Shortint, Word, Longint, Cardinal), one of the floating-point types (Single, Real, Double, Extended, Currency), one of the string types (PChar, AnsiString, ShortString), a packed string, or one of the Boolean types (Boolean, Bool).WriteandWritelnare from the very old days. They don't need things likeIntToStror similar conversion routines. Both are "compiler magic" routines, i.e. the compiler knows them and generates different code sequences depending on the arguments. This also makes them accept multiple different arguments, which was otherwise not possible beforearray of constwas introduced. FWIW, nowadays, such functions are called "intrinsics" by some.IntToStr()with Write and()` for a few decades now :-)Write(I:8, J:8);which formats I and J right in their own "fields" of each 8 characters. Very useful for console programs that should quickly (and readably) output the results of a simple test.