DOORS DXL - String operation » TheCloudStrap (2024)

DOORS DXL - String operation » TheCloudStrap (1)

DOORS DXL Tutorial Part 4

Table of Contents hide

1. DOORS DXL Tutorial Part 4

1.1. String in DXL

1.2. DXL String Concatenation

1.3. Extract Substring from a DXL String

1.4. DXL String Functions

1.6. upper() and lower()

1.7. DXL String Comparison

1.8. cistrcmp()

1.9. String matching

1.10. Conclusion

1.11. Related posts:

In this series of articles, I am going to explain to you IBM DOORS DXL scripting from scratch. So, if you are a beginner in DXL scripting, hopefully, this article would help you. This is part-4 of the DOORS DXL tutorial.

So, if you are looking for a starting point to learn DXL scripting, you are on the right page! I know, we have the DXL reference manual and it’s a bit concise and difficult to grasp for beginners, especially if you do not have any previous experience in other programming languages.

In the previous article (Part-1,2,3), I explained how to write a simple Hello World program and data types. In this article series, we will mainly discuss the DXL string.

String in DXL

DXL String starts enclosed in quotes (“). String in DXL is similar to char * in c programming. The string in DXL can contain any number of characters and it can be treated as an array of characters. A DXL string can also contain control characters such as “\n”, “\t” etc.

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.1.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string str = "www.TheCloudStrap.Com";//print the stringprint(str "\n");// parenthesis for print function is optionalprint str "\n";
DOORS DXL - String operation » TheCloudStrap (2)

DXL String Concatenation

You can concatenate two strings by using the DXL string concatenation operator i.e. space character (” “). When you concatenate two strings the rightmost element of the expression must be a string.

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.2.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string myStr1 = "www";string myStr2 = "TheCloudStrap";string myStr3 = "com";// String concatenation operator in DXL - space character// Concatenate these strings variables myStr1, myStr2, myStr3, myStr4, and myStr5string myWebName = myStr1 "." myStr2 "." myStr3;// print the concatenated stringprint(myWebName);
DOORS DXL - String operation » TheCloudStrap (3)

Extract Substring from a DXL String

We can extract the substring from a DXL string by using the string indexing method. The DXL string indexation is indicated by [ ]. If you want to extract a particular character from a string, you need to mention the index of the character inside [ ]. The DXL string indexing is similar to the C programming language. The index of the first character in the string is 0, for the second character it is 1, and so on. So, if you mention, str[0], you would get the first character of the string str.

But, if you want to extract a substring from a string, you just need to mention the index range inside [ ]. For example, if you want to extract the first three characters from a string str, you can do the following – str[0:2].

string str [range]

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.3.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string myStr = "www.TheCloudStrap.Com";// Extract a character from the string strchar myCh = myStr[0];print(myCh);print("\n");// Extract a substring from myStrstring mySubStr = myStr[0:2];print(mySubStr);print("\n");// Extract another substring from myStrmySubStr = myStr[4:16];print(mySubStr);print("\n");// Extract another substring from myStrmySubStr = myStr[18:20];print(mySubStr);print("\n");
DOORS DXL - String operation » TheCloudStrap (4)

DXL String Functions

Here are the following string functions that are available in DXL:

  1. int length (string str)
  2. string upper (string str)
  3. string lower (string str)

Length of a DXL String

How to find out the length of a string in DXL? The length() function returns the length of the string str. Here is the syntax of the length() function in DXL:

int length (string str)

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.4.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string str = "www.TheCloudStrap.Com";// Find out the length of the string - strprint(length(str));
DOORS DXL - String operation » TheCloudStrap (5)

upper() and lower()

You can convert a string to lowercase by using the lower() and to upper case by using the upper() function.

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.5.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string myStr = "www.TheCloudStrap.Com";// convert myStr to lower casestring myStrLower = lower(myStr);print(myStrLower);print("\n");// convert myStr to upper casestring myStrUpper = upper(myStr);print(myStrUpper);print("\n");
DOORS DXL - String operation » TheCloudStrap (6)

DXL String Comparison

We can compare DXL string by using the following comparison operators:

== != <= < >= >

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.6.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string myStr1 = "www.TheCloudStrap.Com";string myStr2 = "www.thecloudstrap.com";// compare two DXL stringsif(myStr1 == myStr2){print("String Match!\n");}else{print("No Match!\n");}// compare two DXL stringsif(myStr1 != myStr2){print("Strings do not Match!\n");}else{print("Match!\n");}
DOORS DXL - String operation » TheCloudStrap (7)

cistrcmp()

cistrcmp() is used to compare two strings without considering their case. So, this is a case insensitive string comparison function. This is a very useful DXL string function.

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.7.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string myStr1 = "www.TheCloudStrap.Com";string myStr2 = "www.thecloudstrap.com";// compare two DXL strings using cistrcmp()print(cistrcmp(myStr1,myStr2));// print "PASS" if both string are same (case insensitive)if(0 == cistrcmp(myStr1,myStr2)){print("PASS");}else{print("FAIL");}
DOORS DXL - String operation » TheCloudStrap (8)

String matching

You can use the following function to find the string match:

bool matches ( string pattern, string str )

Here is a DXL script example:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d4.8.dxl* $DESCRIPTION: This is a sample DXL program.** NOTICE: Copyright www.TheCloudStrap.Com. All rights reserved.* Software comes without any warranties and guarantees, is provided * as is and is not supported. Use this software at your own risk. * Authors resume no liabilities.* * Contact: admin {at} TheCloudStrap.com************************************************************************/string myStr = "The test: TEST-005 is FAILED at Line Number-128.";if(matches("FAIL",myStr)){print("TEST Failed!\n");}if(matches("fail",myStr)){print("TEST Failed!");}else{print("TEST - No status");}
DOORS DXL - String operation » TheCloudStrap (9)

Conclusion

This was part-4 of the DOORS DXL tutorial. The intention of this article was to familiarize you with DOORS DXL and show you different data types that are supported by DXL scripting. Please comment below if you have any questions/suggestions.

In the next DOORS DXL tutorial, I will discuss about the strings and how to use strings in DXL.

DOORS DXL – String operation

DOORS DXL - String operation » TheCloudStrap (10)

Admin

This post was published by Admin.

Email: admin@TheCloudStrap.Com

Related posts:

  1. How to remove trailing spaces from the DXL string?
  2. DOORS DXL Module Operation
  3. DOORS DXL Object Operation
  4. DOORS DXL Table Operation
  5. DOORS DXL File Operation
  6. DOORS DXL – Introduction
  7. DOORS DXL Skip List
  8. DOORS DXL Items
  9. DOORS DXL Dialog Box
  10. Customizing IBM DOORS with DXL: Tailoring the Tool to Fit Your Organization’s Needs
DOORS DXL - String operation » TheCloudStrap (2024)
Top Articles
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6446

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.