Converting POS application to xHarbour + FWH

Postby Antonio Linares » Thu Apr 10, 2008 7:43 am

Jose,

In 32 bits you use WriteComm() and ReadComm().

Why do you want to keep the 10 chars symbols names limitation ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xhbcoder » Thu Apr 10, 2008 4:54 pm

There are a lot of variables and functions in the source code that are more than 10 characters. I am thinking that it may create problem if these variables are not identical up to the last characters.

If we don't impose the 10 chars restriction, is there a way to work around with this?

Thanks,

Jose
xhbcoder
 
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Postby Antonio Linares » Thu Apr 10, 2008 6:16 pm

Jose,

The solution is to fix your code
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xhbcoder » Thu Apr 10, 2008 7:23 pm

Antonio,

How about compiler switch to restict to 10 characters limit?

Regards,

Jose
xhbcoder
 
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Postby Antonio Linares » Thu Apr 10, 2008 8:25 pm

Jose,

Then FWH will not work as it is not limited to 10 chars
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xhbcoder » Sat Apr 12, 2008 8:37 pm

Antonio,

I can create now an exe, but there's still a lot of code to rewrite.

Thanks,

Jose
xhbcoder
 
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Postby Antonio Linares » Sat Apr 12, 2008 8:59 pm

Have you considered to use #define's to replace names ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Conversion from clipper + fw24 to Xharbour + FWH

Postby xhbcoder » Mon Apr 28, 2008 1:04 am

Antonio,

I was able to convert the part of our system that is pure clipper code.

Now, I am starting the conversion of the main part of the system which is Clipper + FW24. I can create an exe but it generates an error as it start accessing classes.

Is there any particular compiler switch setting for Clipper + FW to access classes?

Any suggestion will be highly appreciated.

Thanks and regards,

Jose

Here's the error code.

Application
===========
Path and name: C:\pcrwin\PCREGW32.Exe (32 bits)
Size: 2,856,960 bytes
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 04/27/08, 17:21:26
Error description: Error BASE/1605 Invalid self: NEW
Args:
[ 1] = O Object
[ 2] = U

Stack Calls
===========
Called from: CRect.prg => CRECT:NEW(135)
Called from: CPcreg.prg => CPCREG:NEW(63)
Called from: PCREGW.PRG => WINMAIN(69)

System
======
CPU type: Intel(R) Celeron(R) CPU 2.93GHz 2933 Mhz
Hardware memory: 751 megs

Free System resources: 90 %
GDI resources: 90 %
User resources: 90 %

Compiler version: xHarbour build 0.99.71 Intl. (SimpLex)
Windows version: 5.1, Build 2600 Service Pack 2

Windows total applications running: 0

Variables in use
================
Procedure Type Value
==========================
CRECT:NEW
Param 1: A Len: 4
Param 2: C "Options"
Param 3: L .T.
Param 4: U
Param 5: L .T.
Local 1: O Class: CRECT
Local 2: C ""
Local 3: U
Local 4: O Class: TINI
Local 5: C ""
Local 6: L .F.
Local 7: U
Local 8: U
Local 9: U
Local 10: N 0
CPCREG:NEW
Local 1: O Class: CPCREG
Local 2: U
Local 3: U
Local 4: O Class: CPCREG
WINMAIN
Local 1: C "C:\WINDOWS\FiveWin.ini"
Local 2: U

Linked RDDs
===========
DBF
DBFFPT
DBFNTX
DBFBLOB

DataBases in use
================

Classes in use:
===============
1 HASHENTRY
2 HBCLASS
3 HBOBJECT
4 TDEBUGGER
5 TDBMENU
6 TDBMENUITEM
7 TDBWINDOW
8 GET
9 HBGETLIST
10 TBROWSE
11 TDATACACHE
12 TBCOLUMN
13 TWINDOW
14 TMDIFRAME
15 CPCREG
16 CRECT
17 TBRUSH
18 TFONT
19 TINI
20 ERROR
21 TREG32

Memory Analysis
===============
519 Static variables

Dynamic memory consume:
Actual Value: 0 bytes
Highest Value: 0 bytes
xhbcoder
 
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Postby Antonio Linares » Mon Apr 28, 2008 9:49 am

Jose,

Please post here the source code for line 135

Called from: CRect.prg => CRECT:NEW(135)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xhbcoder » Sun May 04, 2008 8:46 pm

Antonio,

Line 135: return nil

Regards,

Jose


For more information, I posted the crect class new method.

Line 135 is the last line


/*
* Class CRect created by George J. Hanson on 12/6/2000 0:34AM
*
*/

#include "FiveWin.ch"
#include "default.ch"

//----------------------------------------------------------------------------//

CLASS CRect

VAR nTop, nLeft, nBottom, nRight
VAR Maximized
VAR Name, Client, Modified

METHOD New( aRect, cName, lClient, oWnd, lMax ) CONSTRUCTOR
METHOD SetRect( aRect, oWnd )
METHOD GetRect( )

METHOD nWidth( )
METHOD _nWidth( nNewWidth )

METHOD nHeight( )
METHOD _nHeight( nNewHeight )

METHOD Changed( aRect )
METHOD Resized( aRect )
METHOD Move( nTop, nLeft, oWnd )
METHOD Apply( oWnd )

METHOD Save( oWnd )

METHOD End( )

ENDCLASS

//----------------------------------------------------------------------------//

/*
New( [aRect], [cName], [oWnd] )
New( GetWorkRect( ),'Main' )
*/

METHOD New( aRect, cName, lClient, oWnd, lMax ) CLASS CRect

local crect, aReadRect, oIni, cMaximized, Success := .f., oRect

default lClient := .t., lMax := .f.

::Client := lClient
::Modified := .f.

// Set the rect
::SetRect( aRect, oWnd )

if valtype(cName) == 'C'

// Try to load window position from Pcreg.ini
::Name := cName

* ini oIni file ".\Pcreg.ini"
ini oIni file "Pcreg.ini"

// Get Rect = {1,2,3,4}
cRect := oIni:Get( ::Name, "Rect", "" )

// Get Maximized = Y
cMaximized := oIni:Get( ::Name, "Maximized", "" )

if !empty(cRect)

// Rect is stored in ini
aReadRect := &cRect

if valtype( aReadRect ) == 'A' .and. len( aReadRect ) == 4

if lMax
// Move/reduce read rect to fit on screen
// Fixed issue with window position going negative 10/09/2003 05:14PM GJH
oRect := CRect():New( aReadRect )

oRect:Move( max( oRect:nTop, ::nTop ), max( oRect:nLeft, ::nLeft ) )

if ::nBottom < oRect:nBottom
oRect:nBottom := ::nBottom
oRect:nTop := min( 0, ::nBottom - ::nHeight )
endif
if ::nRight < oRect:nRight
oRect:nRight := ::nRight
oRect:nLeft := min( 0, ::nRight - ::nWidth )
endif

::Modified := oRect:Changed( aReadRect )
if ::Modified
::Save()
endif

// Set the read rect
::SetRect( oRect:GetRect() )

else

// Set the read rect
::SetRect( aReadRect )
endif

Success := .t.

else

// Must be array(4)
msgStop( '[' +cName +'] Rect = ' +cRect, 'Attribute Error in Pcreg.ini' )

endif
endif

// Saved the Maximized attribute
if !empty( cMaximized ) .and. cMaximized = '1'
::Maximized := cMaximized
// oWnd:Maximize()
else
::Maximized := '0'
endif

if Success

// Apply loaded rect to window if it exists
::Apply( oWnd )

endif

endif

return nil
xhbcoder
 
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Postby Antonio Linares » Tue May 06, 2008 6:48 am

Jose,

Please replace that line with:

return Self
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xhbcoder » Thu May 08, 2008 4:48 pm

Antonio,

The EXE is now showing the main Appplication screen.

I created an equivalent and dummy (function name and return only) for functions written in C so we could compile to create an executable.
The EXE is now flashing the main window but exits immediately.

The following is an error code when I tried to compile one of C source codes that was excluded that may be part of the main window.

LINE ERROR DESCRIPTION
44 error E2349 Nonportable pointer conversion in function WMCopyData
107 error E2342 Type mismatch in parameter 'hWndParent'(Wanted 'HWND_*,'got 'int') in function CREATEWINE
107 error E2342 Type mismatch in parameter 'hMenu'(Wanted 'HMENU_*,'got 'int') in function CREATEWINE
107 error E2342 Type mismatch in parameter 'iNUMBER'(Wanted 'int,'got 'HWND_') in function CREATEWINE
195 Warning W8065 Call to function 'GetWndApp' with no prototype in function CONNECT1
195 error E2342 Type mismatch in parameter "hwnd" (wanted 'HWND_*', got 'int') in function CONNECT1
229 error E109 Not an allowed type in function RECV1
0 ERROR *** 6 errors in Compile ***

