Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/21/d38531796/htdocs/jose/smfforum/Sources/Subs.php on line 3825
Get prepared to move on.

Author Topic: Get prepared to move on.  (Read 24492 times)

0 Members and 1 Guest are viewing this topic.

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Get prepared to move on.
« on: January 11, 2013, 02:44:59 PM »
Because it is my intimate conviction that PowerBASIC wouldn't survive to the passing of his creator.

I wonder if, except of BCX, you know some tools that could help translating PB's code to plain C ?

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #1 on: January 11, 2013, 05:17:09 PM »
Patrice,

The reason for the exclusion of Bcx or are you looking for another alternative?

I am looking for a new home for Bc9 (my bcx port) and hope to have both a new home and an update this month.
In my opinion, although biased , it is the only alternative for what you ask.

James

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #2 on: January 11, 2013, 05:31:06 PM »
James

Nothing special against BCX, except that it was unable to convert my PowerBASIC code.
It seems that i have first to convert to the BCX syntax (that is rather different from the current PB's one), and i would avoid the extra step of learning a new syntax.

...
« Last Edit: January 11, 2013, 05:35:03 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +30/-4
    • it-berater
Re: Get prepared to move on.
« Reply #3 on: January 11, 2013, 10:10:59 PM »
Patrice, I have good news for you: Your PB Compiler (while version 10) is still completely alive!
If we talk about newer versions ... thats another topic.
Possibly Steve could say more on this as he has deeper inside knowledge.


Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #4 on: January 11, 2013, 11:20:59 PM »
Quote
Your PB Compiler (while version 10) is still completely alive!

No it is not, and i say this because i can make fair comparisons with the other compilers i have already in my toolbox.

Remember the strong debate i had with Bob about a 64-bit version, and now two years later, there is still none... and Bob has passed.

I couldn't see, how Jim who has been at PB for less than 2 years, could take over a problem that Bob himself was not able to solve since so many years.

Indeed i should have moved to C for long, but i was afraid by the amount of work that it would imply to convert my existing PB/DLL code.
And this is the reason why i am looking now for a tool that could help me to move on.

Time for procrastination has passed.

...
« Last Edit: January 11, 2013, 11:30:38 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Israel Vega

  • Newbie
  • *
  • Posts: 22
  • User-Rate: +0/-0
Re: Get prepared to move on.
« Reply #5 on: January 12, 2013, 03:54:47 AM »
I know PowerBASIC source code is designed in TASM.  If there is no 64-bit version of TASM...is possible a new version
of PowerBasic with TASM?.  I ask this to see if the chances of a 64-bit version are real.  Some other compilers (how PureBasic)
are made in FASM...which also compiles to 64 bit.  I would prefer to convert PowerBasic to PureBasic code instead of C. 

Maybe it's time to evolve PowerBasic other platforms where you have no such dependence API'S...

"PureBasic compiles directly to x86, x86-64, PowerPC or 680x0 instruction sets, generating small standalone executables and DLLs which need no runtime libraries beyond the standard system libraries. Programs developed without using the platform-specific application programming interfaces (APIs) can be built easily from the same source file with little or no modification."
http://en.wikipedia.org/wiki/PureBasic
« Last Edit: January 12, 2013, 04:00:19 AM by Israel Vega »

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #6 on: January 12, 2013, 10:54:56 AM »
 Israel--

PureBasic has the same handicap that PowerBASIC, it is mainly based on the work of a very small (french-german) team, and i would not make twice the same mistake swaping the name of Bob Zale by the name of Frédéric Laboureur.

My problem is not to create work applications (i am using WinDev for that purpose, and so far i neverfound something that could beat its productivity), but to convert my 32-bit DLL to 64-bit without having to retype/convert all the code by hand.

BCX or BC9 (i don't know the difference) could be my solution to perform the conversion, but once i get the job done i will leave PowerBASIC for ever.

I was expecting for a 64-bit PB version, because that would have given me enough time to become fluent with C and perform the transition.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
To James C. Fuller
« Reply #7 on: January 12, 2013, 02:28:05 PM »
James--

Could you explain what is the difference between BCX and BC9.

I have downloaded BCX, from bcxbasic.99k.org
and also Pelles C, but the documentation looks old and refere to LLC only, not Pelles C.

Could you tell me exactly what is needed to try it.
What are the steps to follow in order to be able to translate current version of PB's code correctly ?

Thank you!
« Last Edit: January 12, 2013, 02:30:24 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #8 on: January 12, 2013, 03:02:07 PM »
Patrice,
  As of today Bc9 does not have a home but it is in my opinion the best choice.
  Bc9 is my fork of the current Bcx 6.x.x series. The latest BCX 6 series is available only from the BCX Yahoo group.
The original BCX is designed around optional parameters in function calls which is not ansi/iso c compatable.
Lcc and PellesC are the only "c" compilers that can compile the translated source.
That said many c++ compilers can compile the source but SCREAM LOUDLY with many warnings.

I suggest using bc9 with the MinGWTDM compiler suite. Just a -m32 -m64 compile switch for 32/64.
I will try to put together a new package today and post a link here or email you the link.

I just did the Pb HelloWin.bas -> bc9

You also should decide early on if you want need c++. c and c++ are two distinct different languages and many things
work differently.

James


PowerBASIC HelloWin.bas
Code: [Select]
'==============================================================================
'
'   HELLOWIN.BAS for PowerBASIC for Windows
'   Copyright (c) 1997-2011 PowerBASIC, Inc.
'   All Rights Reserved.
'
'   Translation of HELLOWIN.C from Charles Petzold's book:
'
'     "Programming Windows 95" published by Microsoft Press.
'     ISBN 1-55615-676-6
'
'   Note: The original code does not contain the "gradient" effect.
'
'==============================================================================

#COMPILER PBWIN 10
#COMPILE EXE
#DIM ALL

#INCLUDE ONCE "Win32API.inc"

#RESOURCE RES, "HelloWin.res"     ' this gives the program the "hellowin" icon


'==============================================================================
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG
'------------------------------------------------------------------------------
    ' Program entry point
    '--------------------------------------------------------------------------

    LOCAL Msg       AS tagMsg
    LOCAL wce       AS WndClassEx
    LOCAL szAppName AS ASCIIZ * 80
    LOCAL hWnd      AS DWORD

    ' Setup and register a window class for the main window
    ' CODEPTR is used to pass the address of the function that will
    ' receive all messages sent to any window created with this class
    szAppName         = "HelloWin"
    wce.cbSize        = SIZEOF(wce)
    wce.STYLE         = %CS_HREDRAW OR %CS_VREDRAW
    wce.lpfnWndProc   = CODEPTR(WndProc)
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInstance
    wce.hIcon         = LoadIcon(hInstance, "HELLOWIN")
    wce.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
    wce.hbrBackground = %NULL ' No class background, we do it outselves
    wce.lpszMenuName  = %NULL
    wce.lpszClassName = VARPTR(szAppName)
'    wce.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)

    RegisterClassEx wce

    ' Create a window using the registered class
    hWnd = CreateWindow(szAppName, _               ' window class name
                        "The Hello Program", _     ' window caption
                        %WS_OVERLAPPEDWINDOW, _    ' window style
                        %CW_USEDEFAULT, _          ' initial x position
                        %CW_USEDEFAULT, _          ' initial y position
                        %CW_USEDEFAULT, _          ' initial x size
                        %CW_USEDEFAULT, _          ' initial y size
                        %NULL, _                   ' parent window handle
                        %NULL, _                   ' window menu handle
                        hInstance, _               ' program instance handle
                        BYVAL %NULL)               ' creation parameters

    IF hWnd = 0 THEN  ' exit on failure
        MSGBOX "Unable to create window"
        EXIT FUNCTION
    END IF

    ' Display the window on the screen
    ShowWindow hWnd, iCmdShow
    UpdateWindow hWnd

    ' Main message loop:
    ' Messages sent to HELLOWIN while it has the focus are received by
    ' GetMessage().  This loop translates each message and dispatches it
    ' to the appropriate handler.  When PostQuitMessage() is called, the
    ' loop terminates which ends the application.
    DO WHILE GetMessage(Msg, %NULL, 0, 0)
        TranslateMessage Msg
        DispatchMessage Msg
    LOOP

    FUNCTION = msg.wParam

END FUNCTION


'==============================================================================
SUB DrawGradient (BYVAL hDC AS DWORD)
'------------------------------------------------------------------------------
    ' Custom draw procedure for gradiend fill
    '--------------------------------------------------------------------------

    LOCAL rectFill AS RECT
    LOCAL rectClient AS RECT
    LOCAL fStep AS SINGLE
    LOCAL hBrush AS DWORD
    LOCAL lOnBand AS LONG

    GetClientRect WindowFromDC(hDC), rectClient
    fStep = rectClient.nbottom / 200

    FOR lOnBand = 0 TO 199
        SetRect rectFill, 0, lOnBand * fStep, rectClient.nright + 1, (lOnBand + 1) * fStep
        hBrush = CreateSolidBrush(RGB(0, 0, 255 - lOnBand))
        Fillrect hDC, rectFill, hBrush
        DeleteObject hBrush
    NEXT

END SUB


'==============================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
                  BYVAL wParam AS DWORD, BYVAL lParam AS LONG) EXPORT AS LONG
'------------------------------------------------------------------------------
    ' WndProc is the message handler for all windows creating using the HelloWin
    ' class name.  A single WndProc procedure can handle multiple windows by
    ' testing the hWnd variable passed to it.
    '--------------------------------------------------------------------------

    LOCAL hDC    AS DWORD
    LOCAL pPaint AS PAINTSTRUCT
    LOCAL tRect  AS RECT

    ' The SELECT CASE is used to catch only those messages which the message
    ' handler needs to process.  All other messages are passed through the
    ' tests to the default handler.
    SELECT CASE wMsg

    CASE %WM_CREATE

    CASE %WM_PAINT
        hDC = BeginPaint(hWnd, pPaint)
        GetClientRect hWnd, tRect
        SetBkMode hDC, %TRANSPARENT
        SetTextColor hDC, %WHITE
        DrawText hDC, "Hello, Windows!", -1, tRect, %DT_SINGLELINE OR %DT_CENTER OR %DT_VCENTER
        EndPaint hWnd, pPaint
        FUNCTION = 1
        EXIT FUNCTION

    CASE %WM_ERASEBKGND
        hDC = wParam
        DrawGradient hDC              ' Pass the DC of the region to repaint
        FUNCTION = 1
        EXIT FUNCTION

    CASE %WM_DESTROY
        PostQuitMessage 0
        EXIT FUNCTION

    END SELECT

    ' Any message which is not handled in the above SELECT CASE reaches this
    ' point and is processed by the Windows default message handler.
    FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)

