How do I correctly use the include event sheet method

Just started using Construct 2? Post your questions here

Post » Wed Mar 08, 2017 7:51 am

Hi

I am probably misunderstanding what can and cannot be done when using the "include event sheet" method. At the moment my project is getting too big because I am , in each event sheet, loading files in and reading the data via ajax.

So I thought it would be a good idea to create an event sheet that allowed for the handling of loading files. Then each event sheet would call a function from that included event sheet (say call it B for now) and that function had a parameter to identify each call.

this all sounded good , I tried it with one call from one sheet to start with. The logic goes as follows :
On start of layout - Call function from included event sheet (B) with parameter (1)
(In included event sheet):
on function call - > if parameter equals 1 - load required file via ajax using unique tag.
Ajax on unique tag load completed
-> set variable recordcount(from called event sheet) to tokencount(look for record marker from ajax loadlastdata)
-> array(from called event sheet) set size (recordcount,1,1)

-> subevent -> loop through loadlast.data to populate array with data

-> blank subevent after loop finished - call function from called event sheet to load data to sheet.


The problem I have is that the final call to the function from the called sub even seems to loop. Now this logic was originally in the event sheet that was calling the included event sheet before the include event sheet even existed so I know this logic works. Also if I enable this code back in the original called event sheet the looping stops.

I have also tried to call the last function at the end part of on start of layout but this does not work as no data is loaded to screen.

Any help would be appreciated.
Regards

TimCS
B
23
S
8
Posts: 130
Reputation: 1,917

Post » Wed Mar 08, 2017 9:05 am

Included event sheet acts as its events are in the base sheet.

You gots to have some logic flaw.
Maybe you have the 'Ajax on unique tag load completed' as a sub in the function ?
Or you forgot to reset the parameter in 'if parameter equals 1', so it keeps calling the function until 'load is completed'. Actual executing the 'load' several times in a row ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Mar 08, 2017 1:35 pm

I just included a sheet (for something totally different, in a sub event. It seems to include anyway, condition true or not.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Mar 08, 2017 1:39 pm

99Instances2Go wrote:Included event sheet acts as its events are in the base sheet.

You gots to have some logic flaw.
Maybe you have the 'Ajax on unique tag load completed' as a sub in the function ?
Or you forgot to reset the parameter in 'if parameter equals 1', so it keeps calling the function until 'load is completed'. Actual executing the 'load' several times in a row ?


Does the below screen grabs help to see what I have done wrong ? :

Image

Image
Regards

TimCS
B
23
S
8
Posts: 130
Reputation: 1,917

Post » Wed Mar 08, 2017 2:38 pm

Well 4get my previous (dumb) comments.

Another (maybe dumb) question. I suppose that is not the complete event sheet. Do the other events in the sheet run (showing you results/partial results) before the loading/parsing is complete ?

It can be partial, because 'on complete' is a trigger. A trigger interrupts, performs its actions/conditions, then the 'tick header' returns there were it was.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Mar 08, 2017 6:00 pm

@99Instances2Go

The first image is from the main event sheet and yes there are other events there as well. However the other events are called based on functions so until the GetRandomQuestions is called, the others do not start.

In the second image, this is the entire contents of that sheet and that as you can tell is the sheet I am calling to load the files. I hope this answers your questions

When I get chance I will post that function (GetRandomQuestions) but I know that it worked when I called it from within the same event sheet
Regards

TimCS
B
23
S
8
Posts: 130
Reputation: 1,917

Post » Wed Mar 08, 2017 7:18 pm

Would like to debug the project. Has me puzzled at this point.
Do you trust me enough to PM me the project?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Mar 08, 2017 10:09 pm

99Instances2Go wrote:Would like to debug the project. Has me puzzled at this point.
Do you trust me enough to PM me the project?


@99Instances2Go , well I am either imagining things or in the throws of changing things about , it now appears to be working. So hopefully without any additions to the events just simply re-enabled some of the logic that I disabled which was me just trying things out got it to work. Hmmm will have to watch this carefully next time

Thanks anyway
Regards

TimCS
B
23
S
8
Posts: 130
Reputation: 1,917


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 5 guests