home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / p4w_all.zip / TI1487.ASC < prev    next >
Text File  |  1993-05-06  |  5KB  |  199 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  Paradox for Windows                   NUMBER  :  1487
  9.   VERSION  :  1.0
  10.        OS  :  WIN
  11.      DATE  :  May 6, 1993                              PAGE  :  1/3
  12.  
  13.     TITLE  :  Scan Loop to Format a Date Contained in a Text Field
  14.  
  15.  
  16.  
  17.  
  18.   Intended Audience:
  19.   Those interested in adding formatting to text fields using
  20.   ObjectPAL.
  21.  
  22.   Prerequisites:
  23.   Familiarity with ObjectPAL is helpful.
  24.  
  25.   Purpose of the TI:
  26.   This document demonstrates how to use ObjectPAL to convert an
  27.   Alphanumeric field with date text in the format MMDDYY to the
  28.   format MM/DD/YY.  This will enable the field to be converted to a
  29.   Date field.
  30.  
  31.  
  32.   To restructure an Alphanumeric field to a Date field, the data in
  33.   the Alphanumeric field must be in the format MM/DD/YY and the
  34.   size of the field must be 8 characters.  If your data in the
  35.   Alphanumeric field has the format MMDDYY, it will be necessary to
  36.   convert the data so that it conforms to the format MM/DD/YY.  The
  37.   following ObjectPAL script illustrates how to convert data in the
  38.   format MMDDYY to the format MM/DD/YY.  In order for the script to
  39.   work correctly, the length of the text must be six characters,
  40.   the month, day, and year data must each contain 2 characters, and
  41.   the size of the Alphanumeric field must be 8 characters.  If the
  42.   Alphanumeric field that you want to convert is not 8 characters,
  43.   you will need to first restructure your table and change the size
  44.   of that field to 8 characters.
  45.  
  46.   Before making global changes to your table, it is a good idea to
  47.   first make a backup copy.
  48.  
  49.  
  50.   Creating the Script
  51.  
  52.   Choose File | New | Script from the Desktop.  Your script should
  53.   ultimately resemble the code that appears on the following page:
  54.    
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.   PRODUCT  :  Paradox for Windows                   NUMBER  :  1487
  75.   VERSION  :  1.0
  76.        OS  :  WIN
  77.      DATE  :  May 6, 1993                              PAGE  :  2/3
  78.  
  79.     TITLE  :  Scan Loop to Format a Date Contained in a Text Field
  80.  
  81.  
  82.  
  83.  
  84.       method run(var eventInfo Event)
  85.            var
  86.                tc        TCursor
  87.                tv        Tableview
  88.                dstr      String
  89.            endVar
  90.  
  91.       tc.open("TBLNAME")             ; Change TBLNAME to the name
  92.                                      ;  of your table. Enclose it
  93.                                      ;  in quotes.
  94.       tc.edit()
  95.  
  96.       scan tc:                       ; Make sure to include the
  97.                                      ;   colon.
  98.            dstr = tc."FLDNAME"       ; Change FLDNAME to the name
  99.                                      ;   of your FLDNAME field.
  100.                                      ; Enclose your field name in
  101.                                      ;   quotes.
  102.  
  103.            tc."TBLNAME" = dstr.substr(1,2) + "/" +
  104.                           dstr.substr(3,2) + "/" + dstr.substr(5,2)
  105.       endScan
  106.  
  107.       tc.close()
  108.       tv.open("TBLNAME")
  109.       tv.bringToTop()
  110.       endmethod
  111.  
  112.  
  113.   NOTE: The semicolon ";" indicates that a comment follows.  The
  114.         comment will not be processed when when you play the
  115.         script.
  116.  
  117.  
  118.   Check the Syntax
  119.  
  120.   After you have typed in the script on the previous page, choose
  121.   Language | Check Syntax from the Desktop.  The compiler examines
  122.   the code and identifies if there are syntax errors in the method.
  123.   It displays a message in the status line of the open Editor
  124.   window, such as "No syntax errors" or a description of the syntax
  125.   error.  If there is a syntax error, Paradox positions the cursor
  126.   at the point of the first error.  Before you can run the script,
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.   PRODUCT  :  Paradox for Windows                   NUMBER  :  1487
  141.   VERSION  :  1.0
  142.        OS  :  WIN
  143.      DATE  :  May 6, 1993                              PAGE  :  3/3
  144.  
  145.     TITLE  :  Scan Loop to Format a Date Contained in a Text Field
  146.  
  147.  
  148.  
  149.  
  150.   you will need to correct your code and choose Language | Check
  151.   Syntax again until there are no remaining syntax errors.
  152.  
  153.  
  154.   When there are no syntax errors:
  155.  
  156.      1.  Choose File | Save from the Desktop, type in a filename in
  157.          the edit box, then choose OK.
  158.  
  159.      2.  To run the script, press [F8].  Your script will play, and
  160.          display your table in View mode.
  161.  
  162.  
  163.   Suggested Reading:
  164.  
  165.   scan              Chapter 3, ObjectPAL Reference manual
  166.   subStr            Chapter 4, ObjectPAL Reference manual
  167.   TCursor           Chapter 10, ObjectPAL Developer's Guide
  168.   restructure       Chapter 9, User's Guide
  169.  
  170.  
  171.   DISCLAIMER: You have the right to use this technical information
  172.   subject to the terms of the No-Nonsense License Statement that
  173.   you received with the Borland product to which this information
  174.   pertains.
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.