Undeclared Variables in a .PRG

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Red2
Posts: 282
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Undeclared Variables in a .PRG

Post by Red2 »

Hello,

My Question:
Is there a utility, (either HMG Official or HMG Extended), that can examine a .PRG and identify either:
A variable used but not declared
OR
A variable declared but not used
============================
Google Spanish:
¿Hay alguna utilidad, (ya sea HMG oficial o HMG extendida), que pueda examinar un .PRG e identificar:
Una variable utilizada pero no declarada
O
Una variable declarada pero no utilizada

Thank you for your kind help,
Red2
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Undeclared Variables in a .PRG

Post by gfilatov »

Red2 wrote: Tue Mar 29, 2022 3:53 pm Hello,

My Question:
Is there a utility, (either HMG Official or HMG Extended), that can examine a .PRG and identify either:
A variable used but not declared
OR
A variable declared but not used
============================
Google Spanish:
¿Hay alguna utilidad, (ya sea HMG oficial o HMG extendida), que pueda examinar un .PRG e identificar:
Una variable utilizada pero no declarada
O
Una variable declarada pero no utilizada
Hello Red2,

It is possible with using Harbour switch -w3, i.e.
Harbour mysource.prg -n -w3
Please take a look for a full syntax below:
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/

Syntax: harbour.exe <file[ s ][ .prg ]|@file> [options]

Options: -a automatic memvar declaration
-b debug info
-build display detailed version info
-credits display credits
-d<id>[=<val>] #define <id>
-es[<level>] set exit severity
-fn[:[l|u]|-] set filename casing (l=lower u=upper)
-fd[:[l|u]|-] set directory casing (l=lower u=upper)
-fp[:<char>] set path separator
-fs[-] turn filename space trimming on or off (default)
-g<type> output type generated is <type> (see below)
-gc[<type>] output type: C source (.c) (default)
<type>: 0=compact (default) 1=normal 2=verbose
3=generate real C code
-gh output type: Harbour Portable Object (.hrb)
-gd[.<destext>] generate dependencies list into (.d) file
-ge[<mode>] error output <mode>: 0=Clipper (default)
1=IDE friendly
-i<path> #include file search path
-i[-|+] disable/enable support for INCLUDE envvar
-j[<file>] generate i18n gettext file (.pot)
-k compilation mode (type -k? for more data)
-l suppress line number information
-m compile module only
-n[<type>] no implicit starting procedure
<type>: 0=no implicit starting procedure
1=no starting procedure at all
2=add starting procedure if necessary
-o<path> object file drive and/or path
-p[<path>] generate pre-processed output (.ppo) file
-p+ generate pre-processor trace (.ppt) file
-q quiet
-q0 quiet and don't display program header
-q2 disable all output messages
-ql hide line counter gauge
-r:<max> set maximum number of preprocessor iterations
-s[m] syntax check only [minimal for dependencies list]
-u[<file>] use command def set in <file> (or none)
-u+<file> add command def set from <file>
-undef:<id> #undef <id>
-v variables are assumed M->
-w[<level>] set warning level number (0..3, default 1)
-z suppress shortcutting (.and. & .or.)
@<file> compile list of modules in <file>
Hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
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 Gregory,

Thank you for your prompt answer.
I certainly will investigate your kind suggestion.
Thank you so much!

So far I have only worked using the IDE.
(In VFP I had utilities to find undeclared and unused variables).

Red2
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,
Red2 wrote: Tue Mar 29, 2022 4:43 pm So far I have only worked using the IDE.
i use a *.HBM File to call Compiler Option

Code: Select all

your.hbc 
-w3 -es2
have fun
Jimmy
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 Jimmy,

Thank you for your kind suggestion.
I think I need a little more help.

Do I create a file named <MyProject>.HBM where I include the code you suggested?
Does this new file do into the <MyProject> directory?
Then in the HMG IDE do I "Reset Project Incremental Data" and then simply compile?

Thanks again!
Red2
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 All,

I downloaded Harbour via Gregory's link, https://harbour.github.io/
I then installed it into C:\HB32\. Harbour is now installed

I attempted to follow the "suggested" syntax (above) using:

Code: Select all

C:\HB32\Harbour DataBrowse_OnInit.PRG -n -w3
I keep getting Error F0029 Can't open #include file .....ch
So, I went into "Environment Variable" then "Edit environment variable" dialog and added to my Paths:
C:\HMG3.Include
AND
C:\MiniGUI\Include

Apparently these Path additions do not resolve these ....ch files errors.
Those of you with Harbour experience, could you kindly advise me here?
This is brand new territory to me.

Thank you,
Red2
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,

i use *.HBP which include all *.PRG of the Project
i use *.HBC which include all Libs=myLib
i use *.HBM which include Compiler Option like -w3
all are in Project Folder

dblclick on *.HBP will ask "how" to handle it so assign it to your IDE EXE (Unicode or ANSI)
later you "just" Dblclick on *.HBP to "load" Project into IDE
have fun
Jimmy
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 »

All this is also very new to me....
Learning each day!

Serge
There's nothing you can do that can't be done...
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Undeclared Variables in a .PRG

Post by mol »

If you're using IDE, you can add this line to Configuration tab:
prgflags=-w3

After compilation, you can look for build.log in your project folder to see all warnings
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 All,

Thank you, Gregory, Jimmy, and Mol, for your generous advice and suggestions.
I am building using the "Official" HMG IDE. So far I's getting back no warnings.

My Problems:
1) From the command prompt Harbour's (C:\HB32\bin\Harbour DataBrowse_OnInit.PRG -n -w3)
only generates a series of messages like: Error F0029 Can't open #include file 'hmg.ch'.
I have no idea what is occuring here.

2) I created a HBM file containing prgflags=-n -w3 in my Project directory.
Unfortunately the "build.log" contains no information on variables.

3) What would the "Configuration tab" be in the "Official" HMG IDE?

May I please request further guidance. Thanks again!
Red2
Post Reply