home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1993 #2
/
Image.iso
/
database
/
p4w_all.zip
/
TI1487.ASC
< prev
next >
Wrap
Text File
|
1993-05-06
|
5KB
|
199 lines
PRODUCT : Paradox for Windows NUMBER : 1487
VERSION : 1.0
OS : WIN
DATE : May 6, 1993 PAGE : 1/3
TITLE : Scan Loop to Format a Date Contained in a Text Field
Intended Audience:
Those interested in adding formatting to text fields using
ObjectPAL.
Prerequisites:
Familiarity with ObjectPAL is helpful.
Purpose of the TI:
This document demonstrates how to use ObjectPAL to convert an
Alphanumeric field with date text in the format MMDDYY to the
format MM/DD/YY. This will enable the field to be converted to a
Date field.
To restructure an Alphanumeric field to a Date field, the data in
the Alphanumeric field must be in the format MM/DD/YY and the
size of the field must be 8 characters. If your data in the
Alphanumeric field has the format MMDDYY, it will be necessary to
convert the data so that it conforms to the format MM/DD/YY. The
following ObjectPAL script illustrates how to convert data in the
format MMDDYY to the format MM/DD/YY. In order for the script to
work correctly, the length of the text must be six characters,
the month, day, and year data must each contain 2 characters, and
the size of the Alphanumeric field must be 8 characters. If the
Alphanumeric field that you want to convert is not 8 characters,
you will need to first restructure your table and change the size
of that field to 8 characters.
Before making global changes to your table, it is a good idea to
first make a backup copy.
Creating the Script
Choose File | New | Script from the Desktop. Your script should
ultimately resemble the code that appears on the following page:
PRODUCT : Paradox for Windows NUMBER : 1487
VERSION : 1.0
OS : WIN
DATE : May 6, 1993 PAGE : 2/3
TITLE : Scan Loop to Format a Date Contained in a Text Field
method run(var eventInfo Event)
var
tc TCursor
tv Tableview
dstr String
endVar
tc.open("TBLNAME") ; Change TBLNAME to the name
; of your table. Enclose it
; in quotes.
tc.edit()
scan tc: ; Make sure to include the
; colon.
dstr = tc."FLDNAME" ; Change FLDNAME to the name
; of your FLDNAME field.
; Enclose your field name in
; quotes.
tc."TBLNAME" = dstr.substr(1,2) + "/" +
dstr.substr(3,2) + "/" + dstr.substr(5,2)
endScan
tc.close()
tv.open("TBLNAME")
tv.bringToTop()
endmethod
NOTE: The semicolon ";" indicates that a comment follows. The
comment will not be processed when when you play the
script.
Check the Syntax
After you have typed in the script on the previous page, choose
Language | Check Syntax from the Desktop. The compiler examines
the code and identifies if there are syntax errors in the method.
It displays a message in the status line of the open Editor
window, such as "No syntax errors" or a description of the syntax
error. If there is a syntax error, Paradox positions the cursor
at the point of the first error. Before you can run the script,
PRODUCT : Paradox for Windows NUMBER : 1487
VERSION : 1.0
OS : WIN
DATE : May 6, 1993 PAGE : 3/3
TITLE : Scan Loop to Format a Date Contained in a Text Field
you will need to correct your code and choose Language | Check
Syntax again until there are no remaining syntax errors.
When there are no syntax errors:
1. Choose File | Save from the Desktop, type in a filename in
the edit box, then choose OK.
2. To run the script, press [F8]. Your script will play, and
display your table in View mode.
Suggested Reading:
scan Chapter 3, ObjectPAL Reference manual
subStr Chapter 4, ObjectPAL Reference manual
TCursor Chapter 10, ObjectPAL Developer's Guide
restructure Chapter 9, User's Guide
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.