Hi,
I'm modifying a barmenu routine, originally coded by Steve Trace. Steve had written his barmenu as a sub, but I'm trying to convert it to a function. The function will return the choice selected.
The problem is that the return statement
MyBarMenu = ChoiceSelected
is generating an illegal string-number conversion error.
I don't know how to specify the return value of a function. I tried 'As String' after the function name & parameters ; but that also generates an error.
This is the module.
' Modified from a routine by Steve Trace
Function Mybarmenu
(y
, x
, spacing
, tc
, bc
, prompts$
())
description
= UBound(prompts$
, 2) okprompt$ = ""
Print prompts$
(i
, prompt
);
Spc(spacing
);
okprompt$
= okprompt$
+ Chr$(Asc(prompts$
(i
, prompt
))) current = top
moveto = current
ChoiceSelected = ""
While ChoiceSelected
= "" Print prompts$
(current
, prompt
);
Print prompts$
(current
, description
);
Call specialkey
(ch$
, moveto
, top
, bottom
) ChoiceSelected
= Chr$(Asc(prompts$
(current
, prompt
))) ' ELSEIF INSTR(okprompt$, UCASE$(ch$)) > 0 THEN
Print prompts$
(current
, prompt
);
current = moveto
ch$ = ""
MyBarMenu = ChoiceSelected