Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this code produces different results?
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Why this code produces different results?
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01121979
Message ID:
01121979
Views:
70
Hi everybody,

Bellow is my code from frmFileSelector Init. This form shows files from the directory in the grid. I use new version (unpublished :() of Frank Dietrich's library. I noticed, that sometimes I see broken picture link instead of the nice icon and nothing in the file type. The difference I see is that the files that are displayed wrongly are on the network drive and were created using REPORT FORM TO .. ASCII command. They displayed correctly in Windows Explorer.

Thanks for any suggestions.
lparameters tcDirectory, tcFileExt, tcFilterExpr

local lcFileType, lcIconFile, ;
	loIconBuddy, lcCondition, llAddFile, ;
	lcFileName, lnI, lnFiles, ;
	llIconBuddy, lcDir, lnPos, lnK

local array laFiles[1], laExtUsed[1,3]
if empty(m.tcDirectory)
	lcDir = getdir()
	if empty(m.lcDir)
		return .f.
	endif
else
	lcDir = addbs(m.tcDirectory)
endif
this.caption = this.caption + ' from ' + m.lcDir
tcFileExt = evl(m.tcFileExt,"")
tcFilterExpr = evl(m.tcFilterExpr,"")

lnFiles = adir(laFiles, m.lcDir + "*." + ;
	evl(m.tcFileExt,"*"),"HS",1) 

if m.lnFiles = 0
	=ErrorMsg("No files found in " + m.tcDirectory)
	return .f.
endif
lnK = 0
store .f. to llAddFile, llIconBuddy

for lnI = 1 to m.lnFiles
	if (empty(m.tcFileExt) or ;
		upper(justext(laFiles[m.lnI,1]))== upper(m.tcFileExt)) ;
		and not ;
		inlist(lower(justext(laFiles[m.lnI,1])),"exe","dll","ico")
		lcFile = m.lcDir + laFiles[m.lnI,1]
		lcFileName = juststem(m.lcFile)

		if not empty(m.tcFilterExpr)
			lcCondition = strtran(m.tcFilterExpr, ;
				"##FILENAME##","lcFileName")
			* Evaluate the filter condition	
			if evaluate(m.lcCondition) 
				llAddFile = .t.
			endif
		else
			llAddFile = .t.
		endif
		if m.llAddFile
			if not m.llIconBuddy
				thisform.newobject("oIconBuddy", ;
				"IconBuddy", "IconBuddy.vcx")
				llIconBuddy = .t.
			endif
			lnPos = iif(m.lnK = 0, 0, ;
				ascan(laExtUsed,upper(justext(m.lcFile)),1,-1,1, 14))
			if m.lnPos > 0
				lcIconFile = laExtUsed[m.lnPos, 2]
				lcFileType = laExtUsed[m.lnPos, 3]
			else
** Create bitmaps and not icons
				thisform.oIconBuddy.CreateTmpIcons(m.lcFile,.f.,.t.)
** Get the small picture
				lcIconFile = ;
				thisform.oIconBuddy.GetTMPIconFileName( ;
				lower(justext(m.lcFile)),.f.,.t.)
				lcFileType = thisform.oIconBuddy.cFileType
				lnK = m.lnK + 1
				dimension laExtUsed[m.lnK, 3]
				laExtUsed[m.lnK,1] = upper(justext(m.lcFile))
				laExtUsed[m.lnK, 2] = m.lcIconFile
				laExtUsed[m.lnK, 3] = m.lcFileType
			endif

			insert into curFiles values ;
				(justfname(m.lcFile), laFiles[m.lnI,2], ;
				m.lcFileType, ;
				ctot(dtoc(laFiles[m.lnI,3]) + ;
				" " + laFiles[m.lnI,4]), ;
				m.lcIconFile, ;
				alltrim(str(ceiling(laFiles[m.lnI,2]/1024))) + " KB" )
		endif
		llAddFile = .f.
	endif
endfor

if reccount('curFiles') = 0
	=ErrorMsg("The directory " + m.lcDir + ;
		" does not contain files")
	return .f.
endif

if not dodefault()
	return .f.
endif

thisform.uRetVal = ""
thisform.grdFiles.colImage.dynamicfontshadow = ;
	"thisform.grdFiles.colImage.Refresh()"
If it's not broken, fix it until it is.


My Blog
Next
Reply
Map
View

Click here to load this message in the networking platform