home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / TEXT / PDX_ALL.ZIP / TI541.ASC < prev    next >
Text File  |  1991-09-11  |  7KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. PRODUCT  :  PARADOX                                NUMBER  :  541
  8. VERSION  :  ALL
  9.      OS  :  DOS
  10.    DATE  :  September 11, 1991                       PAGE  :  1/5
  11.  
  12.   TITLE  :  CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
  13.          DIFFERENT FORMATS
  14.  
  15.  
  16.  
  17.  
  18. The following Script will change a date field in a table to
  19. alphanumeric string, and change the separator to any character
  20. selected by the user.  This is a relatively complex script for a
  21. beginning PAL user.  We recommend you develop a strong working
  22. foundation before beginning to work with the following
  23. information.
  24.  
  25. This information is presented as an example.  While writing PAL
  26. code is generally application specific, some routines can be used
  27. as "generic procedures" commonly accessed by different
  28. applications.  The following script is built to be very flexible.
  29. It worked in all applications we tested it with.  If you
  30. encounter any trouble or have some information which might help
  31. in making this script easier to use, please feel free to contact
  32. our Technical Support department.
  33.  
  34. Clearall
  35. Clear
  36. Release Vars All
  37. Proc jctable()
  38. While(true)
  39.  Clear
  40.  @ 1,2 ?? "Enter Name of Table to be processed: "
  41.  @ 2,2 ?? "<┘ for a list of tables."
  42.  @ 1,38 Accept "A10"
  43.    To ztable
  44.    Clear
  45.    If Isassigned(ztable)
  46.      Then
  47.        If ztable = ""
  48.          Then
  49.          Menu {View} Enter
  50.            z=1
  51.            z1st=Menuchoice()
  52.            While(true)
  53.              right
  54.              If menuchoice() = z1st
  55.                then
  56.                quitloop
  57.              endif
  58.              z=z+1
  59.            EndWhile
  60.            Array ztabs[z]
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. PRODUCT  :  PARADOX                                NUMBER  :  541
  74. VERSION  :  ALL
  75.      OS  :  DOS
  76.    DATE  :  September 11, 1991                       PAGE  :  2/5
  77.  
  78.   TITLE  :  CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
  79.          DIFFERENT FORMATS
  80.  
  81.  
  82.  
  83.  
  84.            y=1
  85.            While(y<=z)
  86.              ztabs[y] = menuchoice()
  87.              right
  88.              y=y+1
  89.            EndWhile
  90.            Array zTblDes[z]
  91.            y=1
  92.            While(y<=z)
  93.        zTblDes[y]=ztabs[y]+" has"+strval(nrecords(ztabs[y]))+" records."
  94.              y=y+1
  95.            EndWhile
  96.            Showarray ztabs zTblDes
  97.          ;ShowTables  Directory() "Highlight Name of table and press <┘"
  98.            To ztable
  99.          Endif
  100.        Endif
  101.        If retval = False
  102.          Then
  103.          Message "You Pressed Escape! Press any key to return."
  104.          z=Getchar()
  105.          Loop
  106.        Endif
  107.        If NOT Istable(ztable)
  108.        Then Message "Not a valid Table Name!"
  109.        z=Getchar()
  110.      Loop
  111.    EndIf
  112.  Quitloop
  113. EndWhile
  114. EndProc
  115.  
  116. Proc jcfield()
  117.  While(true)
  118.      Clear
  119.      @ 1,2 ?? "Enter Name of Field to be processed: "
  120.      @ 2,2 ?? "<┘ for a list of fields from "+ztable + " table."
  121.      @ 1,38 Accept "A20"
  122.      To zfield
  123.      Clear
  124.      If Isassigned(zfield)
  125.          Then
  126.          If zfield = ""
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. PRODUCT  :  PARADOX                                NUMBER  :  541
  140. VERSION  :  ALL
  141.      OS  :  DOS
  142.    DATE  :  September 11, 1991                       PAGE  :  3/5
  143.  
  144.   TITLE  :  CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
  145.          DIFFERENT FORMATS
  146.  
  147.  
  148.  
  149.  
  150.              Then
  151.              jcgetfields()
  152.              Showarray zflds zflddes
  153.              To zfield
  154.          Endif
  155.      Endif
  156.      If retval = False
  157.          Then
  158.          Message "You Pressed Escape! Press any key to return"
  159.          z=Getchar()
  160.          Loop
  161.      Endif
  162.      If  Fieldno(zfield,ztable) = "Error"
  163.          Then
  164.          Message zfield+" is not a valid Field in "+ztable
  165.          z=Getchar()
  166.          Loop
  167.      EndIf
  168.      Quitloop
  169.  EndWhile
  170. EndProc
  171.  
  172. Proc jcgetfields()
  173.  Menu {Tools} {Info} {Structure} Select ztable
  174.  zsize = Nrecords("Struct")
  175.  Array zflds[zsize]
  176.  Array zflddes[zsize]
  177.  z=1
  178.  Right
  179.  Scan
  180.      zflds[z] = []
  181.      right
  182.      zflddes[z] = zflds[z] + " has "+[]+" as a data type."
  183.      left
  184.      z=z+1
  185.  Endscan
  186.  Clearimage
  187. EndProc
  188.  
  189. Proc jcSeparator()
  190.  While(true)
  191.      Clear
  192.      @ 1,2 ?? "Enter separating Character: "
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. PRODUCT  :  PARADOX                                NUMBER  :  541
  206. VERSION  :  ALL
  207.      OS  :  DOS
  208.    DATE  :  September 11, 1991                       PAGE  :  4/5
  209.  
  210.   TITLE  :  CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
  211.          DIFFERENT FORMATS
  212.  
  213.  
  214.  
  215.  
  216.      @ 2,2 ?? "Example / for 87/12/2 or - for 87-12-2 "
  217.      @ 1,38 Accept "A1"
  218.      To separator
  219.      Clear
  220.      If retval = False
  221.          Then
  222.          Message "Try Again"
  223.          z=Getchar()
  224.          Clear
  225.          Loop
  226.       Endif
  227.       Quitloop
  228.  EndWhile
  229. EndProc
  230.  
  231. Proc jcNocentry()
  232.  While(true)
  233.      Clear
  234.      @ 1,2 ?? "Do you want full year including century (y or n): "
  235.      @ 2,2 ?? "y for 1989, n for 89 only"
  236.      @ 1,52 Accept "A1"
  237.      Picture "n,y"
  238.      Default "n"
  239.      To zyrtype
  240.      Clear
  241.      If isassigned(zyrtype)
  242.          then
  243.          If zyrtype = ""
  244.            then
  245.            zyrtype = "n"
  246.          Endif
  247.      Endif
  248.      If retval = False
  249.          Then
  250.          Message "Try Again"
  251.          z=getchar()
  252.          Clear
  253.          Loop
  254.       Endif
  255.       Quitloop
  256.  EndWhile
  257. Endproc
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. PRODUCT  :  PARADOX                                NUMBER  :  541
  272. VERSION  :  ALL
  273.      OS  :  DOS
  274.    DATE  :  September 11, 1991                       PAGE  :  5/5
  275.  
  276.   TITLE  :  CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
  277.          DIFFERENT FORMATS
  278.  
  279.  
  280.  
  281.  
  282. Proc jcprocess()
  283.  jctable()
  284.  jcfield()
  285.  jcseparator()
  286.  jcNocentry()
  287.  Menu {Modify} {Restructure} select ztable
  288.      Right
  289.      Locate zfield
  290.      right
  291.      ctrlbackspace
  292.      typein "A10"
  293.      Do_It!
  294.      clearimage
  295.  Edit ztable
  296.  Moveto field zfield
  297.  Scan
  298.      z = strval([])
  299.      z=Dateval(z)
  300.      If z = "Error"
  301.          Then
  302.         Message "Record Number "+Strval(recno())+" has wrong data type!"
  303.          Sleep 750
  304.          Loop
  305.      Endif
  306.      zday   = day(z)
  307.      zmonth = month(z)
  308.      zyear  = year(z)
  309.      If zyrtype = "n"
  310.          Then
  311.          zyear = Substr(Strval(zyear),3,2)
  312.      Else
  313.          zyear = Strval(zyear)
  314.      Endif
  315.      Ctrlbackspace
  316.      Typein strval(zmonth)+separator+strval(zday)+separator+zyear
  317.      Message "Record "+Strval(recno())+" completed"
  318.  Endscan
  319.  Do_It!
  320. Endproc
  321.  
  322. jcprocess()
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.