Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper File Order
Message
 
 
To
23/10/2002 09:51:18
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00714342
Message ID:
00714353
Views:
21
>This is probably almost out of scope, but I am using a VFP program to make it happen.
>
>I have a directory of drawing files named as such 117851F1.pdf, 117851F2.pdf, 117851F3.pdf etc. With automation code I want to make these into one pdf file which I have no problem doing. However, the trouble I have is properly looping through the files in the directory to make sure the first file is F1, second F2 etc. This really gets shakey when there are more than nine files then I have 117851F1, 117851F10, 117851F2. One more complication is some times the file names are a bit longer example: 117853-401F1, 117853-401F2. How can I make sure when I go to insert a page into my pdf file I really have the proper drawing sheet?

Here is some sample code that will sort an array according to what you need. The array you would run this code against would be created by ADIR(laFiles, "location_of_pdf_files\*.pdf"). The dummy file name is placed in element 1 of each row of the array so ASORT will work. The real filename is retained in element 2 of each row in the array.
local laFiles(7,2), lcFile, lcNew
laFiles(1, 1) = [117851F1.pdf]
laFiles(2, 1) = [117851F2.pdf]
laFiles(3, 1) = [117851F3.pdf]
laFiles(4, 1) = [117851F10.pdf]
laFiles(5, 1) = [117851F2.pdf]
laFiles(6, 1) = [117853-401F1.pdf]
laFiles(7, 1) = [117853-401F2.pdf]
FOR lnI = 1 TO ALEN(laFiles, 1)
	lcFile = laFiles[lnI, 1]
	laFiles[lnI, 2] = lcFile
	lcFile = JUSTSTEM(lcFile)
	lcNew = CHRTRAN(SUBSTR(lcFile, AT([F], lcFile)), [F], [])
	lcNew = [F] + PADL(lcNew, 2, [0])
	lcFile = SUBSTR(lcFile, 1, AT([F], lcFile) - 1) + lcNew
	laFiles[lnI, 1] = lcFile 
ENDFOR
ASORT(laFiles)
CLEAR
DISPLAY MEMORY LIKE laFile*
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform