Data Type Conversion

From SDU
Revision as of 19:04, 26 July 2008 by Gityerfix (Talk | contribs)

Jump to: navigation, search
To make corrections or additions to this article, select the edit tab above.
To discuss or ask questions about this article, select the discussion tab above.

Overview

This This article details how to convert from one data type to another in Spel code. This concept is regarded as casting.

Details

Primary data types used in USD spel.

  • string
  • int
  • date
  • duration
  • uuid (introduced in r11.x)

Example: <source lang="javascript">string MyString; int MyInt; date MyDate; duration MyDuration; uuid MyUUID;

MyString = "Hello world no: " +(string) 1; // result: "Hello world no: 1" MyInt = (int) "2 times"); // result: 2 MyDate = (date)( (string) now()); // result: the actual date depending of your system time configuration MyDuration = (duration)((int) "2" + 3), // result: duration of 5 sec. MyUUID = (uuid)expand( "&{'mylogin'=cnt.userid->id}"); // result: the id of contact having userid "mylogin"</source>