Hi

2010/3/21 Viktor Szakáts <harbour...@syenar.hu>:

>> 1. ALIAS1-> & ( "NAME1") + = ALIAS2-> & ( "NAME2")
>> 2. ALIAS1-> (FIELDPUT (FIELDNUM ( "NAME1"), FIELDGET (FIELDNUM (
>> "NAME1") + ALIAS2-> (FIELDGET (FIELDNUM ( "NAME2"))))

> You can even create a simple macro:
>
>   #xtranslate FIELDGETBYNAME( <name> ) => FIELDGET( FIELDPOS( <name> ) )
>
> and use:
>
>   RETURN FIELDGETBYNAME( name )

Compare the ease of writing and understanding:

1. ALIAS1->&("NAME1") + = ALIAS2->&("NAME2") + something
2. ALIAS1->(FIELDPUTBYNAME( "NAME1", FIELDGETBYNAME("NAME1") +
ALIAS2->(FIELDGETBYNAME( "NAME2")) + something ))

IMO first version is still better
speed of execution in this case - a secondary factor (a very small
operation with running infrequently and not in the loop), is more
important than understanding and ease of coding
Where required speed of execution - used functions or # xtranslate

The issue arose from the fact that it works in the PRG, but in the
macro and the HRB does not work (although the HRB compile as usual
PRG)

2010/3/21 Mindaugas Kavaliauskas <dbto...@dbtopas.lt>:

> These are more clear without & :
> 1) alias1->NAME1 += alias2->NAME2
> 2) alias1->(NAME1 := NAME1 + alias2->NAME2)
> (I assumed FIELDNUM() means FIELDPOS())

NAME1 - is a variable, not a field name
therefore, this example is invalid

-- 
Alexandr
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to