rj
2015-03-14 16:54:23
I'm trying to create a file while a form is open - apparently not possible with lape. So I tried to work around it by closing and freeing the form, and it still does not work. Is there a way to create a file while the form is still open? Why does it not write when I have closed the form (through code)?
{$I SRL-6/SRL.Simba}
{$I TFile.Simba}
const
paintColor = 65280;
var
mainForm:TForm;
clickEveryButton:TEdit;
startButton:TButton;
stallOptions:TComboBox;
labels:array of TLabel;
pressed:boolean;
procedure createForm();forward;
function isLoggedIn():boolean;override;
begin
result := true;
end;
procedure reShow();native;
begin
mainForm.showModal();
end;
procedure startScript(sender:TObject); native;
var
error, st:string;
f:Tfile;
begin
try
mainForm.close();
mainForm.Free();
f.create('C:\Simba\', 'passwords', 'txt');
createForm();
mainForm.showModal();
except
writeln('Unable to start GUI');
finally
mainForm.Free();
end;
//sync(reShow);
exit;
st := stallOptions.getCaption;
case st of
'Jewelry' : writeln('1');
'Banana' : writeln('2');
'Crafting': writeln('3');
'Magic' : writeln('4');
'Scimitar': writeln('5');
else
error := 'You must select a stall to steal from';
end;
try
writeln('test');
except
error := 'You must enter a number in the click every box';
end;
if (length(error) > 1) then
begin
messageBox(error, 'Error', 8);
exit();
end else
begin
mainForm.close();
pressed := true;
end;
end;
procedure createForm();
var
i:integer;
pos:TPointArray;
captions:TStringArray;
begin
mainForm.Init(nil);
with (mainForm) do
begin
setWidth(400);
setHeight(300);
setPosition(poScreenCenter);
setBorderStyle(bsSingle);
setShowHint(true);
setCaption('Stall theiver');
end;
clickEveryButton.init(mainForm);
with (clickEveryButton) do
begin
setParent(mainForm);
setBounds(69, 8, 140, 20);
setCaption('C:\Simba\passwords.txt');
setHint('Time (ms)');
end;
startButton.init(mainForm);
with (startButton) do
begin
setParent(mainForm);
setBounds(8, 100, 235, 30);
setCaption('Start Script');
setHint('Start script');
setOnClick(startScript);
end;
stallOptions.init(mainForm);
with (stallOptions) do
begin
setParent(mainForm);
setBounds(69, 48, 100, 30);
setCaption('Jewelry');
setHint('Steal from');
addItem('Jewelry', stallOptions);
addItem('Banana', stallOptions);
addItem('Crafting', stallOptions);
addItem('Magic', stallOptions);
addItem('Scimitar', stallOptions);
end;
captions := ['Path', 'Steal from'];
pos := [Point(5, 10), Point(5, 50)];
setLength(labels, length(captions));
for i := 0 to high(captions) do
begin
labels[i].Init(mainForm);
with labels[i] do
begin
setParent(mainForm);
setBounds(pos[i].x, pos[i].y, 10, 10);
setCaption(captions[i]);
end;
end;
end;
procedure initForm();native;
begin
createForm();
try
mainForm.showModal();
except
writeln('Unable to start GUI');
finally
mainForm.Free();
end;
end;
procedure showForm();
begin
sync(initForm);
end;
begin
setUpsrl;
showForm();
if (not pressed) then
writeln('did not press start');
end.