> Hi > > Can an example of effective solutions? > And why this decision is not effective? > > FieldGet (fieldnum ()) - a very cumbersome > example: > 1. ALIAS1-> & ( "NAME1") + = ALIAS2-> & ( "NAME2") > 2. ALIAS1-> (FIELDPUT (FIELDNUM ( "NAME1"), FIELDGET (FIELDNUM ( > "NAME1") + ALIAS2-> (FIELDGET (FIELDNUM ( "NAME2")))) > (easily be mistaken with brackets)
Macro expansion is always expensive, so it's inefficient. This fact was realized by Clipper 5 dev team and that's why they introduced FIELDGET() and friends. In your case, there is seemingly a double macro expansion done, finally to a codeblock, which codeblock is then EVAL()-ed. This is probably the slowest way a field value can be extracted, since all operations are expensive: macro eval (2x), codeblock creation, codeblock evaluation. This was suggested: EVAL( &( "{|| field->&('" + name + "') }" ) ) -> RETURN FIELDGET( FIELDPOS( name ) ) To my eyes the second is much cleaner, simpler, and much more typo-proof. You can even create a simple macro: #xtranslate FIELDGETBYNAME( <name> ) => FIELDGET( FIELDPOS( <name> ) ) and use: RETURN FIELDGETBYNAME( name ) Brgds, Viktor _______________________________________________ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour