User Tools

Site Tools


utility_commands

CalendarSet Utility Commands

CalendarSet includes several commands to assist in managing the operation of a calendar area, as well as implement other user interface objects.


International Utilities

Dates are handled differently in different countries. CalendarSet provides several commands to assist with dates. These commands use the current workstation OS settings.

To obtain the correct day name for the currently selected location, use CS_GetDayName. Use CS_GetMonthName to get the correct month name.


Array Intersection

You can intersect two arrays to create a third array using FS_ArrayIntrsct.


Commands


Area_Refresh

(AreaRef)

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area

Area_Refresh will redraw any of the plugin area objects in the CalendarSet plugin, using all of the settings that were changed.

This command is generally not necessary. For example you don't need it for the popup areas. When you change any setting (including options / current value of popup areas), CalendarSet will handle it automatically.

It can, however, be useful when modifying an array displayed by a calendar or other object type, e.g. a picture popup array. But you can also simply reset the respective array (CS_SetArray, CS_SetBanrArray, IM_SetArray).

Example

// after adding an item to the arrays being displayed in the calendar 
// object eCalendar, update the object 
AddCalenItem(vDate;vText) 
Area_Refresh(eCalendar) 

CS_GetDayName

(DayNumber; Abbreviated; DayName)

Parameter Type Description
→ DayNumber integer day number to get the name of
→ Abbreviated integer get abbreviated day name
← DayName text day name

CS_GetDayName returns in DayName the day of the week specified by DayNumber.


DayNumber — Integer. This is the number returned by the 4D function Day number and is in the range of 1 to 7 for the days Sunday thru Saturday.

Abbreviated — Integer. This parameter is used to specify whether you want the full day name, or an abbreviation. If Abbreviated is set to 1, DayName will only contain as many characters as is appropriate for abbreviations, according to the OS that is being used. For example,Tuesday abbreviated in the United States is “Tue”.

DayName — Text. This parameter returns the name of the day specified by DayNumber.

Example

// fill an array with the full names of all days 
C_INTEGER($i)
  
C_TEXT(vDayName)
  
ARRAY TEXT(aDayNames;7) 
For($i;1;7)
  
 CS_GetDayName ($i;0;vDayName) 
 aDayNames{$i}:=vDayName 
End for 

CS_GetMonthName

(MonthNumber; Abbreviated; MonthName)

Parameter Type Description
→ MonthNumber integer month number to get the name of
→ Abbreviated integer get abbreviated month name
← MonthName text month name

CS_GetMonthName returns in MonthName the name of the month specified by MonthNumber.

MonthNumber — Integer. This parameter is a number between 1 and 12, corresponding to the months January thru December.

Abbreviated — Integer. This parameter is used to indicate whether to abbreviate the value returned in MonthName. If Abbreviated is set to 1, MonthName will only contain as many characters as is appropriate for abbreviations according to the OS that is being used. For example, “February” is abbreviated in the United States as “Feb”.

MonthName — Text. This parameter returns the name of the month specified by MonthNumber.

Examples

// fill an array with the full names of all months
C_INTEGER($i)
  
C_TEXT(vMonthName)
  
ARRAY TEXT(aMonthName;12) 
For($i;1;12)
  
 CS_GetMonthName ($i;0;vMonthName) 
 aMonthNames{$i}:=vMonthName 
End for 

CS_GetPicture

(AreaRef) → picture

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area
← picture picture vector picture of the area

CS_GetPicture returns a PDF (MacOS) or EMF (Windows) vector picture of the specified area. This feature can be useful for web publishing or offscreen printing, amongst others. It can be used for offscreen areas as well.

Example

// get a picture of the current calendar into a variable 
C_PICTURE(vPict)
  
vPict:=CS_GetPicture (eCalArea) 

CS_SimClick

(AreaRef; whereX; whereY)

Parameter Type Description
→ AreaRef longint area reference of the CalendarSet area
→ whereX integer horizontal relative coordinate of the click
→ whereY integer vertical relative coordinate of the click

CS_SimClick posts a click event in an area, either on screen (same as 4D’s POST CLICK) or offscreen.

For onscreen areas the whereX and whereY coordinates are relative to the window.

Example

// post a click in a offscreen calendar area at coordinates 100 (horizontal), 50 (vertical) 
CS_SimClick (eCalArea;100;50) 

FS_ArrayIntrsct

(CompareArray; SourceArray; DestArray)

Parameter Type Description
→ CompareArray integer array of indices into source
→ SourceArray array array to extract items from
← DestArray array array to place intersected items into

FS_ArrayIntrsct allows you to build an array based upon the intersection of an Integer array of indices and any other array.

The elements of SourceArray with indices from CompareArray are copied into DestArray.

This command is useful with the CalendarSet routine CS_GetSelItems. It allows you to quickly build a new array out of the items that correspond to the selected dates in the calendar.

CompareArray — Integer array. This parameter is an array of indices into the SourceArray.

SourceArray — Array (any type). The original array.

Note: “any type” actually means compatible types: the array must be one-dimensional and not an array of pointers or BLOBs.

DestArray — Array (same type as SourceArray). The results of the intersection are placed into this array.

Example

C_LONGINT(vAction;vType;$i) 
ARRAY INTEGER(aIndex;0) 
If(Form event=On Clicked) 
 CS_GetAction(eCal;vAction) 
 If(vAction=CS_Action_ClickOnDay) // did the user select a day or days? 
  // get the events on this day or days 
  CS_GetSelItems(eCal;CS_Sel_Events;aIndex) 
  // build an array with the event text for events on the selected days 
  FS_ArrayIntrsct(aIndex;aEventText;aSelDayEvts) 
 End if // CS_Action_ClickOnDay 
End if // On Clicked 

Util_SetDate

(DateToSet; Month; Day; Year)

Parameter Type Description
← DateToSet date date to be set
→ Month integer month number of the date
→ Day integer day number of the date
→ Year integer year of the date

This command is deprecated. Use 4D's Add to date function:

$date:=Add to date (!00/00/0000!;$years;$months;$days) 

Note: be careful, the years parameter is before months in this syntax.

utility_commands.txt · Last modified: 2017/07/14 15:31 by cs_admin