home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR7 / FOXTAILS.ZIP / WPCONV.PRG < prev   
Text File  |  1992-03-28  |  3KB  |  96 lines

  1. FUNCTION Wpconv
  2. PARAMETERS Flnm, Wp, Blnk, Dlim
  3. *    This program assumes the following:
  4. *    All databases, relations, filters and indexes are set
  5. *    The main database is selected and pointed at top or
  6. *    wherever.
  7. *    That the Wp parameter is an array.  Each element in the
  8. *    Wp array contains the name of a field or variable to be included.
  9. *    If the element is from another database, the alias should be part
  10. *    of the name.  The variables need to be sequentially filled
  11. *    into the array that's passed to this program
  12. *    The variable Flnm contains a valid ALTERNATE Filename
  13. *    The parameter Blnk is whether or not a blank record should
  14. *    be stuffed at the beginning of the file.
  15. *    That you're a deserving boy or girl.
  16. *
  17. *    Written by R.L. Coppedge
  18. *    Copyright 1991 dbF Software Productions
  19. *    By the way, dbF also has:
  20. *    SysTrak        A Computer Hardware/Software Inventory System
  21. *    Flags        A Flatfile Application Gen. for db3,4 and Fox
  22. *    ClasAdz        A Classified/Notice system for Networks
  23. *    FoxTails #1    A collection of FoxPro tools (like this one)
  24. *    Contact dbF for more information.
  25. *    dbF Software Productions
  26. *    P.O. Box 37194
  27. *    Cleve., Ohio 44137-0194
  28. *    CIS: 72117,165
  29. *    (216)491-4581
  30. *
  31. *    This code may be modified, but leave this original notice up
  32. *    here intact, if ya don't mind.  (Add your own comments about
  33. *    how much better you made it if you like)
  34.  
  35. PRIVATE Wpfld, Wpcnt
  36. SET TALK OFF                    &&    If you haven't, I will!
  37. IF EOF()  &&   The database has nothing to give
  38.     WAIT "There are no records to copy!" WINDOW
  39.     RELEASE Wpfld, Wpcnt
  40.     RETURN .F.
  41. ENDIF
  42. IF EMPTY(Flnm) .OR. ALEN(Wp)=0    &&    I need something...
  43.     WAIT "I need at least a file name and 1 Field...Please?" WINDOW
  44.     RELEASE Wpfld, Wpcnt
  45.     RETURN .F.
  46. ENDIF
  47. SET ALTERNATE TO &Flnm.
  48. SET ALTERNATE ON
  49. SET CONSOLE OFF
  50. Fst = .T.
  51. DO WHILE !EOF()
  52.     WpFld = ""
  53.     FOR Wpcnt = 1 TO ALEN(Wp)
  54.         DO CASE
  55.         CASE TYPE(Wp(Wpcnt)) = "C"   &&   Character Field
  56.             Wpfld = Wpfld + ALLTRIM(EVALUATE(Wp(Wpcnt)))
  57.         CASE TYPE(Wp(Wpcnt)) $ "FN"  &&   Numeric Field
  58.             Wpfld = Wpfld + ALLTRIM(STR(EVALUATE(Wp(Wpcnt))))
  59.         CASE TYPE(Wp(Wpcnt)) = "D"   &&   Date Field
  60.             Wpfld = Wpfld + DTOC(EVALUATE(Wp(Wpcnt)))
  61.         CASE TYPE(Wp(Wpcnt)) = "L"   &&   Logical Field
  62.             Wpfld = Wpfld + IIF(EVALUATE(Wp(Wpcnt)),"Y","N")
  63.         CASE TYPE(Wp(Wpcnt)) = "M"   &&   Memo Field
  64.             SET ALTERNATE OFF
  65.             SET CONSOLE ON
  66.             WAIT "We don't do Memos" WINDOW    &&    Actually we
  67.             *    could...sorta
  68.             SET ALTERNATE ON
  69.             SET CONSOLE OFF
  70.         OTHERWISE &&   "U", or...or...I dunno...
  71.             SET ALTERNATE OFF
  72.             SET CONSOLE ON
  73.             WAIT "I don't know this one" WINDOW
  74.             SET ALTERNATE ON
  75.             SET CONSOLE OFF
  76.         ENDCASE
  77. *        I prefer to use "|", as opposed to ',' to delimit fields
  78. *        but hey, that's me...
  79.         Wpfld = Wpfld + IIF(TYPE("Delim")<>"C", "," ,Delim)
  80.     NEXT
  81.     IF Fst AND !Blnk    &&    If this's the 1st one, ?? instead of ?
  82.         ?? Wpfld        &&    Print the record out to ALTERNATE File
  83.         Fst = .F.        &&    1st no more...
  84.     ELSE
  85.         ? Wpfld        &&    Print the record out to ALTERNATE File
  86.     ENDIF
  87.     Wpfld = ""    &&    Reinit record string
  88.     SKIP    &&    Move to next record and start again!
  89. ENDDO        &&        Wheeeee!!!
  90. *    Must be at EOF() here...
  91. SET ALTERNATE TO
  92. SET ALTERNATE OFF
  93. SET CONSOLE ON
  94. RELEASE Wpfld, Wpvar
  95. RETURN .T.
  96.