Author Topic: is there a way to make control arrays in wxSmith?  (Read 3066 times)

Offline ouch

  • Almost regular
  • **
  • Posts: 223
is there a way to make control arrays in wxSmith?
« on: April 21, 2008, 09:06:10 pm »
I could really use them for my project but I can't seem to be able to find a way to do it. anytime I enter a non standard character for the control's variable wxsmith strips it out.

to better describe what I'm talking about see below:

Code
wxTextCtrl TextCtrl[2];

    TextCtrl[0] = new wxTextCtrl(Panel2, ID_TEXTCTRL0, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL0"));

    TextCtrl[1] = new wxTextCtrl(Panel2, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));

    TextCtrl[2] = new wxTextCtrl(Panel2, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));

//Then later on:

for (i=0;i<2;i++)
    {
     TextCtrl[i]->ChangeValue("written by an array!");
    }

you can also do something simular (but less elegant) with wxArrays. But wxSmith doesn't let you use that method either.

I'm pretty much stuck on my project till I can solve this.
« Last Edit: April 21, 2008, 09:41:17 pm by ouch »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: is there a way to make control arrays in wxSmith?
« Reply #1 on: April 21, 2008, 09:35:42 pm »
Code
wxTextCtrl TextCtrl[2];
[...]
    TextCtrl[2] = new wxTextCtrl(Panel2, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
As you didn't describe what exactly happens: In case your app crashes: You are creating a vector of size 2 and write on position 3. This should definitely result in a crash. Probably this already solves your problem. ;-)

In additon: You are creating an array of objects but fill with pointers... probably you should start reading a book on C++?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline ouch

  • Almost regular
  • **
  • Posts: 223
Re: is there a way to make control arrays in wxSmith?
« Reply #2 on: April 21, 2008, 09:40:07 pm »
the problem is that I can't make the brackets on the variable in the first place. ;) wxSmith strips them out when you try to add them in the variable for the control.

if you try to do it outside of wxSmith of course it overwrites everything you do if you touch your GUI with it again.

that was just some example code to show what I would like wxSmith (or some other method) to do.