Posts: 42
Threads: 12
Joined: Feb 2019
Reputation:
0
Location: Rochester, NY
Is it possible to have have a two form application and be able to call a procedure in form1 from form2? I have a web socket on form1 and I'd like to have one "sendMsg(string);" on form1 that form2 would call. Standard practice in Delphi itself, but the Intraweb app doesn't seem to let me. Do I need another socket on form2 to have it communicate? I have the units in the 'uses' clause of each other and I can see form1 variables in form2 but not procedures.
Posts: 1,136
Threads: 37
Joined: Mar 2018
Reputation:
30
Location: Limassol, Cyprus
The form instances still exist. From an event in form2, you can call methods in instances of form1.
Posts: 42
Threads: 12
Joined: Feb 2019
Reputation:
0
Location: Rochester, NY
That's what I thought as well. But the methods available are only those associated with TIWAppForm, not any that I've declared. Normally I would expect that if I declare a public procedure in iwform1, like "procedure Adjust(s: string);", and somewhere in iwform1 there is
"Procedure TIWform1.Adjust(s: string);
begin
...code...
end;"
that I can call it in iwform2 via "iwform1.Adjust('dog');" Indeed, in plain Delphi, typing just "form1." triggers code completion to list the available procedures and functions. Doing that in my Intraweb app only shows the tiwappform procedures like "SetURL" and gives an error if I enter "iwform1.Adjust('dog');".
I apologize if this is still not clear or that it's a case of some simple setting that "everybody knows".
Posts: 1,136
Threads: 37
Joined: Mar 2018
Reputation:
30
Location: Limassol, Cyprus
"only those associated with TIWAppForm"
That's because you arent accessing them correctly. Where are you getting the instance from? If its from a session list or other then you will need to typecast it just as you would in any Delphi app. Otherwise you can store a typed referenced in your session to specific instances to pages just as you would in a Delphi app, but instead of globals they must exist on the session because IW apps are multi user.
Posts: 1,136
Threads: 37
Joined: Mar 2018
Reputation:
30
Location: Limassol, Cyprus
You can also extend the user session for any global routines. If they are truly page specific, then simply store a reference i your user session from the oncreate, constructor or other place when your page1 gets created.