FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Ambiguous reference: 'OWND'
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 09:14 AM
Dear Friends,

I have just started my 1st project using FWH. Request all of u to forgive my ignorance. Right now I am having only 2 functions Main and BuildMenu. When I compile my project I am getting warning. Exe is working fine

Warning : Ambiguous reference: 'OWND'


oWnd is the object name of the Window

I just want to know where I am wrong.

Regards

Anser


---------- Capture Output ----------
> "Compile.Bat" 

D:\WinAcs>if not exist obj md obj 

D:\WinAcs>c:\Borland\bcc55\bin\make -fWinAcs.rmk 
MAKE Version 5.2  Copyright (c) 1987, 2000 Borland
	c:\xHarbour\bin\harbour .\WinAcs.PRG /L /N /W /Oobj\ /Ic:\fwh\include;c:\xHarbour\include
xHarbour Compiler build 1.1.0 (SimpLex) (Rev. 6195)
Copyright 1999-2008, http://www.xharbour.org http://www.harbour-project.org/
Compiling '.\WinAcs.PRG'...

.\WinAcs.PRG(14) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(16) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(16) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(18) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(35) Warning W0001  Ambiguous reference: 'OWND'
.\WinAcs.PRG(43) Warning W0001  Ambiguous reference: 'OWND'

Lines 66, Functions/Procedures 2
Generating C source output to 'obj\WinAcs.c'...
Done.
	c:\Borland\bcc55\bin\bcc32 -c -tWM -Ic:\xHarbour\include -oobj\WinAcs obj\WinAcs.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
obj\winacs.c:
	c:\Borland\bcc55\bin\brc32.exe -r WinAcs.rc
Borland Resource Compiler  Version 5.40
Copyright (c) 1990, 1999 Inprise Corporation.  All rights reserved.
	echo off
	echo c:\Borland\bcc55\lib\c0w32.obj + > b32.bc
	echo obj\WinAcs.obj obj\One.obj obj\two.obj obj\Masters.obj, + >> b32.bc
	echo WinAcs.exe, + >> b32.bc
	echo WinAcs.map, + >> b32.bc
	echo c:\fwh\lib\FiveHx.lib c:\fwh\lib\FiveHC.lib + >> b32.bc
	echo c:\xHarbour\lib\rtl.lib + >> b32.bc
	echo c:\xHarbour\lib\vm.lib + >> b32.bc
	echo c:\xHarbour\lib\gtgui.lib + >> b32.bc
	echo c:\xHarbour\lib\lang.lib + >> b32.bc
	echo c:\xHarbour\lib\macro.lib + >> b32.bc
	echo c:\xHarbour\lib\rdd.lib + >> b32.bc
	echo c:\xHarbour\lib\dbfntx.lib + >> b32.bc
	echo c:\xHarbour\lib\dbfcdx.lib + >> b32.bc
	echo c:\xHarbour\lib\dbffpt.lib + >> b32.bc
	echo c:\xHarbour\lib\hbsix.lib + >> b32.bc
	echo c:\xHarbour\lib\debug.lib + >> b32.bc
	echo c:\xHarbour\lib\common.lib + >> b32.bc
	echo c:\xHarbour\lib\pp.lib + >> b32.bc
	echo c:\xHarbour\lib\pcrepos.lib + >> b32.bc
	rem Uncomment these two lines to use Advantage RDD
	rem echo c:\xHarbour\lib\rddads.lib + >> b32.bc
	rem echo c:\xHarbour\lib\Ace32.lib + >> b32.bc
	echo c:\Borland\bcc55\lib\cw32.lib + >> b32.bc
	echo c:\Borland\bcc55\lib\import32.lib + >> b32.bc
	echo c:\Borland\bcc55\lib\psdk\odbc32.lib + >> b32.bc
	echo c:\Borland\bcc55\lib\psdk\nddeapi.lib + >> b32.bc
	echo c:\Borland\bcc55\lib\psdk\iphlpapi.lib + >> b32.bc
	echo c:\Borland\bcc55\lib\psdk\msimg32.lib + >> b32.bc
	echo c:\Borland\bcc55\lib\psdk\rasapi32.lib, >> b32.bc
	IF EXIST WinAcs.res echo WinAcs.res >> b32.bc
	c:\Borland\bcc55\bin\ilink32 -Gn -aa -Tpe -s @b32.bc
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
	del b32.bc

D:\WinAcs>


This is the code

#include "FiveWin.ch"
*-----------------------------------------------------------------*
Function Main()
*-----------------------------------------------------------------*
Local nScrHeight,nScrWidth

Private oWnd

nScrHeight:=GetSysMetrics(1)  // Screen Height
nScrWidth :=GetSysMetrics(0)  // Screen Width
DEFINE WINDOW oWnd FROM 1, 1 TO nScrHeight, nScrWidth MDI ;
      TITLE "Accounting Software" ;
      MENU  BuildMenu() ;
      COLOR "B/W" 
      
SET MESSAGE OF oWnd TO "My Company name" NOINSET CLOCK CENTERED
ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID MsgYesNo( "Do you want to quit ?" )       
Return nil

*-----------------------------------------------------------------*
Function BuildMenu()
*-----------------------------------------------------------------*
Local oMenu

MENU oMenu
  MENUITEM "Masters"
  MENU
     MENUITEM "&Account Groups" ;
        ACTION Another() 
     MENUITEM "&Account Heads" ;
        ACTION Another() 
     SEPARATOR
     MENUITEM "&Exit"  ;
        ACTION oWnd:End() 

  ENDMENU

  MENUITEM "&Transactions"
  MENU
     MENUITEM "&Voucher Entry" ;
        ACTION ( MsgStop( "New Clients" ),;
                 oWnd:Say( 5, 5, "New Clients...", "GR+/G" ) ) 

     MENUITEM "&Sales Posting"  ACTION MsgInfo( "Modif. Clients" ) 

     MENUITEM "&Delete..."  ACTION MsgAlert( "Del Clients" ) 

     SEPARATOR

     MENUITEM "&Browse..."  ACTION MsgInfo( "Browse Clients" ) 

  ENDMENU

  MENUITEM "&Utilities"
  MENU
     MENUITEM "&Calculator..." ACTION WinExec( "Calc" ) 

     MENUITEM "&Internet..." ;
        ACTION WinExec( "start iexplore www.fivetech.com", 0 ) 
  ENDMENU
ENDMENU

Return oMenu
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 09:39 AM
The problem got solved when I declared oWnd as Static before the function Main()


#include "FiveWin.ch"
Static oWnd
*-----------------------------------------------------------------*
Function Main()
*-----------------------------------------------------------------*
Local nScrHeight,nScrWidth

nScrHeight:=GetSysMetrics(1)  // Screen Height
nScrWidth :=GetSysMetrics(0)  // Screen Width
DEFINE WINDOW oWnd FROM 1, 1 TO nScrHeight, nScrWidth MDI ;
      TITLE "Accounting Software" ;
      MENU  BuildMenu() ;
      COLOR "B/W" 
      
SET MESSAGE OF oWnd TO "My Company name" NOINSET CLOCK CENTERED
ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID MsgYesNo( "Do you want to quit ?" )       
Return nil


When I move the static declaration to Main() then I am getting only 1 warning at Line no 42 inside the BuilMenu()

*-----------------------------------------------------------------*
Function BuildMenu()
*-----------------------------------------------------------------*
Local oMenu

MENU oMenu
  MENUITEM "Masters"
  MENU
     MENUITEM "&Account Groups" ;
        ACTION Another() 
     MENUITEM "&Account Heads" ;
        ACTION Another() 
     SEPARATOR
     MENUITEM "&Exit"  ;
        ACTION oWnd:End() 

  ENDMENU

  MENUITEM "&Transactions"
  MENU
     [b]MENUITEM "&Voucher Entry" ;
        ACTION ( MsgStop( "New Clients" ),;
                 oWnd:Say( 5, 5, "New Clients...", "GR+/G" ) ) [/b]

     MENUITEM "&Sales Posting"  ACTION MsgInfo( "Modif. Clients" ) 

     MENUITEM "&Delete..."  ACTION MsgAlert( "Del Clients" ) 

     SEPARATOR

     MENUITEM "&Browse..."  ACTION MsgInfo( "Browse Clients" ) 

  ENDMENU

  MENUITEM "&Utilities"
  MENU
     MENUITEM "&Calculator..." ACTION WinExec( "Calc" ) 

     MENUITEM "&Internet..." ;
        ACTION WinExec( "start iexplore www.fivetech.com", 0 ) 
  ENDMENU
