I know there are better and more appropriate ways to create midlets.
But for me this is a hobby, and MP and his friends allow me to recycle old memories of basic programming (waiting days with more spare time to deepen the knowledge of prg languages...)
Here is a small prg I found in a russian (?) forum, as free (public) attachment (it's a simply calculator):

program NewProject;

var
okCommand,sqrCommand,sqrtCommand,IntToHexCommand,q uitCommand,
sinCommand,cosCommand,tanCommand,lnCommand,clicked :command;
IntField:integer;
str:string;
intvalue:integer;
screenWidth, screenHeight: integer;
r:real;

procedure welcomeScreen;
var

textToDisplay : string;
textXPos : integer;
textYPos : integer;
keyCode : integer;
begin
setColor(255, 255, 255);
screenWidth := getWidth;
screenHeight := getHeight;
fillRect(0, 0, screenWidth, screenHeight);
setColor(0, 0, 255);
setFont(FONT_FACE_PROPORTIONAL, FONT_STYLE_BOLD, FONT_SIZE_MEDIUM);
textToDisplay := 'Numeric Converter';
textXPos := (screenWidth - getStringWidth(textToDisplay)) div 2;
textYPos := (screenHeight - getStringHeight(textToDisplay)) / 2;
drawText(textToDisplay, textXPos, textYPos);
textYPos := textYPos + getStringHeight(textToDisplay);
setColor(0, 0, 0);
setFont(FONT_FACE_PROPORTIONAL, FONT_STYLE_PLAIN, FONT_SIZE_SMALL);
textToDisplay := 'Created by Voyager';
textXPos := (screenWidth - getStringWidth(textToDisplay)) div 2;
drawText(textToDisplay, textXPos, textYPos);
textYPos := textYPos + getStringHeight(textToDisplay);
textToDisplay := 'Press any key';
textXPos := (screenWidth - getStringWidth(textToDisplay)) div 2;
drawText(textToDisplay, textXPos, textYPos);
repaint;
repeat
keyCode := getKeyClicked;
until keyCode <0> 0 then
begin
i := IntValue;
while i>0 do
begin
j := i mod 16;
if (j<10) then
s := Chr(Ord('0') + j) + s;
else
s := Chr(Ord('A') + (j - 10)) + s;
i := i div 16;
end;
end;
if Digits <1>0 do
begin
s := '0' + s;
i := i - 1;
end;
IntToHex := s;
end;

Function RealToString(r:real; width:integer):string;
var s1,s2:string;pre:string;
begin
pre:='';
if r<0>5 then width:=5;
if frac(r)>=0.5 then s1:=integertostring(Trunc(r)-1) else s1:=integertostring(Trunc(r));if frac(r)=1/10 then s1:=integertostring(stringtointeger(s1)-1);
if width<=0 then s2:='' else s2:='.'+integertostring(trunc(Trunc(frac(r)*pow(10 ,width))));
if frac(r)=0 then s1:=integertostring(stringtointeger(s1)+1);
if r=0 then RealToString:='0' else RealToString:=pre+s1+s2;
end;

function SqrF(str:string): string;
begin
intvalue:=StringToInteger(str);
SqrF:=IntegerToString(sqr(intvalue));
end;

function SqrtF(str:string): string;
begin
intvalue:=StringToInteger(str);
SqrtF:=RealToString(sqrt(intvalue),5);
end;

function SinF(str:string): string;
begin
intvalue:=StringToInteger(str);
r:=toRadians(intvalue);
SinF:=RealToString(sin(r),5);
end;

function CosF(str:string): string;
begin
intvalue:=StringToInteger(str);
r:=toRadians(intvalue);
CosF:=RealToString(cos(r),5);
end;

function TanF(str:string): string;
begin
intvalue:=StringToInteger(str);
r:=toRadians(intvalue);
TanF:=RealToString(tan(r),5);
end;

function LnF(str:string): string;
begin
intvalue:=StringToInteger(str);
LnF:=RealToString(log(intvalue),5);
end;

begin
welcomeScreen;
okCommand := createCommand('OK', CM_SCREEN, 1);
sqrCommand := createCommand('Sqr', CM_SCREEN, 1);
sqrtCommand := createCommand('Sqrt', CM_SCREEN, 1);
IntToHexCommand := createCommand('Hex', CM_SCREEN, 1);
lnCommand := createCommand('Ln', CM_SCREEN, 1);
sinCommand := createCommand('Sin', CM_SCREEN, 1);
cosCommand := createCommand('Cos', CM_SCREEN, 1);
tanCommand := createCommand('Tan', CM_SCREEN, 1);
quitCommand := createCommand('Quit', CM_EXIT, 1);
showForm;
IntField := formAddTextField('Insert a number:', '', 10, TF_NUMERIC);
repeat
addCommand(sqrCommand);
addCommand(sqrtCommand);
addCommand(IntToHexCommand);
addCommand(lnCommand);
addCommand(sinCommand);
addCommand(cosCommand);
addCommand(tanCommand);
addCommand(quitCommand);
repeat
clicked := getClickedCommand;
delay(100);
until (clicked <> emptyCommand);
if(clicked=quitCommand) then halt;
removeCommand(sqrCommand);
removeCommand(sqrtCommand);
removeCommand(IntToHexCommand);
removeCommand(lnCommand);
removeCommand(sinCommand);
removeCommand(cosCommand);
removeCommand(tanCommand);
removeCommand(quitCommand);
str := (formGetText(IntField));
showCanvas;
setColor(255, 255, 255);
fillRect(0, 0, screenWidth, screenHeight);
setColor(0, 0, 255);
If clicked=IntToHexCommand then drawText(IntToHex(stringtointeger(str),8 ), 5, 5)
else If clicked=sqrCommand then drawText(SqrF(str), 5, 5)
else If clicked=sqrtCommand then drawText(SqrtF(str), 5, 5)
else If clicked=sinCommand then drawText(SinF(str), 5, 5)
else If clicked=cosCommand then drawText(CosF(str), 5, 5)
else If clicked=tanCommand then drawText(TanF(str), 5, 5)
else If clicked=lnCommand then drawText(LnF(str), 5, 5)
else drawText('Invalid command', 5, 5);
repaint;
addCommand(okCommand);
addCommand(quitCommand);
repeat
clicked := getClickedCommand;
delay(100);
until (clicked <> emptyCommand);
removeCommand(okCommand);
removeCommand(quitCommand);
formSetText(IntField,'');
showForm;
until clicked = quitCommand;
halt;
end

I found it very instructive to learn how to use procedure, functions, repeat-until, ifs conditions etc. without missing GOTO statement. A procedure is used for presentation. Main repeat-until cycle contains secondary one (which call the relative functions) ...until prg is halted.