Need conceptual help

The problem i’m having here is more conceptual i think than coding. Knowing where everything is supposed to go. I have a main window that opens and has a menu and some submenus. They work fine. The edit submenu drops down and I click on a selection ie; Edit Tracks. A new window opens with 3 buttons and a listbox. In the open the listbox is populated from a file. The add button lets me add a track. The delete button lets me delete a track. All works great.

Now I am finished and need to click the save changes button. Here’s where it all goes down. I need to t5ake the new list box values and write back to the file. I have the write language correct I believe in the button action. But no matter what I seem to do, I can not get the updated listbox values. In the save button action I try and load up an array and I get the error “Cell” not a member when I try to get info from listbox cells.

I can not seem to find the answer anywhere. Where to put code to gain list values. How to access those values to write to file. As far as I can tell the list values in the listbox cells are local to the listbox. Once I leave the listbox open the info just goes out into never land. How does a new user figure out the logistics of where code needs to go? I have gone through the books, but they seem to only cover about half of a problem.

Maybe it’s just me.

Milfredo

why not LOAD the listbox in the Window2 Open Event
set a flag if the user add/deletes a record
then SAVE the contents of the listbox in the Window2 CLOSE event (if the flag was set)

or am I missing something from your workflow description?

Before the window2 closes I try and save the listbox info into an array when the save button is clicked. But get the error message, that the pushbutton has no member named cell which is what I have to access to get the listbox info. Without the array and the listindex number I can’t write info back out to file.

Didn’t I address this in another thread?

Maybe. If that had to do with the cell.append. That works to load the listbox data in the listbox open but after that, it errors when I try using the code in the pushbutton action.

I may just not be right for OOP programming. I may be best suited for procedeural programming. Looking at Pure Basic right now. Should be able to do what I want with it. And I understand whats going on and where the code has to go. I’m just a hobby programmer anyway.

Thanks,
Milfredo

Read “Head First Design Patterns”, see http://www.headfirstlabs.com/books/hfdp/. The best book by far on learning OO. After that book many things made sense to me where I thought before that this was too complicated for me. The code is in Java but it’s easy to translate to Xojo.

Procedural programming is a from the past and has limited use. Because the computer restrict the choices and actions of an enduser and therefore know where it is going and what is going to happen, makes it seems more easy to implement.

However with Xojo, that will never be possible. Very long ago, I also used procedural programming which I was very good in. Making the switch to OOP somewhere around 1995 gave me headaches and let me believe I better stayed with procedural programming. It took me until somewhere 2004 or 2005 when I switched definatelly to RealBasic (later RealStudio and now Xojo) that after a long while I grasps true OOP programming. It took me still some years to master OOP on the level I intended to master it. I still have very much to learn, even after more than 10 years using Xojo.

But I know one thing for sure : I do not want to return back to procedural programming ever again. With OOP so many interesting things are possible. It is possible to build so much Artificial Intelligence in your applications, which are simply not possible without OOP. Your end user can do so much, feel free and in control. And when you do things the correct way in OOP, it will make your programming life much easier and interesting.

Don’t give up on OOP, follow a good coarse (I follow coarses at Udemy which are very good) and believe in yourself. Believe in the goal to master OOP and Xojo. Xojo is so much better than PureBasic you mentioned. But for all those goodies to come true, there is a steep OOP learning curve. We all once get through that, nobody of us received it for free. We all had to learn, fall and standup again.

There is very good support here in this community. People will help you understand and learn. One day, you will be happy that you learned OOP because there is so much more possible with it. Back in 2005 I also almost have given up. But it was my determination, persistence and persueing perfecting my development skills which opened a bright new world.

I also read books about design patterns but I do not apply those design patterns by force. I do not say that I do not apply design patterns but my design patterns are inside my head. Nevertheless I do a lot of planning and thinking before even writing a single line of coding. Taking long walks, thinking about all facets of the application, how to implement its features, how the end user wants to interact with the application. When I am ready with that, I start creating the application itself. It may sounds unusual but it works. Even when I walk, I work! My wife (which is very much the opposite) became used to my behaviour because she knows that it leads to succesfully create solutions for our end users. And we do not have the need for a website of having clients.