ENDMENU

Return oMenu


I just want to know which is the reght way. My app is going to use around 25 dbf files and around 100 ntx files.

Regards

Anser
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 11:59 AM
oWnd needs to be a STATIC variable!

#include "FiveWin.ch"
*-----------------------------------------------------------------*
Function Main()
*-----------------------------------------------------------------*
Local nScrHeight,nScrWidth

Static oWnd

nScrHeight:=GetSysMetrics(1)  // Screen Height
nScrWidth :=GetSysMetrics(0)  // Screen Width
DEFINE WINDOW oWnd FROM 1, 1 TO nScrHeight, nScrWidth MDI ;
      TITLE "Accounting Software" ;
      MENU  BuildMenu() ;
      COLOR "B/W"
     
SET MESSAGE OF oWnd TO "My Company name" NOINSET CLOCK CENTERED
ACTIVATE WINDOW oWnd MAXIMIZED ;
      VALID MsgYesNo( "Do you want to quit ?" )       
Return nil
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 12:21 PM
anserkk wrote:Dear Friends,

I have just started my 1st project using FWH. Request all of u to forgive my ignorance. Right now I am having only 2 functions Main and BuildMenu. When I compile my project I am getting warning. Exe is working fine

Warning : Ambiguous reference: 'OWND'


oWnd is the object name of the Window

I just want to know where I am wrong.


The best option is to declare oWnd LOCAL and pass it as parameter to the functions that want to use it. Otherwise you have to declare oWnd as MEMVAR ore use M -> oWnd.

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 12:22 PM
JC wrote:oWnd needs to be a STATIC variable!


No, it can be of any type but LOCAL is the preferred one.

EMG
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 12:37 PM
Enrico Maria Giordano wrote:
JC wrote:oWnd needs to be a STATIC variable!


No, it can be of any type but LOCAL is the preferred one.

EMG


Enrico, in this case if the variable is the type "private", then cause the "Ambiguous reference"... I think the variable needs be STATIC and LOCAL works too.
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 02:47 PM
JC wrote:Enrico, in this case if the variable is the type "private", then cause the "Ambiguous reference"... I think the variable needs be STATIC and LOCAL works too.


No, you simply need to declare it as MEMVAR or use the M -> prefix.

EMG
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 03:05 PM
Enrico Maria Giordano wrote:
JC wrote:Enrico, in this case if the variable is the type "private", then cause the "Ambiguous reference"... I think the variable needs be STATIC and LOCAL works too.


No, you simply need to declare it as MEMVAR or use the M -> prefix.

EMG


Ok Enrico... thanks for you answer!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 03:09 PM
My advice is to NEVER use privates--they will give you all kinds of hard to find errors.

The main window object is stored in the function wndMain() so you can always access it from anywhere. So there is no need to make it a static either.

As, Enrico said, it is best to make it a local.

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 04:05 PM

Friends,

Thanks for the replies. As adviced by you people, I shall declare it as a local and pass it as a parameter to the required functions.

Anser

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 04:11 PM

Anser,

You don't have to pass it as a parameter. You can access it using wndMain(). You can do:

local oWnd:= wndMain()

In any function. But you can also do this:

wndMain():refresh()

Which is the same as:

local oWnd:= wndMain()
oWnd:refresh()

Understood?

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Ambiguous reference: 'OWND'
Posted: Fri Aug 29, 2008 04:17 PM
Thank you James,

Now things are getting more clear. I understood what you said.

Regards

Anser

James Bott wrote:Anser,

You don't have to pass it as a parameter. You can access it using wndMain(). You can do:

local oWnd:= wndMain()

In any function. But you can also do this:

wndMain():refresh()

Which is the same as:

local oWnd:= wndMain()
oWnd:refresh()

Understood?

Regards,
James

Continue the discussion