#comand/#translate usage

217 views
Skip to first unread message

Mel Smith

unread,
Jul 9, 2021, 11:47:07 PM7/9/21
to Harbour Users
HI All:
   I have  a client who uses the old-fashioned command construction "Do SomuProggy"  in many programs and many times in all of the program system.

   I would like to add an include  command translation DO2Func.CH at the top of each of his set of 80 or so programs.

   This translation should convert DO SomeProggy => SomeProggy()  where there may be 40 or 50 different proggies.

   Can someone here show the #command translation line using a list marker please ?

   Something like: #command DO <prog, AB,BC,myPROG,> =>  ??????

Thanks.
-Mel

Pete

unread,
Jul 10, 2021, 1:42:57 AM7/10/21
to Harbour Users
Hi Mel
I'm not sure I understood what you mean by  "using a list marker please",
but If my guess is correct the below "command/translation" directives
should be enough for the occasion: 

//--------------------------------------------------------
#xcommand do <proc> [with <var>] => <proc>[(<var>)]
#xcommand do <proc> => <proc>()
//--------------------------------------------------------

Then the rhetoric (yet plausible)  question is : why someone might want to do this?
( seems like trying to teach the compiler a language which the compiler already knows better. <g> )

regards,
Pete

frank van nuffel

unread,
Jul 10, 2021, 5:52:11 AM7/10/21
to Harbour Users
Hi Mel,

That's a real problem!

From the NG

     The DO statement calls a procedure or user-defined function, optionally
     passing arguments to the called routine.  It performs the same action as
     a user-defined function or procedure specified on a line by itself with
     the exception that variables other than field variables are passed by
     reference as the default
.  In order to pass a field variable as an

If you do (as Pete suggests)

#xcommand do <proc> [with <var> [, <var2> ]] => <proc>(<var>[,<var2>])

then this would HAVE TO BE

#xcommand do <proc> [with <var> [, <var2> ]] => <proc>([@<var>][,@<var2>])

BUT then you'll end up with @ being inserted before literals also (terminating compilation)

IOW, letting the compiler translate the DO ... syntax directly (as Pete also suggests) is the only safe manner to proceed, afaik

HTH,

frank
Op zaterdag 10 juli 2021 om 07:42:57 UTC+2 schreef Pete:

Mel Smith

unread,
Jul 10, 2021, 10:39:35 AM7/10/21
to Harbour Users
Hi Frank and Pete:
   Thank you for the solutions !
   My user/client wants to convert  a *large* budget system (approx 85 source files with no comments) from Clipper to Harbour.  I have already converted a very small app for him successfully.
   After I do the basic conversion (i.e., getting it compiled/linked without errors), then I have to resolve mouse/screen problems.  Rather than try to change his 'style', I would rather just accommodate how he programs

   btw,  He *never* uses the DO Command with parameters just the construct 'DO Proggy'.

   I'm of course using Harbour 3.2 under MInGW 11.1 and use hbmk2.exe in a batch file to create .c and .o files  Of course, hbmk2 creates functions for each of the Do proggies, which is good.

Here is an example of the typical use of his DO PROGGY style:

DO CASE
   CASE XL = "A"
   DO A
   CASE XL = "B"
   DO B
   CASE XL = "C"
   DO C
   CASE XL = "D"
   DO D
   CASE XL = "E"
   DO E
   CASE XL = "F"
   DO F
   CASE XL = "G"
   DO G
   CASE XL = "H"
   DO H
   CASE XL = "I"
   DO I
   CASE XL = "J"
   DO J
   CASE XL = "K"
   DO K
   CASE XL = "L"
   DO L
   CASE XL = "M"
   DO M
   CASE XL = "N"
   DO N
   CASE XL = "O"
   DO O
   CASE XL = "P"
   DO P
   CASE XL = "Q"
   DO Q
   CASE XL = "R"
   DO R
   CASE XL = "S"
   DO S
   CASE XL = "T"
   DO T
   CASE XL = "U"
   DO U
   CASE XL = "V"
   DO V
   CASE XL = "W"
   DO W
   CASE XL = "X"
   DO X
   CASE XL = "Y"
   DO Y
   CASE XL = "Z"
   DO Z
   CASE XL = "'"
   DO AP
   CASE XL = "."
   DO FSTOP
