Undeclared Variables in a .PRG

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Undeclared Variables in a .PRG

Post by Claudio Ricardo »

Hi, in the Main.prg, You can try:

#pragma -w3
#pragma -es2
#include <hmg.ch>

Function Main
----> and all folow :)
Last edited by Claudio Ricardo on Wed Mar 30, 2022 4:56 pm, edited 1 time in total.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
apais
Posts: 441
Joined: Fri Aug 01, 2008 6:03 pm
DBs Used: DBF, Leto, MariaDB, SQLite
Location: uruguay
Contact:

Re: Undeclared Variables in a .PRG

Post by apais »

there's so many ways to skin a cat!
Angel Pais
Web Apps consultant/architect/developer.
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: Undeclared Variables in a .PRG

Post by Red2 »

Hi Claudio,

I am still having no luck. I added your 2 suggested lines:
#pragma -w2
#pragma -es2

to the Project's Main.PRG.

The #include <hmg.ch> and all other necessary #includes were already there.
(Note: The IDE, previously, built this project perfectly and did so for months before.)

Unfortunately after adding these 2 lines the IDE now generats over 4900 lines of
(mostly) "Warning W0002" and the build now fails.

I simply want to find:
Variables declared but not used and Variables declared but not used.
===========================
Google Spanish:
Simplemente quiero encontrar:
Variables declaradas pero no utilizadas y Variables declaradas pero no utilizadas.
===========================

Any suggestions? Thank you all for all of your generous guidance.
Red2
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Undeclared Variables in a .PRG

Post by Claudio Ricardo »

I made a mistake but edited it later when I noticed it... it's -w3 and not -w2
With just that line at the beginning it should warn you of errors
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: Undeclared Variables in a .PRG

Post by Red2 »

Hi Ricardo,

Google Spanish:
¡Muchas gracias! Tu última publicación parece dar una solución.

Si solo incluyo #pragma -w3 al comienzo de un .PRG, entonces
la parte inferior del archivo build.log ahora contiene líneas descriptivas como:

Variable 'PNNBROWS' declarada pero no utilizada en la función...
La variable 'LLSTOP' está asignada pero no utilizada en la función...


Gracias a su amable y generosa orientación, parece que
ahora hay una solución que puedo poner en uso.

¡¡¡Una vez más, gracias!!! ¡Por favor acepte mi aprecio!
===================================================

Thank you so much! Your last post seems to give a solution.

If I only include #pragma -w3 at the beginning of a .PRG then
the bottom of file build.log now contains descriptive lines such as:

Variable 'PNNBRROWS' declared but not used in function ...
Variable 'LLSTOP' is assigned but not used in function ...


Thanks to your kind and most generous guidance it looks like
there is now a solution that I can put to use.

Again thank you!!! Please accept my appreciation!

Red2
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Undeclared Variables in a .PRG

Post by Claudio Ricardo »

Hi, The credit goes to Mr. Roberto Lopez I took it out of his code, and there is much more to learn from him...
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Undeclared Variables in a .PRG

Post by AUGE_OHR »

hi Red,

you can -w1, -w2 or -w3 which will give you "all" Error

i use -w3 only when release to Customer while normal just -w1 to identify "not declare" -> Crash
-w3 also include "UNUSD" Variable. i ofter Declare Variable which i want to use "later"

---

when work with IDE you know *.HBP.
when write into "Configuration" Tab you will find a *.HBC when close IDE

last there is hbmk.HBM which can be found in every \HARBOUR\CONTRIB\*.* Folder
it include above *.HBC and Parameter with Compiler Option

i recommend to use Structure like those in \HARBOUR\CONTRIB\*.* Folder
special when use Source Code together with other Compiler like Xbase++
have fun
Jimmy
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Undeclared Variables in a .PRG

Post by Claudio Ricardo »

Hi, I take advantage of the fact that the subject is being discussed to ask about these errors that appear
in three different programs but with the same lines:

C:\Programacion\Programas_Mios_Fuentes\FarmaCard_2\Main.Prg(149) Warning W0001 Ambiguous reference '_HMG_DEFAULTICONNAME'
This line have: SET Default Icon To "AaaaCard" This icon (.png) is in the .rc file and it shows up in all windows perfectly.

C:\Programacion\Programas_Mios_Fuentes\FarmaCard_2\Main.Prg(224) Warning W0001 Ambiguous reference '_HMG_MAINWINDOWFIRST'
C:\Programacion\Programas_Mios_Fuentes\FarmaCard_2\Main.Prg(242) Warning W0001 Ambiguous reference '_HMG_MAINWINDOWFIRST'

Code: Select all

	SET WINDOW MAIN Off       // <-- Line 224
   
		Modulo_Coneccion_Al_Hosting ()					// Funcion de coneccion al hosting y DB's
														// muestra una splash window

		If ! Empty ( pcAdminPass )						// Si hay pass de administrador

			Main_Usuarios ()							// Funcion de Login, show login window
		
		Else											// Si no hay pass de administrador entra directo
														// es para la primera vez que se usa el programa
														// y poder setear el pass de administrador y de usuarios
			plAdminAccess := .T.
			pcUsuario := "Administrador general"
			
			MsgInfo ("Está iniciando sesión como Administrador general !" , "Permisos")
			
		EndIf
	  
	SET WINDOW MAIN On       // <-- Line 242

DEFINE WINDOW Main AT pnRowIniMain , pnColIniMain WIDTH nMinWidth HEIGHT nMinHeight VIRTUAL WIDTH Nil ;
	VIRTUAL HEIGHT Nil TITLE pcSoftName + " - " + pcVersionIdLong ICON "AaaaCard" MAIN CURSOR NIL ;   // and continue the code...
Since everything works fine, I didn't pay attention to it...
If anyone knows what is wrong I thank you in advance !
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
User avatar
serge_girard
Posts: 3420
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Undeclared Variables in a .PRG

Post by serge_girard »

Hi Claudio,

I have VERY MUCH similar "Warning W0001 Ambiguous reference"...!

Serge
There's nothing you can do that can't be done...
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Undeclared Variables in a .PRG

Post by Claudio Ricardo »

Hi Serge
They are the only ones I always receive, but since they are "internal" variables, I am worried that I am doing something wrong,
although the program works without problems.
Knowing that it is something "normal" I will stop paying attention to it.
Very grateful for your reply !
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
Post Reply