Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding data to an array froms several arrays
Message
De
26/04/2007 06:06:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01219995
Message ID:
01220046
Vues:
22
>How do you add data from one element of several arrays into a new arrays?
>
>For example:
>
>You have:
>
>SET DEFAULT TO C:\GRAPHICS
>DIMENSION aTIF[1], aFJP[1], aPNG[1], aJPG[1], aIMAGES[1]
>
>ADIR(aTIF, "*.TIF")
>ADIR(aFJP, "*.FJP")
>ADIR(aPNG, "*.PNG")
>ADIR(aJPG, "*.JPG")
>
>ACOPY(aTIF, aImages) ???
>
>* At this point, how do you add the resulting FILENAMES only from each array,
>* if there is data, into the last array, aImages?
>
>
You need a loop for that. ie:
SET DEFAULT TO C:\GRAPHICS
DIMENSION aTIF[1], aFJP[1], aPNG[1], aJPG[1], aIMAGES[1]

ADIR(aTIF, "*.TIF")
ADIR(aFJP, "*.FJP")
ADIR(aPNG, "*.PNG")
ADIR(aJPG, "*.JPG")
myAcolCopy(@aTif, @aImages, 1,1)
myAcolCopy(@aFjp, @aImages, 1)
myAcolCopy(@aPng, @aImages, 1)
myAcolCopy(@aJpg, @aImages, 1)

PROCEDURE myAColCopy(taSource, taDestination, tnColumn, tnStart)
IF EMPTY(m.tnStart)
	tnStart = ALEN(taDestination)+1
endif
DIMENSION taDestination[m.tnStart-1+ALEN(taSource,1)]
LOCAL ix
FOR ix=1 TO ALEN(taSource,1)
	taDestination[m.tnStart-1+m.ix] = taSource[m.ix, m.tnColumn]
endfor
RETURN ALEN(taSource,1)
endproc
However there is an easier way with using filer.dll that ships with VFP:
LOCAL array aImages[ 1 ]
oFiler = CREATEOBJECT('Filer.FileUtil')
WITH oFiler
  .SearchPath = "c:\graphics"
  .Subfolder = 0 && do not search subfolders
  .FileExpression = "*.TIF;*.FJP;*.PNG;*.JPG"
  .SortBy = 3
  IF  .Find(0) > 0
   DIMENSION aImages[ .Files.Count ]
   FOR ix=1 TO .Files.Count
	aImages[m.ix] = .Files[m.ix].Name
   ENDFOR
  endif
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform