Well not totally a newbie to Basic, but totally new to PureBasic. I used to program a lot as a hobby. ZX 81 Basic, ZX Spectrum Basic, QL Basic and lastly GFA 3.5 on the Atari ST. That was long ago, maybe early 1990's. Clearly I have forgotten more than I knew. I am now a long way past retirement and looking for ways to pass time. I really enjoyed programming, but I am sure things have changed. When I programmed you had a fixed screen size and only one screen, (or window). So my very short test program ending in: Print "The results of the calculation found a possible ";particle;" number out of a possible ";samplesize. Produced nothing on the screen, but I learned you have to surround the text with brackets in PureBasic, which I did but still nothing. So I am guessing you need to create a window or something for the text to appear in?
Basically what I am asking of anyone who remembers Basic from before Windows. How much of a leap is it?
Newbie Question
Re: Newbie Question
Hello and welcome to the forums!
Pb can do a lot of things compared to old basics.
Try a console window first:
Pb can do a lot of things compared to old basics.
Try a console window first:
Code: Select all
OpenConsole("myconsole")
PrintN("Hello World")
Print("Hello ")
Print("World")
Input()
Re: Newbie Question
And Compiler Option Executable Format -> Console
The leap from console to GUI is gigantic.
But it is easy to manage with PureBasic.
Here is a template which I use for testing programmes.
Furthermore PureBasic has a very good help (F1) and also with a UserGuide for beginners
The leap from console to GUI is gigantic.
But it is easy to manage with PureBasic.
Here is a template which I use for testing programmes.
Code: Select all
;-TOP
#ProgramTitle = "Main Window"
#ProgramVersion = "v1.01.2"
Enumeration Windows
#Main
EndEnumeration
Enumeration MenuBar
#MainMenu
EndEnumeration
Enumeration MenuItems
#MainMenuAbout
#MainMenuExit
EndEnumeration
Enumeration Gadgets
#MainEdit
#MainButtonOk
#MainButtonCancel
EndEnumeration
Enumeration StatusBar
#MainStatusBar
EndEnumeration
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
; Resize gadgets
ResizeGadget(#MainEdit, 5, 5, dx - 10, dy - 45)
ResizeGadget(#MainButtonok, 10, dy - 35, 120, 30)
ResizeGadget(#MainButtonCancel, dx - 130, dy - 35, 120, 30)
EndProcedure
Procedure Main()
Protected dx, dy
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle)
; Menu
CreateMenu(#MainMenu, WindowID(#Main))
MenuTitle("&File")
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
MenuItem(#PB_Menu_About, "")
CompilerElse
MenuItem(#MainMenuAbout, "About")
CompilerEndIf
; Menu File Items
CompilerIf Not #PB_Compiler_OS = #PB_OS_MacOS
MenuBar()
MenuItem(#MainMenuExit, "E&xit")
CompilerEndIf
; StatusBar
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
; Gadgets
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
EditorGadget(#MainEdit, 5, 5, dx -10, dy - 45)
ButtonGadget(#MainButtonok, 10, dy - 35, 120, 30, "Ok")
ButtonGadget(#MainButtonCancel, dx - 130, dy - 35, 120, 30, "Abbruch")
; Bind Events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
; Event Loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main
Break
EndSelect
Case #PB_Event_Menu
Select EventMenu()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Case #PB_Menu_About
PostEvent(#PB_Event_Menu, #Main, #MainMenuAbout)
Case #PB_Menu_Preferences
Case #PB_Menu_Quit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
CompilerEndIf
Case #MainMenuAbout
MessageRequester("About", #ProgramTitle + #LF$ + #ProgramVersion, #PB_MessageRequester_Info)
Case #MainMenuExit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #MainEdit
Select EventType()
Case #PB_EventType_Change
;
EndSelect
Case #MainButtonOk
;
Case #MainButtonCancel
;
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
- Addict
- Posts: 1265
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Re: Newbie Question
Wombat wrote: Thu Apr 10, 2025 9:39 pmPrint "The results of the calculation found a possible ";particle;" number out of a possible ";samplesize.
Code: Select all
OpenConsole("myconsole")
samplesize.d = 9999
particle.d = 99
PrintN("The results of the calculation found a possible "+Str(particle)+" number out of a possible "+Str(samplesize)+".")
Input()
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."
Re: Newbie Question
You chose well to reintroduce programming with Purebasic. It has an editor and a debug window for quick calcs. And a form editor when you decide to try some basic windows and gadgets.
Though, don't get too caught up in the form editor, as it may be more instructive to hand code the gui and events you need.
Good luck!
Though, don't get too caught up in the form editor, as it may be more instructive to hand code the gui and events you need.
Good luck!
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum