Chapter 11
Corel® PerfectScript Programming Commands
Corel® PerfectScript Programming Commands
Three new macro commands have been added: MacroCompile, MacroIsCompiled, and MacroPlay. See online Help for information about these commands. Also, the following commands have been changed: DialogAddControl, DialogDelete, FileFind, FileNameDialog, GetFileAttributes, MacroInfo, OLEAutomation, and SetFileAttributes. See online Help for information about these commands.
|
DateAddDays |
| Purpose | Add a specified number of days to Date (parameter). | ||||||
| Return Value | A date with the specified number of days added. An error returns DateAndTime.Error!. | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
DateAddMonths |
| Purpose | Add a specified number of months to a specified date. | |||||||||||||||
| Return Value | Date with the specified number of months added. An error returns DateAndTime.Error!. | |||||||||||||||
| Syntax |
|
|||||||||||||||
| Parameters |
|
|
DateAddWeeks |
| Purpose |
Add a specified number of weeks to a specified date. |
||||||||||||||||||||||||||||||||||
| Return Value |
A date with the specified number of weeks added. An error returns DateAndTime.Error!. |
||||||||||||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||||||||||||
| Parameters |
|
|
DateAddYears |
| Purpose |
Add a specified number of years to a specified date. |
||||||
| Return Value |
Date with a specified number of years added. An error returns DateAndTime.Error!. |
||||||
| Syntax |
|
||||||
| Parameters |
|
|
DateAndTime |
| Purpose |
Return a value representing the date and time. The earliest valid date is January 1, 1601. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return Value |
A number representing the current day, month, year, hour, minute, second, and hundredths of a second is returned if the corresponding parameter is not used. If an error occurs, the enumeration value of Error! is returned. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Examples |
DateAndCurrentTime := DateAndTime() MessageBox (x; "Date"; DateString (TodaysDate)) MessageBox (x; "Time"; TimeString (TodaysDate))
Explanation: MessageBox 1 displays the current date. MessageBox 2 displays current time. vResult := DateAndTime (15; 10; 1994; 00; 10; 10; 10) vDate := DateString (vResult) vTime := TimeString (vResult) MessageBox (x; "Date"; vDate) MessageBox (x; "Time"; vTime)
Explanation: Messagebox 1 displays 10/15/94. Messagebox 2 displays 12:10:10 AM. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters |
|
|
DateDay |
| Purpose |
Return a numeric value representing a day of the month. |
|||
| Examples | Appendix A: 8097 | |||
| Return Value |
Check for an error (illegal date) by comparing the return value to DateAndTime.Error!. |
|||
| Examples |
vDay := DateDay() Messagebox (x; "Day of the Month"; vDay) Result (current system day): 17 |
|||
| Syntax |
|
|||
| Parameters |
|
|
DateDayOfYear |
| Purpose |
Return the number of a day in the year. |
|||
| Return Value |
Number of the day in the year specified by the Date parameter. An error returns DateAndTime.Error!. |
|||
| Syntax |
|
|||
| Parameters |
|
|
DateDaysInMonth |
| Purpose |
Return the number of days in a specified month. |
||||||||||||||||||||||||||||||
| Return Value |
Number of days in a specified month (takes Leap year into account). An error returns DateAndTime.Error!. |
||||||||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||||||||
| Parameters |
|
|
DateDaysInYear |
| Purpose |
Return the number of days in a specified year. |
|||
| Return Value |
Number of calendar days in a specified year. An error returns DateAndTime.Error!. |
|||
| Syntax |
|
|||
| Parameters |
|
|
DateIsLeapYear |
| Purpose |
Determine whether a specified year is a leap year. |
|||
| Return Value |
True if leap year, False if not. Leap years are evenly divisible by 4. This is not true of a century year (year evenly divisible by 100), unless the year is evenly divisible by 400. The year 2000 is a leap year, but 1900 was not. |
|||
| Syntax |
|
|||
| Parameters |
|
|
DateMonth |
| Purpose |
Return an enumeration representing the month. |
|||
| Examples | Appendix A: 8097 | |||
| Return Value |
Check for an error (illegal date) by comparing the return value to DateMonth.Error! or DateAndTime.Error!. |
|||
| January! | ||||
| February! | ||||
| March! | ||||
| April! | ||||
| May! | ||||
| June! | ||||
| July! | ||||
| August! | ||||
| September! | ||||
| October! | ||||
| November! | ||||
| December! | ||||
| Error! | ||||
| Examples |
// Assume the current month is February vMonth := DateMonth() MessageBox (x; "Month"; vMonth) Result (current system month): 2 or February! |
|||
| Syntax |
|
|||
| Parameters |
|
|
DateMonthName |
| Purpose |
Return the name of a month. |
||||||||||||
| Return Value |
An empty string ("") is returned for an illegal date. |
||||||||||||
| Examples |
vDate := DateAndTime (1; 12; 1996) vMonth := DateMonthName (vDate) MessageBox (x; "Month"; vMonth) Result: December vDate := DateAndTime (1; 12; 1996) vMonth := DateMonthName (vDate; Short!) MessageBox (x; "Month"; vMonth) Result: Dec |
||||||||||||
| Syntax |
|
||||||||||||
| Parameters |
|
|
DateOfMonthEnd |
| Purpose |
Return the date for the end of a specified month. |
||||||||||||||||||||||||||||||
| Return Value |
Date for the end of a specified month. An error returns DateAndTime.Error!. |
||||||||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||||||||
| Parameters |
|
|
DateOfNthDay |
| Purpose |
Return the date for a specified day in a year. |
||||||
| Return Value |
Date of a specified day number. An error returns DateAndTime.Error!. |
||||||
| Syntax |
|
||||||
| Parameters |
|
|
DateOfNthWeek |
| Purpose |
Return the date for a specified week. |
|||||||||||||||||||||||
| Return Value |
Date of a specified week number. An error returns DateAndTime.Error!. |
|||||||||||||||||||||||
| Syntax |
|
|||||||||||||||||||||||
| Parameters |
|
|
DateOfNthWeekDay |
| Purpose |
Return the date for a specified weekday in a specified month. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Return Value |
Date of the nth weekday in a specified month. An error returns DateAndTime.Error!. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Parameters |
|
|
DateString |
| Purpose |
Return the date in a string. |
|||||||||||||||
| Return Value |
An empty string ("") is returned for an illegal date. |
|||||||||||||||
| Examples |
vNmbrDate := DateAndTime (1; 1; 2000) vDate := DateString (vNmbrDate; ; "dd/MM/yyyy (dddd)") MessageBox (x; "Date String"; vDate) Result: 01/01/2000 (Saturday) vDate := DateString (; Short!) MessageBox (x; "System Date"; vDate) Result (system date): 2/17/96 vDate := DateString (; Long!) MessageBox (x; "System Date"; vDate) Result (system date): Saturday, February 17, 1996 |
|||||||||||||||
| Syntax |
|
|||||||||||||||
| Parameters |
|
|
DateWeekday |
| Purpose |
Return an enumeration representing the day of the week. |
|||
| Return Value |
Check for an error (illegal date) by comparing the return value to DateWeekday.Error! or DateAndTime.Error!. |
|||
| Sunday! | ||||
| Monday! | ||||
| Tuesday! | ||||
| Wednesday! | ||||
| Thursday! | ||||
| Friday! | ||||
| Saturday! | ||||
| Error! | ||||
| Examples |
vDate := DateAndTime (1; 1; 2000) If(DateWeekday(vDate) = DateWeekday.Date.Saturday!) MessageBox (x; "Day of the Week"; "Saturday") Endif Result: MessageBox displays "Saturday." |
|||
| Syntax |
|
|||
| Parameters |
|
|
DateWeekdayName |
| Purpose |
Return the name of a day of the week. |
||||||||||||
| Return Value |
An empty string ("") is returned for an illegal date. |
||||||||||||
| Examples |
vDate := DateAndTime (17; 2; 1996) vWeekday := DateWeekdayName (vDate; Short!) MessageBox (x; "Weekday"; vWeekday) Result: Sat |
||||||||||||
| Syntax |
|
||||||||||||
| Parameters |
|
|
DateWeekOfYear |
| Purpose |
Return the week number for a specified date. |
||||||||||||||||||||
| Return Value |
Week number for a specified date. An error returns DateAndTime.Error!. |
||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||
| Parameters |
|
|
DateYear |
| Purpose |
Return a value representing a year. |
|||
| Examples | Appendix A: 8097 | |||
| Return Value |
Check for an error (illegal date) by comparing the return value to DateAndTime.Error!. |
|||
| Examples |
vYear := DateYear() MessageBox (x; "Year"; vYear) Result (system date): 1996 |
|||
| Syntax |
|
|||
| Parameters |
|
|
DDEExecute |
| Purpose |
Send a command string to a server application. See the server application's documentation for command names and syntax. |
||||||
| Examples | Appendix A: 8014 | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
DDEExecuteExt |
| Purpose |
Send a command to a server application, and return a value that indicates if the command was successfully processed. See the server application's documentation for command names and syntax. |
||||||||||||
| Examples | Appendix A: 8015 | ||||||||||||
| Return Value |
A number greater than 0 if successful, or 0 if not. |
||||||||||||
| Syntax |
|
||||||||||||
| Parameters |
|
|
DDEInitiate |
| Purpose |
Start a DDE conversation with a server application, and return a conversation ID. A conversation must be started between server and client applications before you can use commands such as DDEPoke, DDERequest, and DDEExecute. |
||||||
| Examples | Appendix A: 8014 | ||||||
| Return Value |
A number that links the server and client applications is returned, or 0 if the conversation is not started. |
||||||
| Syntax |
|
||||||
| Parameters |
|
|
DDEPoke |
| Purpose |
Assign data to an item in a server application. |
|||||||||
| Examples | Appendix A: 8017 | |||||||||
| Syntax |
|
|||||||||
| Parameters |
|
|||||||||
| Note |
Check your server application documentation to see if it supports XTYP_POKE transactions. Many applications do not. |
|
DDERequest |
| Purpose |
Get the contents of a server application item. |
||||||
| Examples | Appendix A: 8016 | ||||||
| Return Value |
Contents of the server application item specified by ItemName. |
||||||
| Syntax |
|
||||||
| Parameters |
|
||||||
| Note |
Check your server application documentation to see if it supports XTYP_REQUEST transactions. Many applications do not. |
|
DDETerminate |
| Purpose |
End a DDE conversation with a server application. |
|||
| Examples | Appendix A: 8016 | |||
| Syntax |
|
|||
| Parameters |
|
|
DDETerminateAll |
| Purpose |
End all DDE conversations. |
| Examples | Appendix A: 8014 |
| Syntax |
DDETerminateAll () |
|
Declare |
| Purpose |
Create a local variable or array, which stores as many variables, constants, or expressions as memory allows. An array can have up to 10 dimensions, and up to 32,767 elements per dimension depending on the amount of available memory. In the following example, Declare creates ArrayA with element in each array is assigned a value. Parentheses are optional. Declare(ArrayA[10]; ArrayB[5]) ArrayA[3] := "John" Explanation: Assigns "John" to the third element in ArrayA. ArrayB[5] := ArrayA[3] Explanation: Assigns "John" to the fifth element in ArrayB. In the next example, Declare creates a two- dimensional array (ArrayC) with 100 elements (10 rows and 10 columns). One element is assigned a value. Declare ArrayC[10;10] ArrayC[2;3] := 3+6 Explanation: Assigns 9 to the element at row 2, column 3. |
||||||
| Examples | Appendix A: 8018 | ||||||
| Syntax |
|
||||||
| Parameters |
|
|
Default: |
| Purpose |
Specify the code to execute when no CaseOF <Selector> matches the control expression in a Switch statement. See Switch. |
| Syntax |
Default: |
|
DefaultUnits |
| Purpose |
Specify the default unit of measure, and return the previous unit of measure. You can set a new value, and then restore the previous value. |
||||||||||||||||||||
| Examples | Appendix A: 8006 | ||||||||||||||||||||
|
Return Values |
The previous unit value. |
||||||||||||||||||||
| None! | |||||||||||||||||||||
| Centimeters! | |||||||||||||||||||||
| Inches! | |||||||||||||||||||||
| Millimeters! | |||||||||||||||||||||
| Points! | |||||||||||||||||||||
| WPUnits! | |||||||||||||||||||||
| Examples |
In the first example, Advance uses the default unit of measure (WPUnits!). In the second, Advance overrides the default unit of measure and uses inches. In the third, DefaultUnits specifies centimeters as the default unit of measure. Advance(AdvanceFromTop!; 4)
Explanation: Advance insertion point 4 WPUnits. Advance(AdvanceFromTop!; 4")
Explanation: Advance insertion point 4 inches. DefaultUnits(Centimeters!) Advance(AdvanceFromTop!; 4)
Explanation: Advance insertion point 4 centimeters. The default unit of measure is effective until changed by another DefaultUnits command. If not specified by DefaultUnits, the default unit of measure is WPUnits!. |
||||||||||||||||||||
|
Discussion |
None! has been added to the list of possible units. Normally, when a non-units value such as 1200 is combined with a units value such as unit type. If the default unit type is WPUnits, 1.0C + 1200 = 3.54C (1200 WPUnits = 2.54C)
If, however, the default unit is set to None!, the non-units value assumes the unit type of the value it is combined with (no conversion is performed). For example, 1.0C + 1200 = 1201.0C With the default unit set to None!, 1200 assumes the unit type of centimeter. |
||||||||||||||||||||
| Syntax |
|
||||||||||||||||||||
| Parameters |
|
|
DegreesToRadians |
| Purpose |
Convert an angle in degrees to radians. |
|||
| Return Value |
Angle in radians. |
|||
| Syntax |
|
|||
| Parameters |
|
|
DeleteDirectory |
| Purpose |
Delete a directory. |
|||||||||||
| Examples | Appendix A: 8080 | |||||||||||
| Return Value |
True if successful, False if not. |
|||||||||||
| Syntax |
|
|||||||||||
| Parameters |
|
|
DeleteFile |
| Purpose |
Delete a file(s). |
|||||||||||
| Examples | Appendix A: 8086 | |||||||||||
| Return Value |
True if successful, False if not. |
|||||||||||
| Syntax |
|
|||||||||||
| Parameters |
|