ENDCASE
IF XL = SPACE(1)
XCOL = XCOL + 2
ELSE
XCOL = XCOL + 8
ENDIF
XPOS = XPOS + 1
ENDDO

Thank you both for your guidance and solutions.  btw, my services are free. I just want more people to start using Harbour.

-Mel

Francesco Perillo

unread,
Jul 10, 2021, 10:47:11 AM7/10/21
to harbou...@googlegroups.com
since you are doing it probono, ask him if you can document the process like I did in the past whrn convertin a clipper 87 application to harbour.

for your specific question, sincerely I don't understand why you want to translate... 
personally, if I didn't like the DO xxx coding style, I'd run a search & replace magic...

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/6189664e-145d-4e28-bb51-ae27d2580b73n%40googlegroups.com.

Mel Smith

unread,
Jul 10, 2021, 11:09:48 AM7/10/21
to Harbour Users
Hi fperillo:
   The substitution didn't work anyway:   The DO CASE was converted also and caused
 the DO CASE to fail.

   In compiling the specific module with all the DO proggies, I get the following errors *even though* I have already compiled each of these into proggy.c and proggy.o earlier in the .rsp file.

   So, it means to me that the source code cannot be found.
   This means (to me) that hbmk2.exe cannot find the program code when using "DO PROGGY"  
   I don't wish to change these to "DO c:\somedir\src\Proggy"  because it will not match what my client's set up is.
-Mel

// compiling a big module with DO Proggy
100

200
Cannot open A.prg, assumed external
Cannot open B.prg, assumed external
Cannot open C.prg, assumed external
Cannot open D.prg, assumed external
Cannot open E.prg, assumed external
Cannot open F.prg, assumed external
Cannot open G.prg, assumed external
Cannot open H.prg, assumed external
Cannot open I.prg, assumed external
Cannot open J.prg, assumed external
Cannot open K.prg, assumed external
Cannot open L.prg, assumed external
Cannot open M.prg, assumed external
Cannot open N.prg, assumed external
Cannot open O.prg, assumed external
Cannot open P.prg, assumed external
Cannot open Q.prg, assumed external
Cannot open R.prg, assumed external
Cannot open S.prg, assumed external
Cannot open T.prg, assumed external
Cannot open U.prg, assumed external
Cannot open V.prg, assumed external
Cannot open W.prg, assumed external
Cannot open X.prg, assumed external
Cannot open Y.prg, assumed external
Cannot open Z.prg, assumed external
Cannot open AP.prg, assumed external
Cannot open FSTOP.prg, assumed external

Francesco Perillo

unread,
Jul 10, 2021, 11:11:36 AM7/10/21
to harbou...@googlegroups.com
a part that you can ignore the warjing, you should use the -m flag and list all your sources in the hbk file...

José M. C. Quintas

unread,
Jul 10, 2021, 11:22:05 AM7/10/21
to harbou...@googlegroups.com
FOR EACH cProg INI { "aprog", "bprog", "cprog" }

   do( cProg )

NEXT

José M. C. Quintas
> --

Mel Smith

unread,
Jul 10, 2021, 11:37:58 AM7/10/21
to Harbour Users
HI All (again):
   With the following manual change, the problem goes away for this DO Proggy-  and I'd like to do it automatically and invisibly for all needed proggies.
   My own 'style' is to to use a build batch file with an associated .hbp file, and also a .rsp file. This has worked admirably so far -- until the "Do Proggy' problem
   I *could* change all the DO Proggies manually to function calls but I would rather leave this style alone and accommodate it by using an include.ch file. But the simple replacement doesn't work, so maybe the list marker #command  is the better way (but I don't know how to implement it. 

   // DO A
   A()

   I'm tired !
Thanks to y'all
-Mel

Francesco Perillo

unread,
Jul 10, 2021, 11:43:44 AM7/10/21
to harbou...@googlegroups.com
add the -m in the .hbp file and list all the .prg files in it.
this is the way to go. 

otherwise try something like:
#traslate DO A => A()
#tranlate DO B => B()



--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Mel Smith

unread,
Jul 10, 2021, 11:44:07 AM7/10/21
to Harbour Users
Hi Again:
   Below is the budget.rsp file -- which is input to hbmk2 in my build batch file

***** contents of budget.rsp *****
c:\xxxxx\source\A.PRG
c:\xxxxx\source\AP.PRG
c:\xxxxx\source\B.PRG
c:\xxxxx\source\BB.PRG
c:\xxxxx\source\BK.PRG
c:\xxxxx\source\BMAINSCR.PRG
c:\xxxxx\source\C.PRG
c:\xxxxx\source\CONSGL.PRG
c:\xxxxx\source\D.PRG
c:\xxxxx\source\E.PRG
c:\xxxxx\source\F.PRG
c:\xxxxx\source\FS.PRG
c:\xxxxx\source\FSTOP.PRG
c:\xxxxx\source\G.PRG
c:\xxxxx\source\GLHEAD.PRG
c:\xxxxx\source\H.PRG
c:\xxxxx\source\I.PRG
c:\xxxxx\source\J.PRG
c:\xxxxx\source\K.PRG
c:\xxxxx\source\L.PRG
c:\xxxxx\source\M.PRG
c:\xxxxx\source\MAINSCR2.PRG
c:\xxxxx\source\N.PRG
c:\xxxxx\source\O.PRG
c:\xxxxx\source\P.PRG
c:\xxxxx\source\Q.PRG
c:\xxxxx\source\R.PRG
c:\xxxxx\source\S.PRG
c:\xxxxx\source\STDALL.PRG
c:\xxxxx\source\STDCAPE.PRG
c:\xxxxx\source\STDCAPR.PRG
c:\xxxxx\source\STDCONS.PRG
c:\xxxxx\source\STDGL.PRG
c:\xxxxx\source\STDMINS.PRG
c:\xxxxx\source\STDOVER.PRG
c:\xxxxx\source\STDPARA.PRG
c:\xxxxx\source\STDPOST.PRG
c:\xxxxx\source\STDREVN.PRG
c:\xxxxx\source\STDSCR.PRG
c:\xxxxx\source\al.prg
c:\xxxxx\source\T.PRG
c:\xxxxx\source\U.PRG
c:\xxxxx\source\V.PRG
c:\xxxxx\source\W.PRG
c:\xxxxx\source\X.PRG
c:\xxxxx\source\Y.PRG
c:\xxxxx\source\Z.PRG
c:\xxxxx\source\ALLFUNC.PRG
c:\xxxxx\source\APL.PRG
c:\xxxxx\source\BL.PRG
c:\xxxxx\source\CL.PRG
c:\xxxxx\source\DBSFUNC1.PRG
c:\xxxxx\source\DBSFUNC2.PRG
c:\xxxxx\source\DBSFUNC3.PRG
c:\xxxxx\source\DBSFUNC4.PRG
c:\xxxxx\source\DBSFUNC5.PRG
c:\xxxxx\source\DBSFUNC6.PRG
c:\xxxxx\source\DL.PRG
c:\xxxxx\source\EL.PRG
c:\xxxxx\source\FL.PRG
c:\xxxxx\source\FSL.PRG
c:\xxxxx\source\GL.PRG
c:\xxxxx\source\HL.PRG
c:\xxxxx\source\IL.PRG
c:\xxxxx\source\JL.PRG
c:\xxxxx\source\KL.PRG
c:\xxxxx\source\LL.PRG
c:\xxxxx\source\ML.PRG
c:\xxxxx\source\NL.PRG
c:\xxxxx\source\OL.PRG
c:\xxxxx\source\PL.PRG
c:\xxxxx\source\QL.PRG
c:\xxxxx\source\RL.PRG
c:\xxxxx\source\SL.PRG
c:\xxxxx\source\SLL.PRG
c:\xxxxx\source\TL.PRG
c:\xxxxx\source\UL.PRG
c:\xxxxx\source\VL.PRG
c:\xxxxx\source\WL.PRG
c:\xxxxx\source\XL.PRG
c:\xxxxx\source\YL.PRG
c:\xxxxx\source\ZL.PRG
c:\xxxxx\source\BUDGET.prg

***** end of budget.rsp *****

Francesco Perillo

unread,
Jul 10, 2021, 11:44:31 AM7/10/21
to harbou...@googlegroups.com
or #command
i don't know the differences

Francesco Perillo

unread,
Jul 10, 2021, 11:46:30 AM7/10/21
to harbou...@googlegroups.com
good.
try to add -m to the .hbp file

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Francesco Perillo

