FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Assignment = or := ?
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Assignment = or := ?
Posted: Mon Jan 18, 2010 10:01 AM

I have noticed that in FIVEWIN the assign is done with = and := .

Could someone explain when to use = and when := .

Thanks in advance
Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Assignment = or := ?
Posted: Mon Jan 18, 2010 11:12 AM

= is the normal assignment operator while := in the inline version of the same operator. As an example:

REDEFINE BUTTON ACTION x = 1 // wrong!

REDEFINE BUTTON ACTION x := 1 // ok!

x = 1 // ok!
x := 1 // ok! It's the same
a = b = 1 // means a = .T. if b = 1 or .F. if b != 1
a = b := 1 // means a = 1 and b = 1
a := b := 1 // the same as above

EMG

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Assignment = or := ?
Posted: Mon Jan 18, 2010 07:02 PM

Otto,

If you have the Clipper help file, there are good descriptions in there.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Assignment = or := ?
Posted: Mon Jan 18, 2010 09:29 PM

Hello Enrico, hello James,

Thank you for explaining to me.
For example in TRBGroup-class assignments are made with := in TBtnBmp classe with =
( VB6 style which I don’t like). I thought that there is maybe a difference which I am not aware of.
Best regards,
Otto

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Assignment = or := ?
Posted: Mon Jan 18, 2010 09:58 PM
= is not a VB assignment style at all. It's the most widely used token for the assignment operator. And it's good style in xBase too. I can't see why to use the inline assignment operator in a statement like

Code (fw): Select all Collapse
a := 1


and I don't like it for sure.

EMG
Posts: 389
Joined: Mon Oct 13, 2008 11:26 AM
Re: Assignment = or := ?
Posted: Tue Jan 19, 2010 10:31 AM

To be sure, use := always 8)

Email: SamirSSabreu@gmail.com
xHarbour 1.2.3 + Fwhh 20.2
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Assignment = or := ?
Posted: Tue Jan 19, 2010 10:39 AM

Ok, so to be sure use always + because * is too complicated. :-)

EMG

Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: Assignment = or := ?
Posted: Tue Jan 19, 2010 11:19 AM

Hello Enrico,
Fivewin classes are my reference for good programming style. As I see that for the same assignment in different classes = and := are used I asked which is the right way.
I personally prefer :=. Why context determining which is meant.
Thanks again for your help.
Best regards,
Otto

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Assignment = or := ?
Posted: Tue Jan 19, 2010 01:41 PM

Otto,

We do prefer to use "=" unless ":=" (inline assignment) is required.

Anyhow, both ways are valid, though "=" is simpler :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion