hb_gti() doc notes 1

199 views
Skip to first unread message

mstuff kstuff

unread,
Mar 1, 2020, 11:31:27 PM3/1/20
to Harbour Users
 I am playing with GT_INFO() and I have made some notes
to my HB_GT_INFO.doc which I downloaded from Juan Luis
Gamero's web page. I thought that it may be useful to
others. Hopefully Juan, after confederation may include
something like them it on his page also.

REQUEST HB_GT_wvT_DEFAULT  // or maybe something else?
 hb32 w/o gtwvG, it is required.          // Don't know exactly why.
Otherwise gtinfo() will not work.

If you didn’t want to include the whole hbgtinfo.ch file, you can use only the #defines that you need or you can use the value/number (not easily understandable).

HB_GtInfo( < the value/number >, [ <xParam1> ], [ <xParam2> ] ) ⇒ <xResult>
 or
HB_GtInfo( < the phrase as #defined >, [ <xParam1> ], [ <xParam2> ] ) ⇒<xResult>

Value/number|Input|Output|...

In GTWIN: Always CERO/zero or NIL

HB_GTI_CLIPBOARDDATA
Sets/fills the clipboard
 hb_gtInfo(HB_GTI_CLIPBOARDDATA,xxxxx)   or
 hb_gtInfo(15,xxxxx)

Gets/retrieves the clipboard
  xStuff = hb_gtInfo(HB_GTI_CLIPBOARDDATA)  or
               hb_gtInfo(15)

nHowLongIsIt = LEN(( hb_gtInfo(HB_GTI_CLIPBOARDDATA))  5

HB_GTI_CLIPBOARDPASTE
 xGetTheStuff = hb_gtInfo(HB_GTI_CLIPBOARDPASTE ) or
 hb_gtInfo(16)




Klas Engwall

unread,
Mar 2, 2020, 3:27:29 AM3/2/20
to harbou...@googlegroups.com
Hi Mike,

> If you didn’t want to include the whole hbgtinfo.ch file, you can use
> only the #defines that you need or you can use the value/number (not
> easily understandable).
>
> HB_GtInfo( < the value/number >, [ <xParam1> ], [ <xParam2> ] ) ⇒ <xResult>
>  or
> HB_GtInfo( < the phrase as #defined >, [ <xParam1> ], [ <xParam2> ] )
> ⇒<xResult>
>
> Value/number|Input|Output|...
>
> In GTWIN: Always CERO/zero or NIL
>
> HB_GTI_CLIPBOARDDATA
> Sets/fills the clipboard
>  hb_gtInfo(HB_GTI_CLIPBOARDDATA,xxxxx)   or
>  hb_gtInfo(15,xxxxx)
>
> Gets/retrieves the clipboard
>   xStuff = hb_gtInfo(HB_GTI_CLIPBOARDDATA)  or
>                hb_gtInfo(15)
>
> nHowLongIsIt = LEN(( hb_gtInfo(HB_GTI_CLIPBOARDDATA))  5
>
> HB_GTI_CLIPBOARDPASTE
>  xGetTheStuff = hb_gtInfo(HB_GTI_CLIPBOARDPASTE ) or
>  hb_gtInfo(16)

NO, NO, NO! Please NEVER suggest using the numeric values from any
header file. After having been involved in Clipper/Harbour support for
almost 35 years I know that the most inexperienced users will follow
that advice and get themselves into trouble.

It is a BAD programming practice and makes the code hard to read. If
someone else takes over your project after you, or you yourself try to
understand that old code five years from now - or five weeks from now -
it vill be a lot harder to debug than if you use the named constants.
And it is also more error prone. If you mistype a constant name you will
get an error at compile time (provided that you set the warning level
appropriately, or you will otherwise get a clear rutime error). But if
you mistype the numerical code the application will happily do what you
tell it, and then you will wonder why it is misbehaving.

So always use the named constants. And there is no reason whatsoever to
pull them out of the header files and duplicate them in every prg file
where you perform a certain operation.

Regards,
Klas

Anand K Gupta

unread,
Mar 2, 2020, 5:18:20 AM3/2/20
to harbou...@googlegroups.com
I agree with Klas.

By using direct #define numbers in code you are not helping the compiler, neither you are decreasing the obj/exe size.
But you are creating problem for human coder.

There is  a reason why #define were made.

Regards,

Anand


--
--
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/4c789c85-4203-0078-fe26-73cb4741ae94%40engwall.com.

mstuff kstuff

unread,
Mar 2, 2020, 10:43:53 AM3/2/20
to Harbour Users
Okay.
You can delete the post if you want to.
Mike
Reply all
Reply to author
Forward
0 new messages