From Dartmouth BASIC to Xojo

In the 1970s I taught Dartmouth BASIC to high schoolers. I was good with PRINT, LET, FOR-NEXT LOOPS, GOSUB-RETURN, and most everything else. Now, at the age of 79, I thought I’d try XOJO for fun. Quite a change!

Might there be any resource that would gently get me from the 1970s to the present? The videos I’ve found are probably good, but it’s the notation and the vocabulary that is taken for granted that can easily be a challenge. For example, I need to know how to “read the meaning” of dot notation which I don’t recall existing in BASIC. Dots are everywhere! And the reference areas are a jungle of new stuff. My kingdom for a resource to bridge the decades!

Another problem for me: I have a variable ‘Sum’ (I figured out the DIM Sum As Double) and a field also called ‘Sum.’ I can’t even figure out to get the value of ‘Sum’ (which is the sum of two other variables, FirstNumber and SecondNumber) into the field called ‘Sum.’ Back in the day, I could’ve written PRINT Sum and I’d have gotten the answer I wanted on screen. Now I want the answer to show up in the field I dragged onto the UI but I can’t.

Any kind words for this old guy?

Hi John,

You should try Xojo Docs and there are some great resources there (Getting started guide)

There is a learn programming with Xojo PDF Xojo PDF

Hi John! We have a textbook that might be a good refresher. We have a lot of videos on our YouTube channel. The Getting Started page has a lot of info that could help too.

Sum (the field) has a property named Value that you can read or set. You address it with that formidable dot notation

Sum.Value = “hello”

Sum (the integer) has a method named ToString that returns the string representation of the number - what PRINT used to do. Therefore, you can write

Sum.Value = Sum.ToString

I wish you well on this journey, and don’t be shy about asking questions. The forum is a friendly place.

‘Old’ basic was mainly simple types… integers, floats, strings

After those came compound types (‘structs’)
So you could create a type called Point, which represents an x,y co-ordinate
In old basic you might have done that with pointx and pointy
In Xojo, you would see that as

dim p as point
p.x = 6
p.y = 7

the dot means ‘thing you find inside of’

and you can think of it as

type Point x as integer y as integer end type

===

After structs came classes.
These are like structs, but carry self-contained subroutines.

Our point CLASS might have this (not xojo syntax here)

class Point x as integer y as integer sub moverightbyone() x = x+1 end sub end type

Now we could have

dim p as point p.x = 6 p.y = y p.moverightbyone

and the subroutine would cause the values of p to have become p.x = 7 p.y = 7

so, having moved away from simple types (‘primitives’) , now we have a lot of complex types, which bring functionality with them.
The main thing to remember with these complex types/classes is that unlike being able to just
dim x as integer

you have to initiialise a class by ‘creating a new one’, and sometimes pass parameters.

Eg   dim  pic as new picture(100,100)

as you should guess, ‘new’ actually calls one of these built in subroutines… in this case a hidden one called the constructor

Thats it for ‘what do the dots do’.
Good luck: Xojo is a great basic to learn with. And powerful enough to make a business from if you stick with it.

Good advice above. To provide some insight into “all the dots” … Xojo is a cross between Basic and Object Oriented Programming. A little research into Object Oriented might help (just google it for a bunch of info.)

I also came from “basic” basic back in the 70s. Did a lot with Visual Basic along the way - that has some object oriented things but its not consistent.

Print = System.DebugLog(“Hello World”) you could replace with a small global method in a module.
if you have a Label in the Window the Label have a .Value property but the type is String (Text) so you need to convert the double value to a string with .ToString or with the help of CType
you access propertys or class methods with the dot. and public or private scope meens they are visible from outside or not.
because xojo is a object-oriented programming language, usually objects are created with the new word or via a method that return this object.
ignore LET, just use a=5 but a must be declared inside of a method with dim or var
or need exists as property.
for next still exists and for each is more fun.
GOSUB abc is just abc where abc is a Method name
and if abc have parameters as input and a output value you would call the method x=abc(d,e,f)
RETURN still exists inside a method you can return a value as example with return x
in the method mini editor you must set the return type to string,integer,double,classname or something else what you need.
Method = Function
Class ? Object
Goto and Gosub was used before the encapsulation with Methods.
the best progress in this basic history are classes/objects somehow a encapsulation of modules and their memory which is very useful.
the example projects that came with xojo are good for learning this new enviroment.

Hi John,

Welcome. Some great advice above.