Herewith I posted the COPYDATA.c for more info.

Thanks and regards,

Jose



/*
* COPYDATA.C written by George J. Hanson 11/13/2000 10:18PM
*/
#include "hbapi.h"
#include <stdio.h>

#include <Windows.h>
#define __WINDOWS_H
#include <ClipApi.h>
#include <WinSock.h>
#include <fwmsgs.h>

#define WM_COPYDATA 0x004A

extern HANDLE __hInstance;

/*
* lParam of WM_COPYDATA message points to...
*/
/*
typedef struct tagCOPYDATASTRUCT {
DWORD dwData;
DWORD cbData;
long lpData;
}

COPYDATASTRUCT, *PCOPYDATASTRUCT;
*/
/*
* Send a string to hWnd target using WM_COPYDATA
* Use CopyMemory API to copy to a Visual Basic String
* See modSubclass.bas
*
*/
CLIPPER WMCOPYDATA(/* hWnd target, hWnd sender, string ,dwData */)
{
HWND hWnd;
COPYDATASTRUCT cds;

hWnd = (HWND)_parni(1);

cds.dwData = _parnl(4);
cds.cbData = _parclen(3);
cds.lpData = (long)_parc(3);

if (hWnd && cds.cbData)
{
if (InSendMessage())
ReplyMessage(TRUE);
_retnl(SendMessage(hWnd, WM_COPYDATA, (WORD)_parni(2), (LONG)&cds));
}
else
_retnl(0);
}

/*
* Receive string passed from other app via WM_COPYDATA
*
*/
CLIPPER ONWMCOPYDA(/* wParam, lParam [, @dwData] */)
{
PCOPYDATASTRUCT pCds;

pCds = (PCOPYDATASTRUCT)_parnl(2);
if (PCOUNT()>=3)
_stornl(pCds->dwData,3);
if (pCds->cbData > 0)
_retclen( (LPSTR)pCds->lpData, (int)pCds->cbData );
else
_retc( "" );

ReplyMessage(1);
}

/*
*
* HWND CreateWindowEx(
* DWORD dwExStyle, // extended window style
* LPCTSTR lpClassName, // registered class name
* LPCTSTR lpWindowName, // window name
* DWORD dwStyle, // window style
* int x, // horizontal position of window
* int y, // vertical position of window
* int nWidth, // window width
* int nHeight, // window height
* HWND hWndParent, // handle to parent or owner window
* HMENU hMenu, // menu handle or child identifier
* HINSTANCE hInstance, // handle to application instance
* LPVOID lpParam // window-creation data
* );
*
*/
CLIPPER CREATEWINE() // ( nExtendedStyle, cClassName, cTitle, nStyle, nLeft, nTop, nWidth,
// nHeight, hWndOwner, hMenu, cExtraData ) --> hWnd
{
_retni( CreateWindowEx(_parnl( 1 ), // Extended style
_parc( 2 ), // Class
_parc( 3 ), // Title
_parnl( 4 ), // Style
_parni( 5 ), // Left
_parni( 6 ), // Top
_parni( 7 ), // Width
_parni( 8 ), // Height
_parni( 9 ), // Parent
_parni( 10 ), // Menu
__hInstance,
( PCOUNT() > 10 ) ? ( void FAR * ) _parc( 11 ): 0 ) ); // Address Window-Creation-Data
}

/*
* GetWorkRect() created by George J. Hanson on 12/15/2000 1:18AM
*
* Wrapper to SystemParametersInfo(SPI_GETWORKAREA,...
* Retrieves the size of the work area on the primary display monitor.
* The work area is the portion of the screen not obscured by the system taskbar
* or by application desktop toolbars. The pvParam parameter must point to a RECT
* structure that receives the coordinates of the work area, expressed in virtual
* screen coordinates.
*/

