The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
July 16, 2018, 02:25:22 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  Project Support Forums
| |-+  PowerBASIC Low Level Code
| | |-+  Learning PowerBASIC
« previous next »
Pages: [1] Print
Author Topic: Learning PowerBASIC  (Read 19517 times)
Richard van Petrov
Guest


Email
Learning PowerBASIC
« on: May 31, 2010, 03:33:36 PM »

What books can I pick up to learn PowerBASIC? The syntax and structure of the language.
Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: Learning PowerBASIC
« Reply #1 on: May 31, 2010, 04:03:41 PM »

Probably the best source is the vendor, they publish various bits and pieces but they also have a good support forum.
Logged

Regards,



Download site for MASM32
http://www.masm32.com
Richard van Petrov
Guest


Email
Re: Learning PowerBASIC
« Reply #2 on: May 31, 2010, 06:50:46 PM »

I have tried a Visual Basic 2005 book, but the dialect is different from PowerBASIC's because PowerBASIC doesn't have OOP support or a CLR. Should I try a Visual Basic 6 book?
Logged
Richard van Petrov
Guest


Email
Re: Learning PowerBASIC
« Reply #3 on: June 01, 2010, 12:50:58 AM »

According to Wikipedia (http://en.wikipedia.org/wiki/BASIC#Structured_BASIC) PowerBASIC is a second-dialect of BASIC.
Logged
frktons
Member
*****
Gender: Male
Posts: 1048



Re: Learning PowerBASIC
« Reply #4 on: June 01, 2010, 11:13:16 AM »

I have tried a Visual Basic 2005 book, but the dialect is different from PowerBASIC's because PowerBASIC doesn't have OOP support or a CLR. Should I try a Visual Basic 6 book?

The two languages are not entirely compatible, you have to rearrange something. To know what,
have a look at the on-line manuals of PowerBASIC.

Frank
Logged

Mind is like a parachute. You know what to do in order to use it :-)
Bob Zale
Guest


Email
Re: Learning PowerBASIC
« Reply #5 on: June 30, 2010, 06:35:00 AM »

Well, Richard, I guess you just can't trust those guys at Wikipedia...

PowerBASIC has excellent object support built right in.  Internal objects.  Com objects.  All sorts of good stuff.  The best suggestion for learning is to skip Visual Basic.  Read the PowerBASIC documentation.  Front to back.  It came with your compiler, and it's pretty comprehensive.  You can also read the complete doc online at the PowerBASIC web site.  Just GOTO www.powerbasic.com and click HELP DESK. 

Questions?  Email support@powerbasic.com  or  post a question on the PowerBASIC forums  or  perhaps ask it here?  PowerBASIC is one publisher that still offers 100% absolutely free tech support for life!

Best regards,

Bob Zale
PowerBASIC Inc.
Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: Learning PowerBASIC
« Reply #6 on: June 30, 2010, 09:52:34 AM »

Hi Bob,

Welcome on board. Always a pleasure to have another experienced assembler programmer floating around here and who has the expertise in PowerBASIC.  ThumbsUp
Logged

Regards,



Download site for MASM32
http://www.masm32.com
dedndave
Member
*****
Posts: 12523


Re: Learning PowerBASIC
« Reply #7 on: June 30, 2010, 11:42:37 AM »

welcome to the forum, Bob   ThumbsUp
Logged
Bob Zale
Guest


Email
Re: Learning PowerBASIC
« Reply #8 on: July 01, 2010, 10:00:01 AM »

Well, thank you!   Hope we can trade a little help and information.

Logged
José Roca
New Member
*
Posts: 24


Re: Learning PowerBASIC
« Reply #9 on: August 03, 2010, 03:07:01 AM »

 
A less advertised feature is that you can also work low-level, in a way not so much different than many of the code I'm seeing in this forum.

For example, this Iczelion tutorial

Code:
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib            ; calls to functions in user32.lib and kernel32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

.DATA                     ; initialized data
ClassName db "SimpleWinClass",0        ; the name of our window class
AppName db "Our First Window",0        ; the name of our window

.DATA?                ; Uninitialized data
hInstance HINSTANCE ?        ; Instance handle of our program
CommandLine LPSTR ?
.CODE                ; Here begins our code
start:
invoke GetModuleHandle, NULL            ; get the instance handle of our program.
                                                                       ; Under Win32, hmodule==hinstance mov hInstance,eax
mov hInstance,eax
invoke GetCommandLine                        ; get the command line. You don't have to call this function IF
                                                                       ; your program doesn't process the command line.
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT        ; call the main function
invoke ExitProcess, eax                           ; quit our program. The exit code is returned in eax from WinMain.

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
    LOCAL wc:WNDCLASSEX                                            ; create local variables on stack
    LOCAL msg:MSG
    LOCAL hwnd:HWND

    mov   wc.cbSize,SIZEOF WNDCLASSEX                   ; fill values in members of wc
    mov   wc.style, CS_HREDRAW or CS_VREDRAW
    mov   wc.lpfnWndProc, OFFSET WndProc
    mov   wc.cbClsExtra,NULL
    mov   wc.cbWndExtra,NULL
    push  hInstance
    pop   wc.hInstance
    mov   wc.hbrBackground,COLOR_WINDOW+1
    mov   wc.lpszMenuName,NULL
    mov   wc.lpszClassName,OFFSET ClassName
    invoke LoadIcon,NULL,IDI_APPLICATION
    mov   wc.hIcon,eax
    mov   wc.hIconSm,eax
    invoke LoadCursor,NULL,IDC_ARROW
    mov   wc.hCursor,eax
    invoke RegisterClassEx, addr wc                       ; register our window class
    invoke CreateWindowEx,NULL,\
                ADDR ClassName,\
                ADDR AppName,\
                WS_OVERLAPPEDWINDOW,\
                CW_USEDEFAULT,\
                CW_USEDEFAULT,\
                CW_USEDEFAULT,\
                CW_USEDEFAULT,\
                NULL,\
                NULL,\
                hInst,\
                NULL
    mov   hwnd,eax
    invoke ShowWindow, hwnd,CmdShow               ; display our window on desktop
    invoke UpdateWindow, hwnd                                 ; refresh the client area

    .WHILE TRUE                                                         ; Enter message loop
                invoke GetMessage, ADDR msg,NULL,0,0
                .BREAK .IF (!eax)
                invoke TranslateMessage, ADDR msg
                invoke DispatchMessage, ADDR msg
   .ENDW
    mov     eax,msg.wParam                                            ; return exit code in eax
    ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
    .IF uMsg==WM_DESTROY                           ; if the user closes our window
        invoke PostQuitMessage,NULL             ; quit our application
    .ELSE
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam     ; Default message processing
        ret
    .ENDIF
    xor eax,eax
    ret
