Author Topic: OnGetNetPage vs OnLeave in New Project wizard  (Read 16226 times)

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
OnGetNetPage vs OnLeave in New Project wizard
« on: November 19, 2018, 05:34:55 pm »
Encountering an oddness, which I suspect is down to the order in which OnGetNetPage and OnLeave are executed.

I want to specifiy the next page in a wizard according to what is in the current page, but I cannot determine that until the OnLeave function is called, where I analyse the content of the page and set up somes variable accordingly. But it appears that OnGetNext is called before OnLeave (could be wrong, in which case something else is happening), so my tests to see what the next page should be fail as the variable are not yet set up.

Ideas?

In other news, having problems with the squirrel array.find function not working, giving a bad index error. Is that function supported in CB?

Jimbo

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #1 on: November 19, 2018, 10:30:16 pm »
Code
In other news, having problems with the squirrel array.find function not working, giving a bad index error. Is that function supported in CB?
Example code?
Are you using standard squirrel arrays or some wxWidgets binding?

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #2 on: November 20, 2018, 11:57:00 am »
Code
In other news, having problems with the squirrel array.find function not working, giving a bad index error. Is that function supported in CB?
Example code?
Are you using standard squirrel arrays or some wxWidgets binding?

Standard squirrel array, here some C&P from the wizard, not the actual code, and not tried to see if it works, but exactly same syntax as using in actual wizard.

Code
selectedLibraries<-array(0);

function fred()
{

  selectedLibraries.append(1);
  selectedLibraries.append(3);
  selectedLibraries.append(5);

  local idx =  selectedLibraries.find(5);    <<<<<<<< Gives a squirrel index [find] not found sort of error
}

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #3 on: November 20, 2018, 12:27:31 pm »
sadly we are using squirrel 2.2.5 and there the find methode does not exists...


@obfuscate: what about updating squirrel, without going to sqrat? Squirrel is now at 3.1 with tons of fixes and additions. 2.2 is 8 years old...

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #4 on: November 20, 2018, 03:09:18 pm »
sadly we are using squirrel 2.2.5 and there the find methode does not exists...


@obfuscate: what about updating squirrel, without going to sqrat? Squirrel is now at 3.1 with tons of fixes and additions. 2.2 is 8 years old...

Ah, that is what I was starting to suspect. It's not a problem, we have for loops...


Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #5 on: November 20, 2018, 06:00:51 pm »
sadly we are using squirrel 2.2.5 and there the find methode does not exists...


@obfuscate: what about updating squirrel, without going to sqrat? Squirrel is now at 3.1 with tons of fixes and additions. 2.2 is 8 years old...

I've also found that the string.slice funcion appears to be missing (same error) but that should be in Squirrel 2.2 which is odd.

Code
local s = _T("abcdefghijklmnop");
local s2 = s.slice(0,5);   <<<<<<<<< AN ERROR HAS OCCURED [the index 'slice' does not exist]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #6 on: November 20, 2018, 07:12:15 pm »
@jimbo: s is not a string type, it is wxString. Search the wiki for the function reference provided by C::B in squirrel scripts.

@bluehazzard: I'm fine if you can make 3.x work with SqPlus, but I think the two were incompatible. I could be wrong of course.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline jimbo

  • Multiple posting newcomer
  • *
  • Posts: 55
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #7 on: November 21, 2018, 11:01:49 am »
@jimbo: s is not a string type, it is wxString. Search the wiki for the function reference provided by C::B in squirrel scripts.

AhHa! Knew I was doing something stupid. Thanks.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #8 on: November 21, 2018, 10:58:54 pm »
Just a little update (and also a permanent note for me, because i do not want again debug a few hours for this)
Porting the scripting engine to 3.0 is not easy possible with sqplus, because squirrel 3.0 releases variables after poping from the internal stack.
This is basically not the problem, but sqplus always returns a reference as return value of squirrel functions. After the scripting function call sqplus stores the reference to the return value and cleans the stack. This will destroy the variable returned by the squirrel function, if this variable was only existent in this function. So the from sqplus stored reference to the return value is now invalid and sqplus returns an invalid reference to the c++ user code. This is very unfortunate. I tried to implement a function that returns a copy of the object , but then all non copyable script bindings (like the ProjectManager) can not be used anymore.
Maybe i split them out...
It is not trivial, and you have to be very carefully with the type of return value you use.
I do not remember how sqrat solves this problem...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #9 on: November 22, 2018, 12:27:42 am »
Ok, here is a repo with the updated squirrel code and fixed sqplus code.

https://github.com/bluehazzard/codeblocks_sf/tree/test/squirrel/update/31/1

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #10 on: November 22, 2018, 08:31:43 am »
As a start.
Can you make a patch where you carefully fix the problem with "base is now a keyword" and commit it? You're doing it for at least a second time, so I guess it doesn't hurt if we fix it in current version of squirrel.

But be careful, I don't think the current commit is correct. And do just a single thing in this commit.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #11 on: November 22, 2018, 11:48:24 pm »
But be careful, I don't think the current commit is correct. And do just a single thing in this commit.
Doh.... i was to fistrated yesterday from debugging the issue and made a quick search and replace... This was a BAD idea. Thank you for pointing it out...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #12 on: December 05, 2018, 10:31:34 pm »
Ok, this should be ok for the "base" keyword in the default scripts.
Can someone check this?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #13 on: December 06, 2018, 08:37:55 am »
I don't like using just different case.
It is pretty easy to make mistakes.
Isn't target more appropriate in most cases?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: OnGetNetPage vs OnLeave in New Project wizard
« Reply #14 on: December 10, 2018, 10:53:51 am »
You are right...
here it is