END FUNCTION



Bc9 HelloWin,bas

Code: [Select]
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Translation of PowerBASIC SDK example HelloWin
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

'Batch file for compiling
$ONEXIT "GWGCCW.BAT $FILE$ -m64 gui"

FUNCTION WINMAIN()
    DIM Msg         As MSG
    Dim wce           AS WNDCLASSEX
    Dim szAppName[80] As char     
    Dim hWnd          AS HWND
   
    szAppName$ = "HelloWin"
   
    wce.cbSize        = SIZEOF(wce)
    wce.style         = CS_HREDRAW OR CS_VREDRAW
    wce.lpfnWndProc   = WndProc
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInst
    wce.hIcon         = LoadIcon(hInst, "HELLOWIN")
    wce.hCursor       = LoadCursor(NULL, IDC_ARROW)
    wce.hbrBackground = NULL
    wce.lpszMenuName  = NULL
    wce.lpszClassName = szAppName$

    If RegisterClassEx(&wce) = 0 Then
        MsgBox "RegisterClass failed"
        Exit Function
    End If
   
    ' Create a window using the registered class
    hWnd = CreateWindow(szAppName$, _               ' window class name
                        "The Hello Program", _     ' window caption
                        WS_OVERLAPPEDWINDOW, _    ' window style
                        CW_USEDEFAULT, _          ' initial x position
                        CW_USEDEFAULT, _          ' initial y position
                        CW_USEDEFAULT, _          ' initial x size
                        CW_USEDEFAULT, _          ' initial y size
                        NULL, _                   ' parent window handle
                        NULL, _                   ' window menu handle
                        hInst, _               ' program instance handle
                        NULL)               ' creation parameters
   
    IF hWnd = 0 THEN  ' exit on failure
        MSGBOX "Unable to create window"
        EXIT FUNCTION
    END IF
   
    ' Display the window on the screen
    ShowWindow(hWnd, CmdShow)
    UpdateWindow(hWnd)

    ' Main message loop:
    ' Messages sent to HELLOWIN while it has the focus are received by
    ' GetMessage().  This loop translates each message and dispatches it
    ' to the appropriate handler.  When PostQuitMessage() is called, the
    ' loop terminates which ends the application.
    DO WHILE GetMessage(&Msg, NULL, 0, 0)
        TranslateMessage(&Msg)
        DispatchMessage(&Msg)
    LOOP
   
   

    Function = Msg.wParam
End Function
'==============================================================================
SUB DrawGradient (hDC AS HDC)
'------------------------------------------------------------------------------
    ' Custom draw procedure for gradiend fill
    '--------------------------------------------------------------------------

    Dim rectFill AS RECT
    Dim rectClient AS RECT
    Dim fStep AS SINGLE
    Dim hBrush AS HBRUSH
    Dim lOnBand AS int

    GetClientRect(WindowFromDC(hDC), &rectClient)
   
    fStep = rectClient.bottom / 200

    FOR lOnBand = 0 TO 199
        SetRect(&rectFill, 0, lOnBand * fStep, rectClient.right + 1, (lOnBand + 1) * fStep)
        hBrush = CreateSolidBrush(RGB(0, 0, 255 - lOnBand))
        FillRect( hDC, &rectFill, hBrush)
        DeleteObject( hBrush)
    NEXT

END SUB

'==============================================================================
CALLBACK FUNCTION WndProc()
'------------------------------------------------------------------------------
    ' WndProc is the message handler for all windows creating using the HelloWin
    ' class name.  A single WndProc procedure can handle multiple windows by
    ' testing the hWnd variable passed to it.
    '--------------------------------------------------------------------------

    Raw hDC    AS HDC
    Raw pPaint AS PAINTSTRUCT
    Raw tRect  AS RECT

    ' The SELECT CASE is used to catch only those messages which the message
    ' handler needs to process.  All other messages are passed through the
    ' tests to the default handler.
    Select Case CBMSG
        Case WM_PAINT
            hDC = BeginPaint(CBHNDL, &pPaint)
            GetClientRect(CBHNDL, &tRect)
            SetBkMode(hDC, TRANSPARENT)
            SetTextColor(hDC, RGB(255,255,255))
            DrawText(hDC, "Hello, Windows!", -1, &tRect, DT_SINGLELINE OR DT_CENTER OR DT_VCENTER)
            EndPaint(hWnd, &pPaint)
            FUNCTION = 1
        Case WM_ERASEBKGND
            hDC = (HDC)wParam
            DrawGradient(hDC)              ' Pass the DC of the region to repaint
            FUNCTION = 1
         Case WM_DESTROY
             PostQuitMessage(0)
    End Select
   
