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 24494 times)

0 Members and 1 Guest are viewing this topic.

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #15 on: January 12, 2013, 11:17:19 PM »
I found there is a 64bit version of bass.dll.

I am working my way through the code and I am learning much.

 BYVAL / BYREF are supported so a lot less editing

James

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #16 on: January 13, 2013, 09:56:28 AM »
James--

Yes, there is a 64-bit version of Bass.dll (but so far i have not translated the header to 64-bit yet)
If BC9 is able to convert the existing PB's code correctly to 32-bit C (VS 2010), then that would be already a good step forward and i think i could start from there.

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

Offline Marc Pons

  • Newbie
  • *
  • Posts: 44
  • User-Rate: +1/-0
  • Programming for hobby
Re: Get prepared to move on.
« Reply #17 on: January 13, 2013, 01:26:10 PM »
Hy James

I am also interrested in BC9 , I tested some months ago using BCX with pelleC but the results where not very efficient.

May you post your software here , I've tried in the BCX forum, I was thinking it could be there, but I can't register.

Thank's,  Marc

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #18 on: January 13, 2013, 05:22:54 PM »
I am still working on a few issues for a new release.
I don't think a PowerBASIC board would be a place for such a package.

One thing that is mandatory for converting PB code to Bc9: Your PowerBASIC code must have #DIM ALL !

I will keep you updated here.

James

Offline Patrice Terrier

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

This section is not an exclusive PowerBASIC board, you can speak of any programming language or translator here.  ;D

...
« Last Edit: January 13, 2013, 06:05:50 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 #20 on: January 13, 2013, 06:44:08 PM »

While I look for a new home for bc9 would it be appropriate  to attach the package to a message here?
It's about 8000KB in rar format. 4400KB 7z but it appears that is not allowed.

James

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #21 on: January 13, 2013, 07:54:42 PM »
Perhaps you could you split it into two or three parts.

Then i would rebuild the whole package into one single ZIP file, and host it on my web-site,
then i could post a link here to download the full zip file for those who want it.

...
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
BCX compatibility
« Reply #22 on: January 13, 2013, 07:58:12 PM »
Quote
Hi Patrice,

In my experience, PB SDK style coding converted fairly well 70% - 80% with most issues being solved using search & replace in your favorite editor.

I haven't done much since PB 8.x, so I don't know how true that holds for PB9 /PB10.


Also, I only use BCX 6.22 (with a few personal modifications), so I don't can't say what issues you might experience with any of the newer variations of BCX.

My hunch is that for large blocks of code, BCX can do much of the translation pretty well but you should expect to have to do some editing of the translated code.


Hope that helps -- GOOD LUCK!

Kevin
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 #23 on: January 13, 2013, 08:07:53 PM »
Patrice,
  It states that max attachment per msg here is 12000KB so, unless there is a problem with hosting it here, it appears it is well under the max size???

James

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 597
  • User-Rate: +11/-8
Re: Get prepared to move on.
« Reply #24 on: January 13, 2013, 09:41:37 PM »
One thing to note and decide is if you want to ignore warnings.

Example.
This compiles fine but if warnings are on you'll get a warning on this code.

Pb and Bc9 code is the same
Code: [Select]
SUB SyncProc(BYVAL nSync AS LONG, BYVAL nChannel AS DWORD, BYVAL nData AS LONG, BYVAL nUser AS DWORD)
    LOCAL nRet AS LONG
    nRet = ChannelSetPosition(nChannel, gnPos, 0)
    IF nSync = gnLastSync AND WM_BASSSYNC THEN PostMessage(nUser, WM_BASSSYNC, 0, 0)
END SUB

translation
Code: [Select]
void SyncProc (long nSync,DWORD nChannel,long nData,DWORD nUser)
{
  static long     nRet;
  memset(&nRet,0,sizeof(nRet));
  nRet= ChannelSetPosition( nChannel, gnPos, 0);
  if(nSync==gnLastSync&&WM_BASSSYNC )
    {
      PostMessage(nUser,WM_BASSSYNC,0,0);
    }
}


warning: passing argument 1 of 'PostMessageA' makes pointer from integer without a cast [enabled by default]

gcc wants nUser to be of type HWND

The warning actually tells you what it wants so you don't have to go look it up.

note: expected 'HWND' but argument is of type 'DWORD'


James
« Last Edit: January 13, 2013, 09:46:06 PM by James C. Fuller »

Offline Frederick J. Harris

  • Hero Member
  • *****
  • Posts: 914
  • User-Rate: +16/-0
    • Frederick J. Harris
Re: Get prepared to move on.
« Reply #25 on: January 14, 2013, 03:44:04 AM »
interesting read on the 'Unreasonable Effectiveness Of C' ...

http://damienkatz.net/2013/01/the_unreasonable_effectiveness_of_c.html

fred

Offline Frederick J. Harris

  • Hero Member
  • *****
  • Posts: 914
  • User-Rate: +16/-0
    • Frederick J. Harris
Re: Get prepared to move on.
« Reply #26 on: January 14, 2013, 03:55:34 AM »
Quote
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:



I'm glad you posted that James.  I was studying your examples, and couldn't imagine what happened to the parameters to WinMain() and WndProc() in the BC9 version!

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: Get prepared to move on.
« Reply #27 on: January 14, 2013, 10:26:24 AM »
James--

I do not agree with the translation of the PowerBASIC LOCAL keyword, into C static

In PowerBASIC, Local variables retain their values only until the end of the procedure.

In C, when you declare a variable in a function, the static keyword specifies that the variable retains its state between calls to that function. It means it is exatly the same than using the STATIC powerBASIC keyword.

However in C, when you declare a variable or function at file scope (global and/or namespace scope), the static keyword specifies that the variable or funcion has internal linkage. Whe you declare a variable, the variable has static duration and the compiler initializes it to 0 unless you specify another value.

See below the use of the static keyword outside procedure or function to mimic a string constant:
Code: [Select]
// GDImage.cpp : définit les fonctions exportées pour l'application DLL.
//
#include <windows.h>
#include <iostream>
#include <string.h>

#include "stdafx.h"
#include "GDImage.h"

typedef struct {
HWND    hWnd;
LONG anchor;
RECT rc;
LONG TiledBitmap;
CHAR order[METADATA_SIZE];
LONG ordersize;
LONG WMBit[25];
DWORD WMCodePtr[25 * 32];
LONG centerx;
LONG centery;
LONG Composited;
} ZIMAGEPROP;

static char *Version = "6.06";

/* Add two integers */
//_declspec (dllexport) long add_num(long a, long b){
//     return((long)(a+b));}
long add_num(long a, long b){
     return((long)(a + b));}

char* ZI_Version () {
    return Version; // Version number of the form "#.#"
}

Indeed, inside the SyncProc procedure
PB: LOCAL nRet AS LONG
should be just translated to
C: long nRet (without the static keyword)

...
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
Re: Get prepared to move on.
« Reply #28 on: January 14, 2013, 10:36:49 AM »
Fred,

I totaly agree with Damien Katz, for a SDK coder like myself, C it is the only manageable way to replace my existing PB's SDK code, to keep producing small, fast, and runtime free DLLs.

...
« Last Edit: January 14, 2013, 02:03:29 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 #29 on: January 14, 2013, 01:47:58 PM »
Patrice,
  In actuality LOCAL in bc9 works the same as PowerBASIC. Why the static I don't know but the results are the
same although the initialization each time the function is called is overhead that might want to be considered.
Note the AS type may also follow the var as in:
  Raw I2 As Integer

From the help file:
A variable dimensioned with DIM or LOCAL in a subroutine or function retains the value on exit,
but will lose it on re-entry due to the automatic initialization.
James

This bc9 line
Code: [Select]
LOCAL AS Integer I1

produces this c code

Code: [Select]
  static int      I1;
  memset(&I1,0,sizeof(I1));


These are 4 different ways to declare variables.
here is bc9 sample code
Code: [Select]
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'Test LOCAL,RAW
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

$NOMAIN
$ONEXIT "GWGCC.BAT $FILE$ -m32 con"
Sub DoTest()
    LOCAL AS Integer I1
    RAW AS Integer I2
    Raw As Integer I3=0
    STATIC As Integer I4
   
    Print "I1 = ", I1
    PRINT "I2 = ", I2
    PRINT "I3 = ", I3
    PRINT "I4 = ", I4
    PRINT "----------"
    I1 = 1
    I2 = 2
    I3 = 3
    I4++
    PRINT "I1 = ", I1
    PRINT "I2 = ", I2
    PRINT "I3 = ", I3
    PRINT "I4 = ", I4       
End Function
'==============================================================================
Function main(argc As Integer,argv As PCHAR ptr ) As Integer
Raw As Integer i

For i = 1 To 3
    DoTest()
    PRINT "********"
Next
Pause
End Function



c translation:
Code: [Select]
SNIP

void DoTest (void)
{
  static int      I1;
  memset(&I1,0,sizeof(I1));
  int      I2;
  int      I3=0;
  static int      I4;
  printf("%s% d\n","I1 = ",(int)I1);
  printf("%s% d\n","I2 = ",(int)I2);
  printf("%s% d\n","I3 = ",(int)I3);
  printf("%s% d\n","I4 = ",(int)I4);
  printf("%s\n","----------");
  I1= 1;
  I2= 2;
  I3= 3;
  I4++;
  printf("%s% d\n","I1 = ",(int)I1);
  printf("%s% d\n","I2 = ",(int)I2);
  printf("%s% d\n","I3 = ",(int)I3);
  printf("%s% d\n","I4 = ",(int)I4);
}


int main (int argc,PCHAR* argv)
{
  int      i;
  for(i=1; i<=3; i+=1)
    {
      DoTest();
      printf("%s\n","********");
    }

  Pause();
  return 0;
}


and the output:

I1 =  0
I2 =  0
I3 =  0
I4 =  0
----------
I1 =  1
I2 =  2
I3 =  3
I4 =  1
********
I1 =  0
I2 =  0
I3 =  0
I4 =  1
----------
I1 =  1
I2 =  2
I3 =  3
I4 =  2
********
I1 =  0
I2 =  0
I3 =  0
I4 =  2
----------
I1 =  1
I2 =  2
I3 =  3
I4 =  3
********
« Last Edit: January 14, 2013, 01:50:25 PM by James C. Fuller »