Is it possible to open a file while a form is open?
I remember there was some ghetto hax thing that @Brandon; did with writeln a long time ago but can't find it and I don't know if it applies to opening files
Is it possible to open a file while a form is open?
I remember there was some ghetto hax thing that @Brandon; did with writeln a long time ago but can't find it and I don't know if it applies to opening files
I don't know the answer to be honest, but we could make a short sample script to test it, right? If someone else doesn't give you a definitive answer soon I'll try to make a short test. I feel like the answer is going to be no though for some reason. Kind of like how the code pauses at ReadLn, until VK_RETURN is hit. But I'll still give it a test anyway. If it turns out being no, you could always add a Button to your form that is open and OnClick, it opens the file.
EDIT: I may be wrong, because I don't have the most experience with forms and files in SRL, (I have some experience with forms, and some experience with files in Java, just started doing file work in Pascal yesterday) but when I edited my AlarmClock/Timer program (which has a form) I added writeln('open file') and OpenFile codes after my ShowForm in main loop. The writeln was never executed until the form was closed. So I'm guessing your best bet would be to just add a button to your form to execute the OpenFile code.
But like I said, I could be wrong. I don't have the most experience here and I did a really short, quick test.
Last edited by Baked0420; 02-11-2016 at 09:58 AM.
RJ is referring to the access violations you get when attempting to read/write files when a form is currently open. It is because of the way Simba handles threads.
There are a few ways around it, by going through the client:
Simba Code:program new;
var
Form: TForm;
Btn: TButton;
Str: String;
procedure Listener(Sender: TObject); native;
var
MyFile: Integer;
begin
MyFile := Client.GetMFiles().OpenFile(IncludePath + 'srl-6\lib\interfaces\bankscreen.aca',true);
Client.GetMFiles().ReadFileString(MyFile, Str, Client.getMFiles().FileSizeMuf(MyFile));
end;
procedure LoadForm(); native;
begin
Form.Init(nil);
with Form do
begin
setWidth(280);
setHeight(250);
setPosition(poScreenCenter);
setBorderStyle(bsSingle);
end;
Btn.Init(Form);
with (Btn) do
begin
setParent(Form);
setBounds(8, 211, 262, 30);
setCaption('Open File');
setOnClick(Listener);
end;
try
Form.ShowModal();
except
finally
Form.free();
end;
end;
begin
Sync(LoadForm);
WriteLn(Str);
end.
I don't think you need EZForm to use TFileStream. My code completion shows TFileStream and I don't have EZForm on my computer anymore.
And whenever my form calls my Timer procedure, just like a timer that loops X-minutes than plays a sound (called from buttonclick), it says "Something went wrong in Simba..." and see error log. But when I take the repeat/until loop out, then the error doesn't happen but the procedure doesn't do what it's supposed to. Does TFileStream fix this problem?
GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!
<BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols
There are currently 1 users browsing this thread. (0 members and 1 guests)