Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Remove excessive spaces in string
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01414370
Message ID:
01414782
Vues:
44
I saw a sample where someone is using aline() to create an array from strings so here is what I came up with:
spamstr = alltrim(xfer_payroll.spall)
ALINES(a__gen5, CHRTRAN(spamstr," ",CHR(13))) && copy the values to array
If vartype(a__gen5) # 'U' and vartype(a__gen5) # 'L' 
  first_sw = .t.                   
  FOR i = 1 TO ALEN(a__gen5,0)
	IF  !EMPTY(ALLTRIM(a__gen5(i)))
		IF first_sw = .t.
			first_sw = .f.
	 		crtspam = ALLTRIM(a__gen5(i)) && don't put space between string
		ELSE 
 			crtspam = crtspam + ' ' + ALLTRIM(a__gen5(i)) && put space while building spam str
 		ENDIF 
 	ENDIF 
  ENDFOR                     
  RELEASE a__gen5
  ALINES(a__gen6, CHRTRAN(crtspam," ",CHR(13))) && copy the values to array                    
                    FOR .f1 = 1 TO ALEN(a__gen6,0)
                    	g1 = ALLTRIM(a__gen6(.f1))
                        
                        Do case
                            Case g1 == 'FLSA'
                                cummflsa = evaluate('xfer_payroll.spamt'+allt(str(.f1,3,0)))
	                            hldflsa = hldflsa + cummflsa
the only problem is that the array always seems to be created, even if there is no value in the spamstr. I'm not sure how I can prevent from going into a for loop if the string is empty after testing for "If vartype(a__gen5) # 'U' and vartype(a__gen5) # 'L' ". I was hoping no array is created if the string is empty. However it does and I don't know how to prevent from looping on an empty array. thanks....Nick
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform