Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Field type is D and value is .null.
Message
 
À
01/02/2006 16:36:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Divers
Thread ID:
01092558
Message ID:
01092663
Vues:
18
I do not understand why you are limited to something like you presented, supposedly doing scan and using macro substitution.
Also, if you are going to replace NULLs in the table, why nulls will be in Excel file?

Anyway see if this is what you need:
CLEAR 
CLOSE TABLES all
CREATE TABLE yy (fldchar c(10), fnum n(3), fdt D null, ftm T)
FOR ia=1 TO 10
	insert into yy VALUES (;
		PADL(ia,10,"0"),;
		ia,;
		IIF(RECNO()%2=0,DATE()-ia,NULL),;
		DATETIME()-ia)
ENDFOR

COPY TO c:\yy.xls xls		&& get Excel files with NULLS

DO case  && choose the case that you like
case .t.  && replace one field at once
	FOR ia=1 TO FCOUNT()
		lccom="replace "
		IF TYPE("EVALUATE(field(ia))")="D"
			lccom=lccom + field(ia)+" with DATE() for ISNULL("+field(ia)+")"
			&lccom
		ENDIF
	ENDFOR
CASE .F.  && record by record
	SCAN 
		FOR ia=1 TO FCOUNT()
			IF isnull(EVALUATE(field(ia))) AND TYPE("EVALUATE(field(ia))")="D"
				REPLACE (FIELD(ia)) WITH DATE()
			ENDIF
		ENDFOR
	ENDSCAN
ENDCASE
*END, no NULLS in the table, and there will be no nulls in Excel file
RETURN
Now let us work with Excel File assuming it has null values in the
known field FDT
oExcel= CREATEOBJECT("Excel.Application")
WITH oExcel
	.Visible = .t.
	.WorkBooks.Open("c:\yy.xls")
	WITH .Activesheet
		FOR ia=1 TO .UsedRange.Rows.Count
			WITH .cells(ia,3)
				IF EMPTY(.value) OR ISNULL(.value)
					.value=DATE()
				ENDIF
			ENDWITH
		ENDFOR
	ENDWITH
ENDWITH
oExcel=NULL
>Hi,
>
>I need something like:
>
> for nCnt = 3 to FCOUNT()
> if TYPE( &field(nCnt) ) == "D" .and. ISNULL( &field(nCnt))
> replace &field(nCnt) wit h date()
>
>But something is wrong ...
>
>
>For Excel I need function which recognize .null. values so I could replace them ...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform