• Welcome to Jose's Read Only Forum 2023.
 

Look at this before you compile your old code with PB 9

Started by Theo Gottwald, August 15, 2008, 10:20:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

Today I got to compile my first program with the new PowerBASIC for Objects 9.

It was not designed for the new compiler, it was just a big project made on PB 8.

Soon i realized, that i had to make some changes or else this project would not be compiled on the new PB 9.

1. First I had several Labels and MACRO Names (ME, ISWIN etc.) which are now reserved words.
These had to be changed.

Example:
MACRO FUNCTION ISWIN(P1) = (IsWindow(P1)<>0) 
Is now a reserved word. But as it seems to do just the same, as my MACRO before. So I just aded a comment.

2. I had this inside a Function
%X_CT_PROCESS_TERMINATE = &H1 

This was Ok in PB 8.04. Actually this is not more valid. It says "Must be outside SUB/FUNCTION/CLASS".

In fact these Compiler-variables have never been local therefore this is rather a clarification, not  really a disadavantage at this place. It can just be move a few lines up.

At another place this is a bigger problem.

I had a include file, which was called "MAININCLUDE" which contained several initializations and was called at the start of WINMAIN.
Also I had an Inlcude File called "Exitinclude" which was called at the End of WINMAIN.

These contain a lot fo things like this:

Something like this:
#IF NOT %DEF(%A_Mainincludes_INC)
%A_Mainincludes_INC=1 '<----- This Line is now invalid because it was in WINMAIN
'------------------------------------------------------------------------------------------------
   ' Mainincludes aus 009_WRS_ST.inc
   #IF %DEF(%WRS_Maininclude)
    DIM WI(%WR_ST)
   #ENDIF   

Now the second line becomes invalid. To keep it working i will need to change the whole code to use the

#INCLUDE ONCE

statement because this include file was protected from beeing multiple time inserted using the

%A_Mainincludes_INC=1

and this is not more going to work inside WINMAIN.

Therefore the #INCLUDE ONCE was really needed after this change. For new programms the new statement makes things easier.

Thinking a Moment on it, I believe that for me the ONCE is the normal State and to include something multiple times is rather seldom. Therefore I used a Replace Utility which replaced all "'INCLUDE "" with #INCLUDE ONCE "".

This was surprisingly one of a few things i needed to change to make it compile.

Also i can say that in terms of compiling speed it seemed to be as fast as PB 8.04 - not slower.
I wondered because we have one more Pass now (thats why we do not need declares anymore).



José Roca

Quote
Now the second line becomes invalid.

The second line doesn't become invalid. Just move the include outside WinMain. Constants aren't allowed to be declared inside a function, and including that file in WinMain, you are declaring the %A_Mainincludes_INC inside a function.

Theo Gottwald

The Include was Designed as a Collection of statements, which were to be inserted at the start of any WINMAIN.
Thats why they have been called "MAININCLUDE.inc".
This is just how an Initialization in an Object.
It still works, just had to use #INCLUDE ONCE instead of the other mechanism.
I have already solved the problem, however this code will never compile under PB 8.0x anymore.