Is there any difference between how variables were defined in Clipper versus how they are defined in Harbour?

124 views
Skip to first unread message

Mario Emmanuel

unread,
Oct 4, 2023, 4:06:25 PM10/4/23
to Harbour Users
I am following an old example in a Clipper book from late 80s.

The example is as follows:

  1 PROCEDURE main
  2
  3         LOCAL i
  4        
  5         * HORIZONTAL MENU
  6        
  7         @ 00, 01 PROMPT "PAYABLES"
  8         @ 00, 14 PROMPT "RECEIVABLES"
  9         @ 00, 28 PROMPT "TAXES"
 10        
 11         i = 1
 12         MENU TO i
 13
 14         DO CASE i
 15                
 16                 CASE i=1
 17                         @ 02, 01 PROMPT "P01"
 18                         @ 03, 01 PROMPT "P02"
 19                         @ 04, 01 PROMPT "P03"
 20                         @ 05, 01 PROMPT "P04"
 21                         @ 06, 01 PROMPT "P05"
 22                        
 23                         i = 1
 24                         MENU TO i
 25                
 26                 CASE i=2
 27                         @ 02, 14 PROMPT "R01"
 28                         @ 03, 14 PROMPT "R02"
 29                         @ 04, 14 PROMPT "R03"
 30
 31                         i = 1
 32                         MENU TO i
 33                
 34                 CASE i=3
 35                         @ 02, 28 PROMPT "T01"
 36                         @ 03, 28 PROMPT "T02"
 37                         @ 04, 28 PROMPT "T03"
 38                         @ 05, 28 PROMPT "T04"
 39                         @ 06, 28 PROMPT "T05"
 40
 41                         i = 1
 42                         MENU TO i
 43
 44         ENDCASE
 45
 46 RETURN

The only thing I have added is the PROCEDURE main and the RETURN
The remaining code is as is.

I have three questions:

- Why variable "i" is not defined as PUBLIC/PRIVATE/LOCAL/STATIC ?
- Why i = 1 is not i := 1
- Why CASE i=1 and not CASE i==1? Is a comparison, isn't it?

Thanks,

Klas Engwall

unread,
Oct 4, 2023, 4:44:12 PM10/4/23
to harbou...@googlegroups.com
Hi Mario,

> I am following an old example in a Clipper book from late 80s.

Don't use Clipper books from the 80s :-)

At that time we had the "season" versions. The last of those was Summer
87, which I suppose your book targets. The first 5.x version came in the
early 90s, and that changed a lot (see below)
Well, line 3 says "LOCAL i" which surprises me given the age of the
book. As far as I remember the LOCAL statement arrived with Clipper 5.0.

> - Why i = 1 is not i := 1
> - Why CASE i=1 and not CASE i==1? Is a comparison, isn't it?

The := and == operators also arrived with Clipper 5.0 so they were
unknown when your book was written.

Regards,
Klas

Mario Emmanuel

unread,
Oct 4, 2023, 4:54:31 PM10/4/23
to harbou...@googlegroups.com
Thanks for your answer Klas,

The "LOCAL i" was not there in the book, I added it while trying to figure it out. That was a typo while posting the message.
Same for the "DO CASE i", it is just "DO CASE".

So if I understood correctly, before Clipper 5.0, you did not have ":=" and "==" and "=" was used either as assignment or comparison based on context.

Still, why were variables not defined before Clipper 5.0? What was the expectation on them?

BTW, The book is the one from Rick Spence (1989) and I am finding it very useful to understand how to articulate the text user interfaces.

BR,



--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://groups.google.com/group/harbour-users
---
You received this message because you are subscribed to a topic in the Google Groups "Harbour Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-users/VcDpkLY9m5U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/aac03412-3337-ddc6-6a70-96cfc57c5aa2%40engwall.com.

José M. C. Quintas

unread,
Oct 4, 2023, 6:07:10 PM10/4/23
to harbou...@googlegroups.com

i = 1 and i := 1 are the same, but i := 1 can be used inside another things:

a := b := 5

IF ( b := 1 ) == 1


== makes exact comparision, more important on strings

test:

? "A" = "AB", "AB" = "A", "A" == "AB", "AB" ==  "A"


Why PUBLIC/PRIVATE/LOCAL/STATIC ?

You can use any type, but each type have it's own visibility, check about the types.

On a single module you do not see difference.

José M. C. Quintas

--
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: https://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/59d51838-a77f-4477-bc87-73036f440425n%40googlegroups.com.

Don Lowenstein

unread,
Oct 4, 2023, 6:10:09 PM10/4/23
to harbou...@googlegroups.com
it can also be used to update database variables.

For example:

DBALIAS->SOMEVAR := 'ABC'



From: harbou...@googlegroups.com <harbou...@googlegroups.com> on behalf of José M. C. Quintas <jmcqu...@gmail.com>
Sent: Wednesday, October 4, 2023 5:06 PM
To: harbou...@googlegroups.com <harbou...@googlegroups.com>
Subject: Re: [harbour-users] Is there any difference between how variables were defined in Clipper versus how they are defined in Harbour?
 

Auge & Ohr

unread,
Oct 4, 2023, 10:46:17 PM10/4/23
to Harbour Users
> Still, why were variables not defined before Clipper 5.0? What was the expectation on them?

variabel before v5.x are all PUBLIC / PRIVATE

as i know harbour is based on v5.x so be careful ad Klas say which S87 Book

Jim

Klas Engwall

unread,
Oct 5, 2023, 5:49:24 AM10/5/23
to harbou...@googlegroups.com
Hi Mario,

> Thanks for your answer Klas,
>
> The "LOCAL i" was not there in the book, I added it while trying to
> figure it out. That was a typo while posting the message.
> Same for the "DO CASE i", it is just "DO CASE".

OK, so order has been restored. That LOCAL declaration upset my sense of
history :-)

> So if I understood correctly, before Clipper 5.0, you did not have ":="
> and "==" and "=" was used either as assignment or comparison based on
> context.

Yes, that is correct. I think you have the complete picture now based on
what the other guys said.

> Still, why were variables not defined before Clipper 5.0? What was the
> expectation on them?

That is a question of history. Clipper grew out of the need to compile
dBase code. And dBase had its own history from Vulcan in the 70s. They
were both intended to be used interactively while allowing the users to
write code snippets to automate simple things. Then everything evolved,
one piece at a time, from there. Nantucket, the company behind Clipper,
realized that more could be done but that a more strict approach was
needed for the future. So they created Clipper 5.0, which was a
revolution compared to Summer 87. That took them about four years to
complete. So Clipper 5 was, under the hood, an entirely different
product compared to the season versions, but Nantucket couldn't throw
out everything that the existing Clipper users had built their
applications around, so they kept the entire old syntax by clever use of
the preprocessor on top of the new syntax. And Harbour still keeps that
old syntax in the same way today for backwards compatibility. So you can
still write code as if you were using Vulcan.

> BTW, The book is the one from Rick Spence (1989) and I am finding it
> very useful to understand how to articulate the text user interfaces.

Rick wrote some very good books, but don't let his old ones give you bad
habits :-)

Regards,
Klas
Reply all
Reply to author
Forward
0 new messages