You have three main hurdles to get over in your transition from Dartmouth BASIC to Xojo. Firstly, you’re now programming for a graphical user interface environment - rather than outputting directly to the screen, you’re updating the values of controls that appear in your app. Xojo makes this stuff pretty easy. Secondly, while Xojo has its roots in BASIC (and many of us learnt programming using early BASICs), it has advanced a long way and is much more modern. It should have a familiar feel though. Thirdly, it’s object-oriented. This will likely be your hardest hurdle to overcome but, again, Xojo does a good job of simplifying OOP. This won’t make any sense to you now, but you’ll come to realise that everything in Xojo is OOP - you learn it rather naturally while using Xojo.

My advice would be to work your way through and fully understand the Desktop QuickStart at https://documentation.xojo.com/getting_started/quickstarts/desktop_quickstart.html and then pull apart the projects in the Examples folder that comes with Xojo. Finally, as @Tim Hare says, ask questions, we like to help.

Not an easy task. This days Xojo is making an effort to diferentiate more from the BASIC languaje. So, lots of what you can found in videos anda samples is now “deprecated” And yes, decades of using some keywords are now a problem.

It is best to avoid external resources for now, use the current xojo version with the oficial learning resources to avoid this problems: Xojo: Learn Xojo Programming

Considering your previous experience, I guess another characteristic of Xojo that can be confusing at first is that it is event driven.

Controls (like pushbutton, checkbox, listbox,…) and other elements you will be using in Xojo have events, and you will need to use them and respond to them. For example, if you create a new window the window.open event will fire and whatever code you put in that event will be executed. You could want to display the curret date somewhere on the window and use the window.open event to do that.

Another example: if a pushbutton is clicked by the user the pushbutton.mousedown event will fire, and you could code it to display a message, change the color of some control,…

Check the documentation for pushbutton (for example), and check its events.

Julen

I was in the small classes when we were both at school. I am only 69. Yet, I come from Applesoft Basic, IBM BASICA and Microsoft GWBasic, all much closer to Dartmouth than to Xojo.

I have actually ported the 1970 ELIZA source to Xojo. The result is in the Mac App Store.

There is no GOSUB in Xojo, but there are methods. So you can have a subprogram process things and return a value to the main program.

You will find next to the Xojo executable, example projects you can study.

Now, at the risk of shocking some, here is a way to program Xojo the old procedural way:

Add an event handler for the Open event of the main window (Window1). Right click on the window in the left hand side column of the IDE, and add “Open”.

In that event handler, you can very well program just the way we did back in the days. There is no Gosub alright, but Xojo kept GOTO. It is considered bad form by tenants of object oriented programming, but heck…

Little by little, you will start experimenting with methods, events, controls, and soon enough, you will feel at home.

Good luck :slight_smile:

Hi John,

I’m old-school BASIC too. I discovered XOJO around 2015 and had exactly the same issues that you mention. Suffice to say that I am now totally addicted to XOJO!
For me, the examples provided with the XOJO download were a great place to learn “how does that work, and why?”.
Also great advice above, especially the official learning resources provided by XOJO. Once I understood the general principles of XOJO, the details got much more intuitive.

As mentioned above - the .dot notation is just a really nice way of drilling down and addressing the “properties” and “methods” of each “thing”, where
things = Objects,
properties = Object characteristics,
methods = subroutines / functions (where subroutines just do a bunch of stuff and stop, and functions are subroutines which return a result / value / new object back to the caller)

As an aside - I would also just mention that, where I might have a variable called “Sum” and a text field called “Sum” I would usually name them like “vSum” and “txtSum” as that helps my ageing brain cells to keep up with the meanings of my code, and helps to avoid any ambiguity, particularly in cases where a variable object and a text box object might, potentially, have properties (ie .value) of the same name.

Enjoy the journey!

make sure not to use control name with these words like property, value, title and notes in your window

So many more great responses! Thanks.

I would say: If you want to learn Xojo and object oriented programming, forget about what used to be BASIC and read the Xojo textbook and view some webinars. In no time you will be into software development at current state of the art.

I agree with this. Knowing dartmouth BASIC makes sure most of the groundwork is set anyway, but it’s important to consider Xojo as a new language that might be familiar in places, rather than trying to force it to work as BASIC. It is possible, but you’d be creating limitations and weird scenarios that would be harder to troubleshoot.

Also, while not mentioned, it is possible to compile only command-line apps, which may be easier for smaller tasks and might provide a jumping point for GUI apps later on. To me the biggest hurdle really wasn’t the language or the IDE, but the enormous amount of cognitive load that comes from moving from terminal to GUI (this is not Xojo’s fault, and Xojo actually makes it easier to transition than most IDEs, including Apple’s own Xcode)