Ambiguous reference: 'OWND'

Ambiguous reference: 'OWND'

Postby anserkk » Fri Aug 29, 2008 9: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


Code: Select all  Expand view  RUN
---------- 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

Code: Select all  Expand view  RUN
#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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby anserkk » Fri Aug 29, 2008 9:39 am

The problem got solved when I declared oWnd as Static before the function Main()


Code: Select all  Expand view  RUN
#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()

Code: Select all  Expand view  RUN
*-----------------------------------------------------------------*
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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby JC » Fri Aug 29, 2008 11:59 am

oWnd needs to be a STATIC variable!

Code: Select all  Expand view  RUN
#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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: Ambiguous reference: 'OWND'

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » 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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby JC » 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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Enrico Maria Giordano » Fri Aug 29, 2008 2: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
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby JC » Fri Aug 29, 2008 3: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby James Bott » Fri Aug 29, 2008 3: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby anserkk » Fri Aug 29, 2008 4: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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby James Bott » Fri Aug 29, 2008 4: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby anserkk » Fri Aug 29, 2008 4: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
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 75 guests