End Function

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #9 on: January 12, 2013, 03:07:55 PM »
Here is the "c" code

Code: [Select]
// *********************************************************************
// Created with bc9 - BASIC To C/C++ Translator (V) 9.1.0.3 (2013/1/10)
//                 BCX (c) 1999 - 2009 by Kevin Diggins
// *********************************************************************
//          Translated for compiling with an ANSI/ISO C Compiler
//                           On MS Windows
// *********************************************************************
#include <windows.h>    // Win32 Header File
#include <windowsx.h>   // Win32 Header File
#include <commctrl.h>   // Win32 Header File
#include <commdlg.h>    // Win32 Header File
#include <mmsystem.h>   // Win32 Header File
#include <shellapi.h>   // Win32 Header File
#include <shlobj.h>     // Win32 Header File
#include <richedit.h>   // Win32 Header File
#include <wchar.h>      // Win32 Header File
#include <objbase.h>    // Win32 Header File
#include <ocidl.h>      // Win32 Header File
#include <winuser.h>    // Win32 Header File
#include <olectl.h>     // Win32 Header File
#include <oaidl.h>      // Win32 Header File
#include <ole2.h>       // Win32 Header File
#include <oleauto.h>    // Win32 Header File
#include <winsock.h>    // Win32 Header File
#include <process.h>    // dos
#include <conio.h>      // dos
#include <direct.h>     // dos
#include <io.h>         // dos
#include <ctype.h>      // dos/linux
#include <fcntl.h>      // dos/linux
#include <math.h>       // dos/linux
#include <stdio.h>      // dos/linux
#include <string.h>     // dos/linux
#include <stddef.h>     // dos/linux
#include <stdlib.h>     // dos/linux
#include <setjmp.h>     // dos/linux
#include <time.h>       // dos/linux
#include <stdarg.h>     // dos/linux
#include <sys/types.h> 
#include <sys/stat.h>   


// *************************************************
//        User's GLOBAL ENUM blocks
// *************************************************

// *************************************************
//            System Defined Constants
// *************************************************

#define CCPTR const char*
#define cSizeOfDefaultString 2048

// *************************************************
//            User Defined Constants
// *************************************************


// *************************************************
//               Standard Prototypes
// *************************************************

// char*   BCX_TmpStr(size_t,size_t= 128,int= 1);
char*    BCX_TmpStr( size_t,size_t,int);
// char*   command (int=-1);
char*    command( int);
// *************************************************
//          User Defined Types And Unions
// *************************************************


// *************************************************
//                System Variables
// *************************************************

static char    SPC [2]={32,0};  /* Space */

// *************************************************
//            User Global Variables
// *************************************************

static PCHAR   *g_argv;
static int     g_argc;


// *************************************************
//               Standard Macros
// *************************************************

#define BOR |


// *************************************************
//               User Prototypes
// *************************************************

int     WINAPI WinMain (HINSTANCE,HINSTANCE,LPSTR,int);
void    DrawGradient (HDC);
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
void    DoCmdLine (void);

// *************************************************
//            User Global Initialized Arrays
// *************************************************



// *************************************************
//                 Runtime Functions
// *************************************************

#ifndef BCXTmpStrSize
#define BCXTmpStrSize  2048
#endif
char *BCX_TmpStr (size_t Bites,size_t  iPad,int iAlloc)
{
  static int   StrCnt;
  static char *StrFunc[BCXTmpStrSize];
  StrCnt=(StrCnt + 1) & (BCXTmpStrSize-1);
  if(StrFunc[StrCnt]) {free (StrFunc[StrCnt]); StrFunc[StrCnt] = NULL;}
#if defined BCX_MAX_VAR_SIZE
  if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)
  {
  printf("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\n",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);
  abort();
  }
#endif
  if(iAlloc) StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
  return StrFunc[StrCnt];
}


char *command (int nArg)
{
 register int i = 0;
 char *c = 0, *retstr, *s = GetCommandLine();
 if(nArg < i) // return entire commandline
    {
    while(*s && *s != 32) {
      if(*s == 34) while(*++s && *s != 34);
      s++;
      }
    while(isspace((unsigned char)*s))s++;
    retstr = BCX_TmpStr(strlen(s)+1,128,1);
    strcpy(retstr, s);
    if(*(retstr+strlen(retstr)-1)==20) *retstr=0;
    return retstr;
    }
  while(i <= nArg) {
    while(isspace((unsigned char)*s)) s++; // skip whitespace
    c = s;
    if(*s == 34) {                           // argument starts a quote
      while(*++s && *s != 34);          // skip till next quote
        if(*s) s++;                       // skip quote itself
    }
    else {
      while(*s && *s != 32) s++;
     }
    i++;
    }
  if(*c == 34) {
      c++;                                 // skip leading quote
      if(*(s-1) == 34) s--;                // skip any trailing quotes
    }
  retstr = BCX_TmpStr((s - c) + 1,128,1);
  strncpy(retstr, c, (s - c));
  retstr[s-c]=0;
  return retstr;
}