WndProc endp

end start

roughly translates as:

Code:
#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"

FUNCTION WinMain (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, BYVAL lpszCmdLine AS ASCIIZ PTR, BYVAL nCmdShow AS LONG) AS LONG

   LOCAL hWndMain    AS DWORD
   LOCAL wc          AS WNDCLASSEX
   LOCAL szClassName AS ASCIIZ * 80
   LOCAL szAppName   AS ASCIIZ * 255

   ' Register the window class
   szClassName      = "SimpleWinClass"
   wc.cbSize        = SIZEOF(wc)
   wc.style         = %CS_HREDRAW OR %CS_VREDRAW
   wc.lpfnWndProc   = CODEPTR(WndProc)
   wc.cbClsExtra    = %NULL
   wc.cbWndExtra    = %NULL
   wc.hInstance     = hInstance
   wc.hCursor       = LoadCursor (%NULL, BYVAL %IDC_ARROW)
   wc.hbrBackground = %COLOR_WINDOW + 1
   wc.lpszMenuName  = %NULL
   wc.lpszClassName = VARPTR(szClassName)
   wc.hIcon         = LoadIcon (%NULL, BYVAL %IDI_APPLICATION)
   wc.hIconSm       = LoadIcon (%NULL, BYVAL %IDI_APPLICATION)
   RegisterClassEx wc

   ' Window caption
   szAppName = "Our First Window"

   ' Create a window using the registered class
   hWndMain = CreateWindowEx(%NULL, _
                             szClassName, _
                             szAppName, _
                             %WS_OVERLAPPEDWINDOW, _
                             %CW_USEDEFAULT, _
                             %CW_USEDEFAULT, _
                             %CW_USEDEFAULT, _
                             %CW_USEDEFAULT, _
                             %NULL, _
                             %NULL, _
                             hInstance, _
                             BYVAL %NULL)

   ' Display the window
   ShowWindow hWndMain, nCmdShow
   UpdateWindow hWndMain

   ' Message handler loop
   LOCAL uMsg AS tagMsg
   WHILE GetMessage(uMsg, %NULL, 0, 0)
     TranslateMessage uMsg
     DispatchMessage uMsg
   WEND

   FUNCTION = uMsg.wParam

END FUNCTION

FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG

   SELECT CASE uMsg

      CASE %WM_DESTROY
         PostQuitMessage %NULL
         EXIT FUNCTION

   END SELECT

   FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)

END FUNCTION
Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: Learning PowerBASIC
« Reply #10 on: August 03, 2010, 03:40:28 AM »

Thanks Jose, nice example.

Attached is a bare template that I use from a tool that creates them. It has a toolbar and status bar with common dialog support.

* demo.zip (36.52 KB - downloaded 679 times.)
Logged

Regards,



Download site for MASM32
http://www.masm32.com
masm_diehard
New Member
*
Posts: 1


Re: Learning PowerBASIC
« Reply #11 on: October 05, 2011, 11:52:28 PM »

Bob,

Great to see you on this forum! I have used PowerBASIC for years and have been curious if it is developed using C++?

I have a requirement to acquire relatively high speed serial data in real time through multiple USB ports and I'm having problems with PBCC 6.0 and PB9.0 keeping up. That's what has brought me here. PowerBASIC has a lot of great features that I really like and find very useful. The graphics capabilities are excellent for data logging and display. I can't afford to give time slices away by putting "SLEEP" statements in my code so that windows can execute all of the "priority"...might I say "bloat" code that supports all of the other functionalities that are not priorities to me.

Hutch, Good examples! Your examples make me feel at home. I live another parallel life writing Microchip microcontroller assembly code!

Thanks guys!



 
Logged
dedndave
Member
*****
Posts: 12523


Re: Learning PowerBASIC
« Reply #12 on: October 06, 2011, 12:04:23 AM »

Bob pops in once in a while - that post was 2010   Tongue
you may have better luck finding him on the pb forum
Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: Learning PowerBASIC
« Reply #13 on: October 06, 2011, 02:42:59 AM »

Hi Chuck,

Welcome on board. If the data logging is a critical task it may be worth you putting it into a separate thread and limit how often it updates the display in the main thread. PB is a very useful dialect of Basic that has a decent assembler built into it, the later versions (10 & PBCC6) can come close to pure MASM code in places where you need it and if you are fussy it can be done without a stack frame if you know how to write that type of code.

Although MASM is my main programming language, PB is my preferred high level compiler as it is cleaner than many of the alternatives and can still do the low level grunt stuff where its needed.
Logged

Regards,



Download site for MASM32
http://www.masm32.com
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!