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 >
Wrap
Text File
|
1991-09-11
|
7KB
|
331 lines
PRODUCT : PARADOX NUMBER : 541
VERSION : ALL
OS : DOS
DATE : September 11, 1991 PAGE : 1/5
TITLE : CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
DIFFERENT FORMATS
The following Script will change a date field in a table to
alphanumeric string, and change the separator to any character
selected by the user. This is a relatively complex script for a
beginning PAL user. We recommend you develop a strong working
foundation before beginning to work with the following
information.
This information is presented as an example. While writing PAL
code is generally application specific, some routines can be used
as "generic procedures" commonly accessed by different
applications. The following script is built to be very flexible.
It worked in all applications we tested it with. If you
encounter any trouble or have some information which might help
in making this script easier to use, please feel free to contact
our Technical Support department.
Clearall
Clear
Release Vars All
Proc jctable()
While(true)
Clear
@ 1,2 ?? "Enter Name of Table to be processed: "
@ 2,2 ?? "<┘ for a list of tables."
@ 1,38 Accept "A10"
To ztable
Clear
If Isassigned(ztable)
Then
If ztable = ""
Then
Menu {View} Enter
z=1
z1st=Menuchoice()
While(true)
right
If menuchoice() = z1st
then
quitloop
endif
z=z+1
EndWhile
Array ztabs[z]
PRODUCT : PARADOX NUMBER : 541
VERSION : ALL
OS : DOS
DATE : September 11, 1991 PAGE : 2/5
TITLE : CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
DIFFERENT FORMATS
y=1
While(y<=z)
ztabs[y] = menuchoice()
right
y=y+1
EndWhile
Array zTblDes[z]
y=1
While(y<=z)
zTblDes[y]=ztabs[y]+" has"+strval(nrecords(ztabs[y]))+" records."
y=y+1
EndWhile
Showarray ztabs zTblDes
;ShowTables Directory() "Highlight Name of table and press <┘"
To ztable
Endif
Endif
If retval = False
Then
Message "You Pressed Escape! Press any key to return."
z=Getchar()
Loop
Endif
If NOT Istable(ztable)
Then Message "Not a valid Table Name!"
z=Getchar()
Loop
EndIf
Quitloop
EndWhile
EndProc
Proc jcfield()
While(true)
Clear
@ 1,2 ?? "Enter Name of Field to be processed: "
@ 2,2 ?? "<┘ for a list of fields from "+ztable + " table."
@ 1,38 Accept "A20"
To zfield
Clear
If Isassigned(zfield)
Then
If zfield = ""
PRODUCT : PARADOX NUMBER : 541
VERSION : ALL
OS : DOS
DATE : September 11, 1991 PAGE : 3/5
TITLE : CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
DIFFERENT FORMATS
Then
jcgetfields()
Showarray zflds zflddes
To zfield
Endif
Endif
If retval = False
Then
Message "You Pressed Escape! Press any key to return"
z=Getchar()
Loop
Endif
If Fieldno(zfield,ztable) = "Error"
Then
Message zfield+" is not a valid Field in "+ztable
z=Getchar()
Loop
EndIf
Quitloop
EndWhile
EndProc
Proc jcgetfields()
Menu {Tools} {Info} {Structure} Select ztable
zsize = Nrecords("Struct")
Array zflds[zsize]
Array zflddes[zsize]
z=1
Right
Scan
zflds[z] = []
right
zflddes[z] = zflds[z] + " has "+[]+" as a data type."
left
z=z+1
Endscan
Clearimage
EndProc
Proc jcSeparator()
While(true)
Clear
@ 1,2 ?? "Enter separating Character: "
PRODUCT : PARADOX NUMBER : 541
VERSION : ALL
OS : DOS
DATE : September 11, 1991 PAGE : 4/5
TITLE : CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
DIFFERENT FORMATS
@ 2,2 ?? "Example / for 87/12/2 or - for 87-12-2 "
@ 1,38 Accept "A1"
To separator
Clear
If retval = False
Then
Message "Try Again"
z=Getchar()
Clear
Loop
Endif
Quitloop
EndWhile
EndProc
Proc jcNocentry()
While(true)
Clear
@ 1,2 ?? "Do you want full year including century (y or n): "
@ 2,2 ?? "y for 1989, n for 89 only"
@ 1,52 Accept "A1"
Picture "n,y"
Default "n"
To zyrtype
Clear
If isassigned(zyrtype)
then
If zyrtype = ""
then
zyrtype = "n"
Endif
Endif
If retval = False
Then
Message "Try Again"
z=getchar()
Clear
Loop
Endif
Quitloop
EndWhile
Endproc
PRODUCT : PARADOX NUMBER : 541
VERSION : ALL
OS : DOS
DATE : September 11, 1991 PAGE : 5/5
TITLE : CONVERTING DATES TO ALPHANUMERIC STRINGS WITH
DIFFERENT FORMATS
Proc jcprocess()
jctable()
jcfield()
jcseparator()
jcNocentry()
Menu {Modify} {Restructure} select ztable
Right
Locate zfield
right
ctrlbackspace
typein "A10"
Do_It!
clearimage
Edit ztable
Moveto field zfield
Scan
z = strval([])
z=Dateval(z)
If z = "Error"
Then
Message "Record Number "+Strval(recno())+" has wrong data type!"
Sleep 750
Loop
Endif
zday = day(z)
zmonth = month(z)
zyear = year(z)
If zyrtype = "n"
Then
zyear = Substr(Strval(zyear),3,2)
Else
zyear = Strval(zyear)
Endif
Ctrlbackspace
Typein strval(zmonth)+separator+strval(zday)+separator+zyear
Message "Record "+Strval(recno())+" completed"
Endscan
Do_It!
Endproc
jcprocess()