unread,
Jul 10, 2021, 11:50:07 AM7/10/21
to harbou...@googlegroups.com

-m tells the compiler to not add the files used in the DO command to the compile list.

m for module. 

so each source file is compiled separately and the linker joins them.

if the linker misses some files, add to the .rsp file.

I'd copy the rsp file inside the hbp file, unless you need it for another rrason...

Mel Smith

unread,
Jul 10, 2021, 11:50:48 AM7/10/21
to Harbour Users
Hi All:

   FWIW, Here below is my build batch file.

   ***** BLDBDG.BAT *****
@ECHO OFF
CLS

SET SAVPATH=%PATH%

IF ~%1==~ GOTO NOAPP
IF EXIST %1.hbp GOTO GOTHBP
GOTO NOHBP
:GOTHBP
REM Have to Ensure that MinGW Compiler is on path
SET PATH=C:\MINGW111\MINGW32\BIN;C:\harbour\BIN;C:\harbour\LIB;C:\xxxxx\SOURCE;c:\CURL\LIB;

DEL %1.LOG
DEL %1.EXE
IF EXIST %1.EXE GOTO BADDEL

echo .
echo . Compiling / linking %1.prg
echo .
\harbour\BIN\HBMK2 @%1.hbp XHB.HBC @%1.RSP -plat=win -comp=mingw -workdir=\xxxxx\temp -rebuildall > %1.LOG 2>&1


IF EXIST %1.EXE GOTO GOODBLD
IF EXIST %1init.EXE GOTO GOODBLD
ECHO .
ECHO .
ECHO .  Failed to create executable.
ECHO .
ECHO . View %1.LOG to see what happened.
ECHO .
PAUSE
ECHO .
GOTO ENDJOB

:GOODBLD
ECHO .
ECHO . Build Was Successful. %1.exe was created
ECHO . View %1.LOG for info on Build
ECHO .
GOTO FINISH


:BADDEL
ECHO .
ECHO . Build Failed. Failed to delete old executable: %1.exe
ECHO . View %1.LOG for info on Build
ECHO .
GOTO FINISH

:NOAPP
ECHO .
ECHO . Argument 1 must be the root name of the 'App' to be built
ECHO .
PAUSE
GOTO FINISH

:NOHBP
ECHO .
ECHO . There is NO Harbour .HBP File to get options from
ECHO .
PAUSE
GOTO FINISH

:FINISH

:ENDJOB
SET PATH=%SAVPATH%
ECHO . Deleting the .map, .tds files ...
ECHO .
DEL *.MAP
DEL *.TDS

   ***** end of BLDBDG.BAT *****

José M. C. Quintas

unread,
Jul 10, 2021, 11:53:15 AM7/10/21
to harbou...@googlegroups.com

Without -m, compiler try to found modules indicateds by DO module, as PRG files.

Compile using -m, and the prg list.

In this way, objects will be required on link, not on compile.


José M. C. Quintas

Mel Smith

unread,
Jul 10, 2021, 11:58:18 AM7/10/21
to Harbour Users
Hi fperillo:

   PERFECT !!!
   That fixed the "Do Proggy" problem immediately, and I'm refreshed and on to later crashes :))

Thanks again !

-Mel

Francesco Perillo

unread,
Jul 10, 2021, 12:11:07 PM7/10/21
to harbou...@googlegroups.com
if you want I may also suggest some changes in your bat files :-)

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.

Mel Smith

unread,
Jul 10, 2021, 12:21:45 PM7/10/21
to Harbour Users
Hi fperillo:
   Sure, I always listen to experts and consider their suggestions :)
 -Mel

Mel Smith

unread,
Jul 10, 2021, 12:26:30 PM7/10/21
to Harbour Users
Also, I couldn't find the description you noted regarding the -m option. Where is this described please ??   (I only noted that harbour said "Compile Module Only|

Thanks,
-Mel

Francesco Perillo

unread,
Jul 10, 2021, 12:28:05 PM7/10/21
to harbou...@googlegroups.com
compile module only is the exact description, compiles one module only...

Mel Smith

unread,
Jul 10, 2021, 12:31:09 PM7/10/21
to Harbour Users
... and again where 'bdg' is an abbreviation for 'budget' :

   This batch file is to save re-typing many times per hour 
***** bdlbdg.bat contents *****  
@call bldapp budget
***** end of bldbdg.bat *****