Only you can decide for yourself if OOP is something for you. Make a good decision for yourself and once made persue your dreams and being the best in what you believe it is your way in making things done.

Wish you very much luck and all the best. Hope to see you again in the Xojo community, which is here to help you making your life easier.

When I started a long time ago, OOP did not exists. So I had ample time to see the difference.

Procedural programming is very much like giving tasks to a very stupid robotic maid :
1 - Swipe the floor 100 times (for next)
2 - If you find a toy, put it in the kids basket
3 - Make the bed
4 - Open the window to freshen the air
5 - Do something else

The very stupid maid is incapable of initiative

An OOP programmed robotic maid is much more intelligent. Instead of doing things sequentially, she does that upon things happening.

Event BedroomEnter : Check if the window is open ; if needed, open it ;
Event bedInShambles : make the bed
Event DustFound : Swipe the floor 100 times (for next)
Event ToyOnTheFloor : put in the kids basket

Apart from the first event which is mandatory, events may occur at any given time, the actions within the handler are independent. It is much easier to code for an intelligent robot.

When you add code to the pushbutton, you’ll have to explicitly refer to the listbox by name, ie listbox1.cell(x,y)

I think what you’re missing is the concept of context. Code added to the listbox can refer to itself like me.cell(x,y), or implicitly like cell(x,y). In the pushbutton’s code, writing cell(x,y) gives the compiler no hint about the listbox and so me.cell(x,y) is assumed and pushbutton.cell doesn’t exist.

It would be helpful if you posted your actual code. But this is one way that should work - obviously replace “myListBox” with the actual name of your listbox:
dim tab As String = Chr(9)
dim cr As String = Chr(13)
dim rowvalues(), content() As String
dim maxColumn As Integer = myListBox.ColumnCount-1
redim rowvalues(maxColumn)
dim maxRow As Integer = myListBox.ListCount-1
for row As Integer = 0 to maxRow
for column As Integer = 0 to maxColumn
rowvalues(column) = myListBox.Cell( row, column)
next
content.Append Join( rowvalues, tab )
next
dim contentstring As String = Join( content, cr )

Thanks everybody. I really appreciate your input. I like what I have done so far in Xojo, it’s just so damn frustrating. I don’t want to come off as whiny and sniveling, I just hate having to come here and ask questions all the time. Any way, I haven’t given up. I keep going back and forth. That’s one reson I come here and ask some of this stuff. So as to help me make up my mind.

Thanks again.
I’m going to read that book and see how that helps me. And thanks for the code snippet. I’ll see how that helps.

Have a great week everybody.

Milfredo

I think you should forget about OOP for the moment and concentrate on “Event Driven”. At least that’s how I moved from Cobol/Fortran/Interpreter Basic to the new world. Once you get your head around having to respond to events, objects sort of makes sense, which gives you a basis for OOP & design patterns. Surprisingly enough once you start using design patterns with OOP you sort of wonder how the fuck you managed to get anything done at all before.

So my suggestion for you now is to forget Objects. When adding anything to a window add all of the events - after dropping the thing (button or whatever) double click it and select all the events then add them. Choose which ones you’ll use and implement the code. You can clean up later by removing the unused events (only required for production code). Later you’ll know which events you’ll use and only add the events you require.

Once you’ve gotten you head around Event Driven you’ll be ready for objects - it won’t take long it’s the simplest first step, but that mindset is essential to the next step.

Robin, your code worked just fine. Thank you so much.

Milfredo

Great night. with help that I have gotten from you guys and encouragement, I was able to create Window3, populate a listbox from the file that was manipulated thanks to Robin’s code used in window2, and have the user select different values from the window3 listbox and populate another empty listbox in window3 with the users selections. I will code the delete button tomorrow hopefully and then write the user’s selections to a file to access later.

Pretty great feeling.

Thanks again guys.

Milfredo