// ************************************
//       User Subs and Functions
// ************************************

int WINAPI WinMain (HINSTANCE hInst,HINSTANCE hPrev,LPSTR CmdLine,int CmdShow)
{
  static MSG      Msg;
  memset(&Msg,0,sizeof(Msg));
  static WNDCLASSEX  wce;
  memset(&wce,0,sizeof(wce));
  static char     szAppName[80];
  memset(&szAppName,0,sizeof(szAppName));
  static HWND     hWnd;
  memset(&hWnd,0,sizeof(hWnd));
  strcpy(szAppName,"HelloWin");
  wce.cbSize= sizeof( wce);
  wce.style= CS_HREDRAW  BOR  CS_VREDRAW;
  wce.lpfnWndProc= WndProc;
  wce.cbClsExtra= 0;
  wce.cbWndExtra= 0;
  wce.hInstance= hInst;
  wce.hIcon= LoadIcon( hInst,"HELLOWIN");
  wce.hCursor= LoadCursor( NULL, IDC_ARROW);
  wce.hbrBackground= NULL;
  wce.lpszMenuName= NULL;
  wce.lpszClassName= szAppName;
  if(RegisterClassEx( &wce)==0 )
    {
      MessageBox (GetActiveWindow(),"RegisterClass failed","",0);
      return 0;
    }
  hWnd= CreateWindow( szAppName,"The Hello Program", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL,(HMENU) NULL, hInst, NULL);
  if(hWnd==0 )
    {
      MessageBox (GetActiveWindow(),"Unable to create window","",0);
      return 0;
    }
  ShowWindow(hWnd,CmdShow);
  UpdateWindow(hWnd);
  while(GetMessage( &Msg,NULL,0,0))
    {
      TranslateMessage( &Msg);
      DispatchMessage( &Msg);
    }

  return Msg.wParam;
}


void DrawGradient (HDC hDC)
{
  static RECT     rectFill;
  memset(&rectFill,0,sizeof(rectFill));
  static RECT     rectClient;
  memset(&rectClient,0,sizeof(rectClient));
  static float    fStep;
  memset(&fStep,0,sizeof(fStep));
  static HBRUSH   hBrush;
  memset(&hBrush,0,sizeof(hBrush));
  static int      lOnBand;
  memset(&lOnBand,0,sizeof(lOnBand));
  GetClientRect(WindowFromDC(hDC), &rectClient);
  fStep= rectClient.bottom/ 200;
  for(lOnBand=0; lOnBand<=199; lOnBand+=1)
    {
      SetRect( &rectFill,0,lOnBand*fStep,rectClient.right+1,(lOnBand+1)*fStep);
      hBrush= CreateSolidBrush( RGB( 0, 0, 255- lOnBand));
      FillRect(hDC, &rectFill,hBrush);
      DeleteObject(hBrush);
    }

}


LRESULT CALLBACK WndProc (HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)
{
  HDC      hDC;
  PAINTSTRUCT  pPaint;
  RECT     tRect;
  if(Msg==WM_PAINT )
    {
      hDC= BeginPaint( hWnd,  &pPaint);
      GetClientRect(hWnd, &tRect);
      SetBkMode(hDC,TRANSPARENT);
      SetTextColor(hDC,RGB(255,255,255));
      DrawText(hDC,"Hello, Windows!",-1, &tRect,DT_SINGLELINE  BOR  DT_CENTER  BOR  DT_VCENTER);
      EndPaint(hWnd, &pPaint);
      return 1;
    }
  if(Msg==WM_ERASEBKGND )
    {
      hDC=( HDC) wParam;
      DrawGradient(hDC);
      return 1;
    }
  if(Msg==WM_DESTROY )
    {
      PostQuitMessage(0);
    }
  return DefWindowProc(hWnd, Msg, wParam, lParam); // CallBackFlag
}


