Apple Newton Utilities Guide de l'utilisateur Page 744

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 942
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 743
CHAPTER 20
Localizing Newton Applications
20-12 Using the Localization Features of the Newton
To use one of these values, access the appropriate slot by dereferencing
ROM_dateTimeStrSpecs with a dot operator, as in the following example:
LongDateStr(Time(),ROM_datetimestrspecs.longDateStrSpec);
Using these predened format specications also saves the trouble of dening them
at compile time and initializing slots with the compile-time variables at run time.
Format specications available from the
ROM_dateTimeStrSpecs object are
listed in “System-Dened Format Specications” (page 17-11) in Newton
Programmers Reference
Using GetDateStringSpec 20
A date or time format specication is an array, the elements of which are
themselves two-element arrays. The rst element in each two-element array is a
constant specifying the item to display. The second element is a constant specifying
the format in which to display that item.
The complete set of constants is listed in “Constants to Create Your Own
Specication” (page 17-13) in Newton Programmers Reference.
For example, the two-element array [kElementDayOfWeek, kFormatAbbr]
species that the day in a date string is to be displayed in abbreviated format, such
as “Wed”. On the other hand, the two-element array
[kElementDayOfWeek,
kFormatLong] specifies that the day of the week is to be displayed in long
format, such as “Wednesday”.
The following code example uses system-supplied constants to build an array of
[element, format] pairs specifying the output of a date string. This array is
supplied as the argument to the
GetDateStringSpec function, which returns the
format specication passed to the LongDateStr function. The LongDateStr
function returns a string with the current time (returned by the
Time function)
formatted as specied by the format specication:
// at compile time, define my array of
// element and format pairs
DefConst('myArray,
[
[kElementYear, kFormatNumeric],// year
[kElementDay, kFormatNumeric],// day of month
[kElementMonth, kFormatLong],// name of month
[kElementDayOfWeek, kFormatLong]// day of week
]);
// create the formatSpec
// this spec returns a string such as “February 1, 1994”
DefConst('kmyDateSpec, GetDateStringSpec(myArray));
Vue de la page 743
1 2 ... 739 740 741 742 743 744 745 746 747 748 749 ... 941 942

Commentaires sur ces manuels

Pas de commentaire