-Mel

José M. C. Quintas

unread,
Jul 10, 2021, 12:54:14 PM7/10/21
to harbou...@googlegroups.com

-m is Clipper compatible.

A long time ago, default for Harbour was changed, but users required same default as Clipper.

-m -n -w3 are best options, but users required to be Clipper compatible.

Not only DO module, but same occurs if use SET PROCEDURE TO

Not sure if there exists a better description.

These parameters comes from Clipper days, they exists for more than 40 years, they are older than Harbour.


José M. C. Quintas

Mel Smith

unread,
Jul 11, 2021, 7:22:22 PM7/11/21
to Harbour Users
Hi All again:
   With all your help and guidance, I have now compiled and linked and ran this budget system for my user. It runs properly without major issues.
  .So, thank you.
   However I note that the following 'MENU TO XSELECT' command causes the screen data to skip up two lines -- losing the top border and a title line.

Here is a fragment of the code causing the problem, and my Alert() messages which bound the problem
**** code fragment *****
  // DESM is declared above as a 1-D array

 DESM [1] = "PLEASE ENTER PASSWORD TO GAIN ACCESS"
DESM [2] = "XXXXXX BUSINESS SYSTEMS INFORMATION."
DESM [3] = "EXIT FROM THIS XXXXXXX BUDGET SYSTEM."

SET WRAP ON
SET MESSAGE TO 23 CENTER

@XROW,XCOL PROMPT  "LOG IN YOUR PASSWORD"  MESSAGE DESM [1]
XROW = XROW + 1
@XROW,XCOL PROMPT  "INFORMATION DESK BBS"  MESSAGE DESM [2]
XROW = XROW + 1
@XROW,XCOL PROMPT  "EXIT                "                       MESSAGE DESM [3]
alert("1.0 In BMAINSCR O.K.")
MENU TO XSELECT     // the problem line causes screen jump up 2 lines
alert("1.5 In BMAINSCR Screen kicks up one line.  Why ?")
***** end of code fragment *****

So, in the above code, on the Alert(1.0), the screen is perfect and at the top of the Command Prompt boundary
After the Menu to XSELECT is activated, the data on the screen jump up two lines (i.e., the two top
lines of the display disappear upwards).

Why does 'MENU TO'  cause this to happen please ?

Francesco Perillo

unread,
Jul 11, 2021, 7:25:35 PM7/11/21
to harbou...@googlegroups.com
do you have a setmode() command anywhere?

how many rows is your command prompt windows?

Francesco Perillo

unread,
Jul 11, 2021, 7:27:14 PM7/11/21
to harbou...@googlegroups.com
if a setmode command is missing, add one in the main functiin, setmode(25,80)
or 80,25, can't remember

Mel Smith

unread,
Jul 12, 2021, 10:31:31 AM7/12/21
to Harbour Users
Hi fperillo:
   I'll look over the client's code for a setmode() command. and insert one in budget.prg if missing.
Thanks again for your help !
-Mel

Mel Smith

unread,
Jul 12, 2021, 10:42:03 AM7/12/21
to Harbour Users
Hi fperillo"

   WOW !!   You hit another *home run* !!!
   There is no more 'kick-up' of two lines !
   Can you briefly explain the action when the setmode(25,80) is used. And what is the 'mode' *before* this function is activated.

Again, Thank you for this perfect solution !
-Mel

Mel Smith

unread,
Jul 12, 2021, 1:16:46 PM7/12/21
to Harbour Users
Hi fperillo:
   I'm testing the mouse operation now.
  
 The statement:   MV = MSETCURSOR(.T.) returns False (.f.)
 What is the meaning of this please ?
Thanks,
-Mel

Mel Smith

unread,
Jul 14, 2021, 11:45:10 AM7/14/21
to Harbour Users
Hi All:
   Geoff Davies answered my query above thru an email.
Thanks Geoff !
-Mel

GeoffD

unread,
Jul 15, 2021, 2:40:33 AM7/15/21
to Harbour Users
Hi Mel 
Thanks for acknowledgement.

There are many functions that work like this so you don't have to worry about what the status was before setting a particular value.

Just store the previous value and restore on exit and "Bob's your uncle" English idiom 
Easy as
Take care Geoff
Reply all
Reply to author
Forward
0 new messages