void DoCmdLine (void)
{
  int      i=0;
  static char    cmd[32][cSizeOfDefaultString];
  static char*    argv[32];
  strcpy(cmd[0],SPC);
  for(;;)
    {
      if(strlen(command(i)))
        {
          strcpy(cmd[i],command(i));
          argv[i]  =( char*) cmd[ i];
        }
      else
        {
          goto L1003;
        }
      i++;
    }
L1003:;
  g_argc= i;
  g_argv= argv;
}




Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #10 on: January 12, 2013, 04:08:20 PM »
James--

Can i use VS 2010 Pro with BC9 ?

IF Answer = YES THEN
    How to setup BC9 for VS 2010
ELSE
    How to setup BC9 for MinGWTDM
END IF

Could you provide a detailed check list of everything needed to use BC9, including the batch file to produce either 32-bit or 64-bit from prompt.

Quote
I will try to put together a new package today and post a link here or email you the link.
Either way, would be nice, thank you!

...
« Last Edit: January 12, 2013, 04:30:50 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
BC9 / PB syntax differences
« Reply #11 on: January 12, 2013, 04:39:26 PM »
James --

It looks like BC9 is not 100% compatible with the current PB's syntax, implying that we have to edit first the PB's code?

For example we have to use DIM instead of LOCAL, and we can't have is list of common declarations onto the same line.
It understands only DDT CBMSG in the windproc instead of plain SDK syntax, and we have to add the "CALLBACK" reserved word in front of each callback.

Do you know if there is a complete list of all the differences ?

With such a list, i could write a utility to convert first my PB's code to the the BC9 syntax that seems to match only the ten years old PB's syntax.

...
« Last Edit: January 12, 2013, 04:41:45 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #12 on: January 12, 2013, 05:37:22 PM »
Patrice,
  Of course bc9 is not 100% compatible, but I doubt you'll find anything closer.
The package includes the RadAsm3 ide configured for bc9/BCX with all the batch files and instructions on it's
operation.

  I got a bit carried away with the shortcuts. One of the best aspects of Bc9 is it's versitility.
This is also quite acceptable:

Code: [Select]
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Translation of PowerBASIC SDK example HelloWin
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

'Batch file for compiling
$ONEXIT "GWGCCW.BAT $FILE$ -m64 gui"

FUNCTION WINMAIN(hInst AS HINSTANCE,hPrev AS HINSTANCE,CmdLine As LPSTR,CmdShow AS Integer) As Integer
    LOCAL Msg         As MSG
    LOCAL wce           AS WNDCLASSEX
    LOCAL szAppName[80] As char     
    LOCAL hWnd          AS HWND
   
    szAppName$ = "HelloWin"
   
    wce.cbSize        = SIZEOF(wce)
    wce.style         = CS_HREDRAW OR CS_VREDRAW
    wce.lpfnWndProc   = WndProc
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInst
    wce.hIcon         = LoadIcon(hInst, "HELLOWIN")
    wce.hCursor       = LoadCursor(NULL, IDC_ARROW)
    wce.hbrBackground = NULL
    wce.lpszMenuName  = NULL
    wce.lpszClassName = szAppName$

    If RegisterClassEx(&wce) = 0 Then
        MsgBox "RegisterClass failed"
        Exit Function
    End If
   
    ' Create a window using the registered class
    hWnd = CreateWindow(szAppName$, _               ' window class name
                        "The Hello Program", _     ' window caption
                        WS_OVERLAPPEDWINDOW, _    ' window style
                        CW_USEDEFAULT, _          ' initial x position
                        CW_USEDEFAULT, _          ' initial y position
                        CW_USEDEFAULT, _          ' initial x size
                        CW_USEDEFAULT, _          ' initial y size
                        NULL, _                   ' parent window handle
                        NULL, _                   ' window menu handle
                        hInst, _               ' program instance handle
                        NULL)               ' creation parameters
   
    IF hWnd = 0 THEN  ' exit on failure
        MSGBOX "Unable to create window"
        EXIT FUNCTION
    END IF
   
    ' Display the window on the screen
    ShowWindow(hWnd, CmdShow)
    UpdateWindow(hWnd)

    ' Main message loop:
    ' Messages sent to HELLOWIN while it has the focus are received by
    ' GetMessage().  This loop translates each message and dispatches it
    ' to the appropriate handler.  When PostQuitMessage() is called, the
    ' loop terminates which ends the application.
    DO WHILE GetMessage(&Msg, NULL, 0, 0)
        TranslateMessage(&Msg)
        DispatchMessage(&Msg)
    LOOP
   
   

    Function = Msg.wParam
End Function
'==============================================================================
SUB DrawGradient (hDC AS HDC)
'------------------------------------------------------------------------------
    ' Custom draw procedure for gradiend fill
    '--------------------------------------------------------------------------

    LOCAL rectFill AS RECT
    LOCAL rectClient AS RECT
    LOCAL fStep AS SINGLE
    LOCAL hBrush AS HBRUSH
    LOCAL lOnBand AS int

    GetClientRect(WindowFromDC(hDC), &rectClient)
   
    fStep = rectClient.bottom / 200

    FOR lOnBand = 0 TO 199
        SetRect(&rectFill, 0, lOnBand * fStep, rectClient.right + 1, (lOnBand + 1) * fStep)
        hBrush = CreateSolidBrush(RGB(0, 0, 255 - lOnBand))
        FillRect( hDC, &rectFill, hBrush)
        DeleteObject( hBrush)
    NEXT

END SUB

'==============================================================================
FUNCTION WndProc (hWnd AS HWND, Msg AS UINT, wParam AS WPARAM, lParam AS LPARAM) AS LRESULT

'------------------------------------------------------------------------------
    ' WndProc is the message handler for all windows creating using the HelloWin
    ' class name.  A single WndProc procedure can handle multiple windows by
    ' testing the hWnd variable passed to it.
    '--------------------------------------------------------------------------

    LOCAL hDC    AS HDC
    LOCAL pPaint AS PAINTSTRUCT
    LOCAL tRect  AS RECT

    ' The SELECT CASE is used to catch only those messages which the message
    ' handler needs to process.  All other messages are passed through the
    ' tests to the default handler.
    Select Case Msg
        Case WM_PAINT
            hDC = BeginPaint(hWnd, &pPaint)
            GetClientRect(hWnd, &tRect)
            SetBkMode(hDC, TRANSPARENT)
            SetTextColor(hDC, RGB(255,255,255))
            DrawText(hDC, "Hello, Windows!", -1, &tRect, DT_SINGLELINE OR DT_CENTER OR DT_VCENTER)
            EndPaint(hWnd, &pPaint)
            FUNCTION = 1
        Case WM_ERASEBKGND
            hDC = (HDC)wParam
            DrawGradient(hDC)              ' Pass the DC of the region to repaint
            FUNCTION = 1
         Case WM_DESTROY
             PostQuitMessage(0)
    End Select
    Function = DefWindowProc(hWnd, Msg, wParam, lParam)
End Function

One thing to note: I don't know whhat Pb does when a variable is defined as LOCAL.
This is what Bc9 does.

Code: [Select]
  static MSG      Msg;
  memset(&Msg,0,sizeof(Msg));
  static WNDCLASSEX  wce;
  memset(&wce,0,sizeof(wce));
  static char     szAppName[80];
  memset(&szAppName,0,sizeof(szAppName));
  static HWND     hWnd;
  memset(&hWnd,0,sizeof(hWnd));

Also I assume you realize all parameters in c/bcx are the exact opposite of PowerBASIC. Default is byval to pass by ref
you use the ampersand &myvar


A list of all the differences?? No. never needed one.


James

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #13 on: January 12, 2013, 06:58:14 PM »
James--

Link to small Test.bas DLL has been sent to you, because your gmail account does not accept zip attachment.

Thank you!
« Last Edit: January 12, 2013, 07:11:42 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #14 on: January 12, 2013, 08:48:43 PM »
Patrice,
  Update.
  I commented out all the 32bit dll declarations and it still compiled fine with PB so I assume they were not needed?
The other item is the bass.dll. Is there a 64bit version of it?

James