I just put a post in the PBWin forum, talking about the benefits of templates. I'm putting some suggested templates here.
These are the three templates I have in my PB IDE. I'm sure as I get more experience with PowerBASIC, that I'll find myself using templates with more and more code.
1. Modal dialog - nothing more
2. Test code with a button press
3. Test code within a Doevents loop
These can also be found and downloaded on my website at
http://www.garybeene.com/power/pb-tutor-templates.htm.
These are the three templates I have in my PB IDE. I'm sure as I get more experience with PowerBASIC, that I'll find myself using templates with more and more code.
1. Modal dialog - nothing more
Code:
1 .bas .Code Test - Modal Dialog, Empty #Compile Exe #Dim All #Include "win32api.inc" Global hDlg As Dword Function PBMain () As Long Dialog New Pixels, 0, "Test",300,300,200,200, %WS_OverlappedWindow To hDlg '... test code goes here Dialog Show Modal hdlg Call DlgProc End Function CallBack Function DlgProc() As Long '... test code goes here End Function
Code:
1 .bas .Code Test - Modal Dialog, Press Button #Compile Exe #Dim All #Include "win32api.inc" Global hDlg As Dword Function PBMain() As Long Dialog New Pixels, 0, "Button Test",300,300,200,200, %WS_OverlappedWindow To hDlg Control Add Button, hDlg, 100,"Push", 50,10,100,20 Control Add Label, hDlg, 101,"results", 50,40,100,20, %WS_Border Control Add Label, hDlg, 102,"results", 50,70,100,20, %WS_Border Dialog Show Modal hDlg Call DlgProc End Function CallBack Function DlgProc() As Long Select Case Cb.Msg Case %WM_Command Select Case Cb.Ctl Case 100 If Cb.CtlMsg = %BN_Clicked Then Local iResult1&, iResult2& '... test code here - place results in labels 100 & 101 Control Set Text hDlg, 101, Str$(iResult1&) Control Set Text hDlg, 102, Str$(iResult2&) End If End Select End Select End Function
Code:
1 .bas .Code Test - Modeless Dialog, Doevents Loop #Compile Exe #Dim All #Include "win32api.inc" Global hDlg As Dword Function PBMain() As Long Local Count& Dialog New Pixels, 0, "Test",300,300,200,200, %WS_OverlappedWindow To hDlg Control Add Label, hDlg, 100,"results", 50,50,100,20, %WS_Border Control Add Label, hDlg, 101,"results", 50,80,100,20, %WS_Border Dialog Show Modeless hDlg Do Dialog DoEvents 0 To Count& MySub Loop While Count& End Function Sub MySub Local iResult1&, iResult2& '... test code here - place results in labels 100 & 101 Control Set Text hDlg, 100, Str$(iResult1&) Control Set Text hDlg, 101, Str$(iResult2&) End Sub
http://www.garybeene.com/power/pb-tutor-templates.htm.
Comment