home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR7
/
FOXTAILS.ZIP
/
WPCONV.PRG
< prev
Wrap
Text File
|
1992-03-28
|
3KB
|
96 lines
FUNCTION Wpconv
PARAMETERS Flnm, Wp, Blnk, Dlim
* This program assumes the following:
* All databases, relations, filters and indexes are set
* The main database is selected and pointed at top or
* wherever.
* That the Wp parameter is an array. Each element in the
* Wp array contains the name of a field or variable to be included.
* If the element is from another database, the alias should be part
* of the name. The variables need to be sequentially filled
* into the array that's passed to this program
* The variable Flnm contains a valid ALTERNATE Filename
* The parameter Blnk is whether or not a blank record should
* be stuffed at the beginning of the file.
* That you're a deserving boy or girl.
*
* Written by R.L. Coppedge
* Copyright 1991 dbF Software Productions
* By the way, dbF also has:
* SysTrak A Computer Hardware/Software Inventory System
* Flags A Flatfile Application Gen. for db3,4 and Fox
* ClasAdz A Classified/Notice system for Networks
* FoxTails #1 A collection of FoxPro tools (like this one)
* Contact dbF for more information.
* dbF Software Productions
* P.O. Box 37194
* Cleve., Ohio 44137-0194
* CIS: 72117,165
* (216)491-4581
*
* This code may be modified, but leave this original notice up
* here intact, if ya don't mind. (Add your own comments about
* how much better you made it if you like)
PRIVATE Wpfld, Wpcnt
SET TALK OFF && If you haven't, I will!
IF EOF() && The database has nothing to give
WAIT "There are no records to copy!" WINDOW
RELEASE Wpfld, Wpcnt
RETURN .F.
ENDIF
IF EMPTY(Flnm) .OR. ALEN(Wp)=0 && I need something...
WAIT "I need at least a file name and 1 Field...Please?" WINDOW
RELEASE Wpfld, Wpcnt
RETURN .F.
ENDIF
SET ALTERNATE TO &Flnm.
SET ALTERNATE ON
SET CONSOLE OFF
Fst = .T.
DO WHILE !EOF()
WpFld = ""
FOR Wpcnt = 1 TO ALEN(Wp)
DO CASE
CASE TYPE(Wp(Wpcnt)) = "C" && Character Field
Wpfld = Wpfld + ALLTRIM(EVALUATE(Wp(Wpcnt)))
CASE TYPE(Wp(Wpcnt)) $ "FN" && Numeric Field
Wpfld = Wpfld + ALLTRIM(STR(EVALUATE(Wp(Wpcnt))))
CASE TYPE(Wp(Wpcnt)) = "D" && Date Field
Wpfld = Wpfld + DTOC(EVALUATE(Wp(Wpcnt)))
CASE TYPE(Wp(Wpcnt)) = "L" && Logical Field
Wpfld = Wpfld + IIF(EVALUATE(Wp(Wpcnt)),"Y","N")
CASE TYPE(Wp(Wpcnt)) = "M" && Memo Field
SET ALTERNATE OFF
SET CONSOLE ON
WAIT "We don't do Memos" WINDOW && Actually we
* could...sorta
SET ALTERNATE ON
SET CONSOLE OFF
OTHERWISE && "U", or...or...I dunno...
SET ALTERNATE OFF
SET CONSOLE ON
WAIT "I don't know this one" WINDOW
SET ALTERNATE ON
SET CONSOLE OFF
ENDCASE
* I prefer to use "|", as opposed to ',' to delimit fields
* but hey, that's me...
Wpfld = Wpfld + IIF(TYPE("Delim")<>"C", "," ,Delim)
NEXT
IF Fst AND !Blnk && If this's the 1st one, ?? instead of ?
?? Wpfld && Print the record out to ALTERNATE File
Fst = .F. && 1st no more...
ELSE
? Wpfld && Print the record out to ALTERNATE File
ENDIF
Wpfld = "" && Reinit record string
SKIP && Move to next record and start again!
ENDDO && Wheeeee!!!
* Must be at EOF() here...
SET ALTERNATE TO
SET ALTERNATE OFF
SET CONSOLE ON
RELEASE Wpfld, Wpvar
RETURN .T.