Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple string manipulation problem
Message
De
06/08/2001 13:07:46
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00540244
Message ID:
00540252
Vues:
11
This message has been marked as a message which has helped to the initial question of the thread.
Nadya,

This is the function we use,
********************************************************************************
FUNCTION ADDALIAS( tcExpr, tcAlias )
********************************************************************************
*
*   OVERVIEW:  Adds the alias name to a list of field names contained in an
*	       index expression so that alias and field names are paired, and
*	       returns the amended expression.
*
*   EXAMPLE:   ADDALIAS( "sys_code + pipe", "ansurvey" ) ->
*			"ansurvey.sys_code + ansurvey.pipe"
*
*   PARAMETERS:	tcExpr	The index expression to which alias is to be added
*			tcAlias		The alias name to be added.
*
*   RETURN:	(C)	The index expression with alias name added to each field
*			name in the expression.
*
LOCAL lnNumFields, lcExpr, lcThisField, lnThisFieldPosition, lnI, lcAliasedExpr

DO WHILE " " $ tcExpr
   tcExpr = STRTRAN( tcExpr, " ", "" )
ENDDO

*   Get the number of fields in the expression
lnNumFields = OCCURS( '+', tcExpr ) + 1

*   This variable will be used to hold the amended expression with alias name
*   added to each field in the expression.
lcAliasedExpr = ''

*   NOTE: There is no testing to determine whether the field is actually in the
*   specified table.  Testing if wanted should be added here.
FOR lnI = 1 TO lnNumFields

    IF lnI = lnNumFields
        lcThisField = lcExpr
    ELSE
        lcThisField = LEFT( lcExpr, AT( '+', lcExpr ) - 1 )
    ENDIF

    IF OCCURS( '( ', lcThisField ) > 0
        lnThisFieldPosition = ;
            AT( '( ', lcThisField, OCCURS( '( ', lcThisField ) ) + 1
    ELSE
        lnThisFieldPosition = 0
    ENDIF

    lcAliasedExpr = ;
        lcAliasedExpr + IIF( !EMPTY( lcAliasedExpr ), '+', '' ) + ;
            STUFF( lcThisField, lnThisFieldPosition, 0, tcAlias + '.' )

    lcExpr = SUBSTR( lcExpr, AT( '+', lcExpr ) + 1 )

NEXT

RETURN lcAliasedExpr

ENDFUNC && ADDALIAS() 
Hope this helps,

Regards
Jim Edgar
Jurix Data Corporation
jmedgar@yahoo.com

No trees were destroyed in sending this message. However, a large number of electrons were diverted from their ordinary activities and terribly inconvenienced.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform