Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Field values from a variable
Message
 
À
16/09/1998 10:30:43
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00136777
Message ID:
00137277
Vues:
19
>Perry,
>Found your code in another thread. I couldn't understand how you will utilize this but does replace :
close all
>set defa to \temp
>=rand(-1)
>create cursor xtest (Category c(10), Subcategory c(10), Amount i)
>for ix = 1 to 5000
>	lnCategory		= int(rand()*10)
>	lnSubCategory	= int(rand()*252)
>	insert into xtest ;
>		values ("Cat"+padl(lnCategory,2,"0"),;
>		"SubCat"+padl(lnSubCategory,3,"0"),;
>		int(rand()*1000))
>endfor
>
>SELECT Category , Subcategory , SUM(amount);
>    FROM xtest ;
>    GROUP BY Category, SubCategory ;
>    ORDER BY Category, SubCategory ;
>    INTO CURSOR SYS(2015)
>
>* Parameters:
>*
>* 		 Parm1 - output file/cursor name (default "xtab.dbf")
>* 		 Parm2 - cursor only (default .F.)
>* 		 Parm3 - close input table after (default .T.)
>* 		 Parm4 - show thermometer (default .T.)
>* 		 Parm5 - row field 	(default 1)
>* 		 Parm6 - column field 	(default 2)
>* 		 Parm7 - data field 	(default 3)
>* 		 Parm8 - total rows	(default .F.)
>* 		 Parm9 - totaling options (0-sum, 1-count, 2-% of total)
>* 		 Parm10 - display Null values
>
>DO (_GENXTAB) WITH 'XTAB',.t.,.t.,.t.,,,,.t.,0,.f.
>browse
>  SELECT xtab
>  GO BOTTOM
>  APPEND BLANK IN xtab
>  REPLACE (field(1,"xtab")) WITH 'TOTAL'
>  FOR lnCnt = 2 TO FCOUNT()
>    lcFieldName = 'xtab.'+FIELD(lnCnt)
>    CALCULATE SUM(&lcFieldName) TO lnSum
>    GO BOTTOM
>    REPLACE &lcFieldName WITH lnSum
>  ENDFOR
>  CREATE DBF ATA_Report (ata c(5) , project1 c(5), project2 c(5), ;
>    project3 c(5), project4 c(5), project5 c(5), project6 c(5), ;
>    project7 c(5), project8 c(5), project9 c(5), project10 c(5), ;
>    project11 c(5), project12 c(5), project13 c(5), project14 c(5), ;
>    project15 c(5))
>  select 0
>  CREATE DBF ATA_Report1 (ata c(5) , project1 i, project2 i, ;
>    project3 i, project4 i, project5 i, project6 i, ;
>    project7 i, project8 i, project9 i, project10 i, ;
>    project11 i, project12 i, project13 i, project14 i, ;
>    project15 i)
>  GO TOP
>  SELECT xtab
>  GO TOP
>  llEnd = .f.
>  DO WHILE !EOF()
>	lnFieldTot = 2
>    FOR lnFCnt = 1 TO 15
>      SELECT xtab
>      lcFName = FIELD(lnFieldTot)
>      lcFCnt = ltrim(STR(lnFCnt))
>      IF lnFCnt < 10
>        lcATAFName = "project"+RIGHT(lcFCnt,1)
>      ELSE
>        lcATAFName = "project"+RIGHT(lcFCnt,2)
>      ENDIF
>      IF lnFCnt = 1
>        SELECT ATA_Report
>        GO BOTTOM
>        APPEND BLANK
>        REPLACE ata WITH (eval("xtab."+field(1,"xtab")))
>
>        insert into ATA_Report1 (ata) ;
>        	values ( eval("xtab."+field(1,"xtab")) )
>      ENDIF
>      IF !EMPTY(lcFName)
>        lnATAFValue = nvl(EVAL('xtab.'+lcFName),0)
>        lcATAFValue = ltrim(STR(lnATAFValue))
>        SELECT ATA_Report
>        GO BOTTOM
>        REPLACE (lcATAFName) WITH lcATAFValue
>		if type("lnATAFValue") = "N"
>	        replace (lcATAFName) with lnATAFValue in "ATA_report1"
>	    endif
>	  ELSE
>        llEmpty = .T.
>        EXIT
>      ENDIF
>      lnFieldTot = lnFieldTot + 1
>      IF lnFCnt = 15
>        lnFCnt = 0
>      ENDIF
>      SELECT xtab
>      IF lnFieldTot > FCOUNT()
>        llEnd = .T.
>        EXIT
>      ENDIF
>    ENDFOR
>    SELECT xtab
>    Skip
>    IF EOF()
>      IF!llEnd
>        GO TOP
>      ELSE
>        EXIT
>      ENDIF
>    ENDIF
>  ENDDO
>select ata_report
>browse
>select ata_report1
>browse
Cetin


Thanks Cetin,

The LTRIM() was all it needed to do the trick. Works pretty well now!! I read the help file. I thought all *TRIM() functions were pretty much the same. You learn something every day.
Perry E. Chrzanowski
Programmer/Analyst
Saturn (Solutions) Inc.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform