Professional Documents
Culture Documents
P6 Global Change Functions: Substring Example
P6 Global Change Functions: Substring Example
Use the following string functions in Then: and Else: statements to select and change values for fields such as the activity ID, descriptions, resource names, and other text parameters. Function SubString(Parameter,x,y) Purpose Extracts y characters, beginning with the character in position x. e.g. SubString(Activity ID,2,4) Activity ID ABC123 SubString statement will extract "BC12" For further examples of the SubString function, see further down this solution. Extracts # of character. s, beginning with the last character in the parameter. Extracts # of characters, beginning with the first character in the parameter. Finds the day of the week on which the date falls.
Substring Example: The SubString function extracts a specified number of characters (defined with the first #) from a text field starting at a specified position (defined using the second #). Example If: Activity ID = AADRAW000 Then: Activity ID = SubString(Activity ID,3,4) RightString Example: The RightString function extracts a specified number of characters from a text field, beginning with the last character of the value. The following example changes an activity name. Example If: Activity Name = System Design. Then: Activity Name = RightString(Activity Name,6) Explanation Selects activities named System Design. Extracts six characters, beginning with the last character in the Activity Name field. Old value New value Explanation Selects activity AADRAW000 Extracts four characters, beginning with the third. Old value New value
AADRAW000
DRAW
System Design
Design
LeftString Example:
&n.bsp;
The LeftString function extracts a specified number of characters from a text field, beginning with the first character of the value. The following example changes the name of an activity. Example If: Activity Name = System Design Then: Activity Name = LeftString(Activity Name,6) Explanation Selects activities named System Design. Extracts six characters, beginning with the first character in the Activity Name field. Old value New value
System Design
System
&n.bsp;
The DayOfWeek function returns the day of the week (Monday, Tuesday, and so on) to the specified date field, such as the Start or Finish. Example Then: User_text1=DayOfWeek(Start) Explanation Stores the day of week corresponding to the start date in the User_text1 user field.