CLIPPER GETWORKREC() // --> { nTop, nLeft, nBottom, nRight }
{
RECT rct;

rct.top = 0;
rct.left = 0;
rct.bottom = 0;
rct.right = 0;

#define SPI_GETWORKAREA 48
SystemParametersInfo(SPI_GETWORKAREA,0,&rct,0);

_reta( 4 );
_storni( rct.top, (WORD)-1, 1 );
_storni( rct.left, (WORD)-1, 2 );
_storni( rct.bottom, (WORD)-1, 3 );
_storni( rct.right, (WORD)-1, 4 );
}


// Windows Socket: Connect
// Written 03/20/2003 09:37AM by George J. Hanson

// Add the _ prefix to these functions that are in fivewin's winapi.lib
unsigned long PASCAL FAR _inet_addr (const char FAR * cp);
int PASCAL FAR _connect (SOCKET s, const struct sockaddr FAR *name, int namelen);
u_short PASCAL FAR _htons (u_short hostshort);
int PASCAL FAR _recv (SOCKET s, char FAR * buf, int len, int flags);


CLIPPER CONNECT1() // ( socket, ipAddress|hostname, port, non-blocking ) --> int (0 on success or SOCKET_ERROR on failure)
{

SOCKET socket;
SOCKADDR_IN saServer;
LPHOSTENT lpHostEntry = NULL;
int rc;

socket = _parni(1);

saServer.sin_family = AF_INET;
saServer.sin_port = _htons( _parni(3) );
saServer.sin_addr.s_addr = _inet_addr( _parc(2) );


// Check if address valid ip address
if (saServer.sin_addr.s_addr == INADDR_NONE)
{

// Check if address is a valid hostname
lpHostEntry = gethostbyname( _parc(2) );

if ( lpHostEntry != NULL )

// Address is a valid hostname
saServer.sin_addr = *((LPIN_ADDR)*lpHostEntry->h_addr_list);

else

// No valid address
rc = SOCKET_ERROR;

}
// else address is a valid ip address

if (rc != SOCKET_ERROR)
{

// Connect
rc = _connect( _parni(1), (LPSOCKADDR)&saServer, sizeof(struct sockaddr) );

// Non-blocking
if (rc != SOCKET_ERROR && _parni(4))

rc = WSAAsyncSelect( socket, GetWndApp(), WM_ASYNCSELECT, FD_ACCEPT|FD_READ|FD_CLOSE|FD_CONNECT|FD_WRITE );

}

_retni( rc );

}


// This version uses first two parameters and return value like the original winsock recv function so errors can be detected.
// Uses a 4k buffer.
CLIPPER RECV1() // ( nSocket, @cRecv ) --> nLength (or SOCKET_ERROR)
{
BYTE buffer[ 4096 ];
WORD wLen;

// Is cRecv parameter a character passed by reference?
if (_parinfo(2) == 33)

// Receive data from socket
wLen = _recv( _parni( 1 ), buffer, 4096, 0 );

else

// Can't store in parameter that is not by reference
wLen = (WORD)SOCKET_ERROR;

// Is there a socket error?
if (wLen == (WORD)SOCKET_ERROR)

_storc( "", 2 );

else

if (_storclen( buffer, wLen, 2 ) == 0)

// Failed to store parameter
wLen = (WORD)SOCKET_ERROR;

_retni( wLen );

}
xhbcoder
 
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Postby Antonio Linares » Sat May 10, 2008 9:39 am

Jose,

The C compiler is clearly telling you what lines to fix.

If you are interested in using WM_COPYDATA please review samples\copydata_16_32\fwcopy16.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xhbcoder » Sat May 10, 2008 8:10 pm

Antonio,

C is not my language. I can't figure out how to port the C code.

Regards,

Jose
xhbcoder
 
Posts: 100
Joined: Wed Oct 04, 2006 4:50 pm
Location: USA

Postby Antonio Linares » Sat May 10, 2008 8:17 pm

Jose,

An error like this one:
Type mismatch in parameter 'hWndParent'(Wanted 'HWND_*,'got 'int') in function CREATEWINE

means that the C function was expecting a HWND and got an int. In those cases you need to do a C "types casting":

you have to place a ( HWND ) _parnl( ... ) so you tell the C compiler to use that type as a HWND.

I suggest you to review FiveWin provided C source code and also to review a simple C language tutorial
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for CA-Clipper

Who is online

Users browsing this forum: No registered users and 13 guests