Best way to start

  1. 3 weeks ago

    This may seem lame. But I code in a Basic now. I want to learn Xojo and I see the get started stuff. But what is the best way to really get started when I have a project to do and I want to do it in Xojo. I have watched a couple of webinars, but I don't quite understand when a method is needed and some of the other OOP things.

    Thanks
    milfredo

  2. Mark C

    Nov 24 Pre-Release Testers, Xojo Pro Spain 35510

    Hi Milford,

    nothing lame about asking questions, nor answering them.

    I am being very simplistic in this answer, but accurate enough I hope!

    whatever BASIC you use must have the following:-
    subroutine
    function

    these are exactly what a 'method' is, in Xojo the method can either be a subroutine, runs code, has no parameters, returns nothing or a function, runs code, with optional parameters and can return a value, as I understand the 'method' name it is a convention, and nothing to do with OOP, it could just as easily be called 'BlockOfCodeThatDoesStuff'.

    do not worry about OOP, a large amount of the OOP in the language is very well hidden by the IDE (which make starting to learn the language quite simple).

    the best way I found to work with the system is to take one of the EXAMPLES that might interest you, then change SMALL things to do additional functions.
    the most important part is write the code, run it and see what happens, the computer will not blow up.

    I have used Xojo for many years and I still do not really know if I am writing OOP code, and to be honest I do not think about it, I make applications for my customers, none of them have said 'I hope its an OOP application', they just want it to work on several platforms and not to be noticed when in use, they pay me and thats it.

    just write some code and see what happens, there is a wealth of help available on this forum, but its likely you will be asked by any of the contributors to actually post some code to support a specific request.

    best of luck!

  3. Mark S

    Nov 24 Pre-Release Testers, Xojo Pro, XDC Speakers

    This is a bit general response.

    With Xojo you can either fully embrace OOP methods or program like you would with Visual BASIC 6. That is one of the reasons I like Xojo. I am NOT an OOP purest and Xojo lets me code with a style where I am comfortable. For me OOP does not always make code better or easier to understand.

    Because Xojo can do Desktop, Web, and iOS programs I would suggest starting to learn with a Desktop app. The coding will transition among different types of apps but unless you are pretty fluent in Web or iOS these will add many more things to learn in addition to Xojo itself.

    Pick out one of the example programs and see how it is put together. Next think of some very simple project even if it is not something useful and get that working. From there hopefully you will get the feel of building Xojo apps.

    The dialect of BASIC in Xojo is fairly typical but some things, like file I/O, are different that many BASIC implementations.

    If you get stuck post here with your questions. Try to be as specific as you can and even post some code snippets if that might help clarify your questions.

  4. Dave S

    Nov 24 San Diego, California USA

    What version of "BASIC" are you currently using. Xojo is in many ways similar to VB.NET (not the same, just similar)

    A "form" in VB.NET is a "window" in Xojo... and can contain visual controls, as well as events, and "methods"
    In VB.Net you have SUB and FUNCTION , in Xojo you have "methods"... which may or may not return a value (ie. function)
    In Xojo you have Modules (same in VB.NET if I recall), and these can contain variables, and methods not directly associated to a window

  5. Thanks guys. I write in Liberty Basic. I write Horse racing Handicapping programs. I will do as you guys suggest. I will grab an example and try and understand it. The thing that is confusing a bit is when watching the webinars, I see the steps but the reason for those steps often are not clear.

    Thanks again.

  6. Mark C

    Nov 24 Pre-Release Testers, Xojo Pro Spain 35510

    I never have seen a webinar.
    whatever logic you use in the current code will be transferable to Xojo, the syntax is going to be the difference for sure.

    try the examples, most certainly do not try to make a massive project from new and have to learn 50 new things in one go.
    something will fail and leave you thinking its Xojo that is bad when a lack of experience is the issue.

    it is a journey that is likely to be fruitful in time.

  7. 2 weeks ago

    Mark S

    Nov 26 Pre-Release Testers, Xojo Pro, XDC Speakers

    Milford,

    I think coming from Liberty BASIC you will find Xojo will provide an environment that lets you create better user interfaces with much less effort. In Xojo you simply drag and drop controls to a form to create interactive screens. The core logic behind the screens will have syntax similar to Liberty BASIC but building programs will be done with event driven logic. Example: Click a button and it invokes a small (or big) block of logic to do something with "traditional" BASIC looking logic.

    If you have not done much event driven programming you might try to understand this:
    https://en.wikipedia.org/wiki/Event-driven_programming

    Here is a tutorial to build a desktop app in Xojo:
    http://developer.xojo.com/webinar-desktop-app-tutorial

    You will also find SQL database programming will make handling data much easier but if you have not used SQL you will need to some learning on that topic.

    But don't get too stressed. Remember ... to eat an elephant just take one bite at at time.

    Mark

  8. So here we go. I have a window with a pushbutton control on it so far. It's caption is Load Track. Now when it's clicked on here is the action code.
    Dim DataType As New FileType
    DataType.Name = "*/jcp"
    DataType.Extensions = "jcp"

    Dim f As FolderItem
    f = GetOpenFolderItem( DataType )
    If f <> Nil Then
    MsgBox(f.ModificationDate.ShortDate)
    End If

    What that does is open access to directory with all the race data files. The user then selects a data file to import.
    I have looked around quite a bit, but can not find how to read a csv file. I assume that I will create a Class Horse with a bunch of properties to store the end result of the manipulated data for each horse. And then store an instance of that class for each horse into an array... Yes/No? In Liberty I read each data field into a large array, manipulate the data I need to work with and then store the results in a Record. in a random access file.. Which is basically another array of a class or An array of a large dictionary.

    I could use some guidance and where to find the info I need to solve this next step.

    Thanks Guys. I seem to learn better when working on a project that is dear to my heart and that I understand fully.

  9. Dave S

    Nov 27 San Diego, California USA

    You need to of course read the data INTO your app... and that can be done many different ways.....
    but if it is a CSV file, then you also need to be able to parse that file.... the below example is just that.. .an example.
    It assumes that you have no commas IN the "data" meaning they are only delimiters, and the data contains no linefeeds except at the end of each record...... again .. this is a partial example only

    Dim DataType As New FileType
    DataType.Name  = "*/jcp"
    DataType.Extensions = "jcp"
    
    Dim f As FolderItem
    f = GetOpenFolderItem( DataType )
    If f <> Nil Then
    // open a text input stream
    Dim t As TextInputStream = TextInputStream.Open(f)
    // read the entire file into a string
    dim s as string = t.readall
    // split the string into individual lines
    dim v() as string=split(s,endofline)
    //
    for i=0 to v.ubound
        dim l() as string = split(v(i),",") // split line into comma delimited data
        for j=0 to l.ubound
             // do something with each field on the line
        next j
    next i
    
    End If

    again... just an example.. up to you to adapt to you particular needs , and there is various error checking, and other integrity checks that should be done.....

  10. Where can I find some documentation on reading a file? There are some commas in the data. I deal with that in Liberty. Probably similar work around in Xojo I would think.

  11. Dave S

    Nov 27 San Diego, California USA

    I would bet it might be almost word for word identical.... post how you think you might do it...

  12. I will. Found a webinar by Paul called fun with files...LOL. Watching it now and see what I can glean from it and then will start trying to code it.

  13. I added a text area to my window. Here is the action code. Taken directly from documentation...and the error code generated. Can't figure out how to correct so The info from the file selected by the user can be read and displayed in text area.

    Dim DataType As New FileType
    DataType.Name = "*/jcp"
    DataType.Extensions = "jcp"

    Dim f As FolderItem
    f = GetOpenFolderItem( DataType )

    Dim f FolderItem
    f = GetOpenFolderItem("")
    If f <> Nil Then
    Dim file As New Xojo.IO.FolderItem(f.NativePath )
    Dim stream As Xojo.IO.TextInputStream
    stream = TextInputStream.Open(file, Xojo.Core.TextEncoding.UTF8)
    TextArea1.Text = stream.ReadAll
    stream.Close
    End If
    ------------------------------------------------
    ERRORS...
    f = GetOpenFolderItem("")
    If f <> Nil Then
    Dim file As New Xojo.IO.FolderItem(f.NativePath)----------------Expects type Text but this is type string
    Dim stream As Xojo.IO.TextInputStream
    stream = TextInputStream.Open(file, Xojo.Core.TextEncoding.UTF8)----------Too many arguments, Got 2 expected 1
    TextArea1.Text = stream.ReadAll
    stream.Close
    End If

  14. Never mind. I am going to go through the documentation more. Need to get my head around this stuff a bit more before I go asking for specific help.

  15. Louis D

    Nov 28 Pre-Release Testers, Xojo Pro Montreal, QC, Canada

    Milford, while you are going through docs, I would suggest to remain with the classic framework as much as possible (except where there is a clear advantage to using the new framework). API 2.0 is just around the corner and will replace the new framework, to bring IOS development closer to the other platforms (among other objectives). There is a blog post on the topic. The classic framework will remain supported for quite a while after API 2.0 is introduced, so it is a safe bet to start learning Xojo. Also, the classic framework is closest to the old VB6, and from what I know of Liberty BASIC, it is also what is closest. This will ease the transition. One area where there is a clear advantage to using the new framework is the Date object, if you need to add or subtract time periods. Otherwise, the classic framework date object is just fine.

    And of course, welcome to the forum!

  16. Geoff P

    Nov 28 Xojo Inc Austin, Texas

    @milford w Thanks guys. I write in Liberty Basic. I write Horse racing Handicapping programs. I will do as you guys suggest. I will grab an example and try and understand it. The thing that is confusing a bit is when watching the webinars, I see the steps but the reason for those steps often are not clear.

    Thanks again.

    I suggest choosing a small app to write. Having some direction really helps with learning anything.

  17. Mark S

    Nov 28 Pre-Release Testers, Xojo Pro, XDC Speakers

    Geoff is correct. The best learning is when you are trying to do something concrete and familiar but using a new method (like switching to Xojo).

    In terms of just writing lines of code I think you will find disk file processing to be somewhat different than Liberty BASIC. Take a look at this example program (in the Xojo install folder under Example Projects / Files) to understand how to find a file you want to open with a dialog box.

    FolderItem Dialogs.xojo_binary_project

    I have some code that will process a CSV (Comma Separated Value) file. I will dig up a few chunks of code and post it here later today. You can use some of the example program above and the code I will post to load the CSV file into an array.

  18. Paul L

    Nov 28 Xojo Inc http://docs.xojo.com

    @milford w I have watched a couple of webinars, but I don't quite understand when a method is needed and some of the other OOP things.

    Welcome to Xojo!

    The Introduction to Programming book might be a good place to start.

    The Getting Started topic has links to lots of other information that you may find helpful as you learn Xojo:
    https://docs.xojo.com/GettingStarted:Welcome

  19. Thanks guys. Sometimes I think to much. Here is the code that takes me to where I can select a file to read.

    Dim f As New FolderItem
    f = GetOpenFolderItem("????")

    Now I will look at the example FolderItem Dialogs.xojo_binary_project and see what's in it.

    Thanks Mark. I look forward to seeing the CSV code.

  20. Marc Z

    Nov 28 Pre-Release Testers, Xojo Pro, XDC Speakers Oregon

    You might also check out xDev Magazine's Beginner's Guide:

    http://www.xdevmag.com/browse/15.3/

    It's not free, but the issue is only $10, and it walks you through a lot of basic things about getting started with Xojo.

  21. Newer ›

or Sign Up to reply!