DOORS DXL - Basic data types » TheCloudStrap (2024)

DOORS DXL - Basic data types » TheCloudStrap (1)

DOORS DXL Tutorial Part 2

Table of Contents hide

1. DOORS DXL Tutorial Part 2

1.1. What is an Identifier in DXL?

1.2. Basic Data Types in DXL

1.4. Arithmetic Operations on Integer Type in DXL

1.5. Assignment Operations on Integer type in DXL

1.6. Conclusion

1.7. 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 will help you. This is part-2 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), I explained how to write a simple Hello World program. In this article series, we will mainly discuss the data types in DXL scripting.

What is an Identifier in DXL?

Identifier is nothing but a variable, data types, functions, and values.

Basic Data Types in DXL

Here are the fundamental data types that are available in DXL scripting:

Basic Data Type in DXLDescription
intInteger type. It is a 32-bit integer type.
realSimilar to float or double type in C/C++. It is 64-bit precision.
charSimilar to character type in C/C++.
stringstring data type.
boolBoolean data type to represent true or false.
voidEmpty data type. It is mainly used for function return types.

Variable declaration and initialization

Now, we know all the available data types in DXL. Let’s now look into a couple of examples to show how to declare and initialize different types of variables. Here is an example DXL program:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d2.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************************************************************************/int i = 100real r = 200.58;bool b = true;char c = 'W'string s = "Welcome to DXL!"print "i = " i "\n"print("r = " r "\n")print("c = " c "\n")print("b = " b "\n")print("s = " s "\n")

In the above program, I have declared and initialized several variables such as i, r, b, c, s of type int, real, bool, char, and string respectively. I have then simply printed them one by one. I have not included “void” type in this example to make the example simple. I will cover the void type when I discuss the function. In DXL, the void data type is mainly used for the function return type to indicate what kind of data the function is going to return.

Let us now run the above program and see the output. I have discussed in the previous article how to run the DXL script in DOORS.

DOORS DXL - Basic data types » TheCloudStrap (2)

We can do various operations on these basic data types. For example, we can apply addition, subtraction, multiplication, division, increment, decrement, bitwise AND etc operators. Similarly, you can apply the arithmetic operator, assignment operator, and math functions for real types. But, you can not apply the bitwise operator on real data types for obvious reasons. For boolean types, you can apply comparison operators ( i.e. >,<,>=,<=,==,!=), and logical operators (&&, ||, !).

Here is an example program to showcase how to apply those operators on int, real type variables. If you are familiar with other programming languages such as C/C++, you may already know the concept.

In this program, you can see addition, and subtraction for int and real and comparison operations for bool type. First, I have declared an integer type variable i.e. day, and initialized it to 0. Notice that I have intentionally added a semicolon at the end of the statement and in the next line, I have avoided it. This is to show you that the DXL interpreter does not expect you to end a statement with a semicolon. It is optional. From my next article, onward I will consistently follow by adding a semicolon at the end of each statement.

The variable “day” is then incremented by 1 and again added to 2 with the current value. After that, it is decremented(–) by 1.

Similarly, I have declared temp, and temp_offset of real type and performed subtraction operation. Later, the comparison operation is performed in the if condition. The syntax of the if condition is very similar to C/C++. If you have just one statement under the if condition, you can also avoid adding “{}”.

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d2.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************************************************************************/int day = 0;day++// day = day + 1day = day + 2day--// day = day - 1real temp = 5.78;real temp_offset = 0.02;temp = temp - temp_offset;if(day==2){print "Happy Tuesday!\n"}if(temp>5.0){print "It's Cold!"}

Now, let’s run the program. Here is the output:

DOORS DXL - Basic data types » TheCloudStrap (3)

Arithmetic Operations on Integer Type in DXL

Here is the operation you can perform on integer data type:

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d2.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************************************************************************/int i = 15, j = 2, result = 0;// 1. Addition result = i + j;print("result = " result "\n");// 2. Subtractionresult = i - j;print("result = " result "\n");// 3. Multiplicationresult = i * j;print("result = " result "\n");// 4. Divisionresult = i / j;print("result = " result "\n");// 5. Modulo Division (remainder after division)result = i % j;print("result = " result "\n");// 6. Bitwise ORresult = i | j;print("result = " result "\n");// 7. Bitwise ANDresult = i & j;print("result = " result "\n");// 8. Bitwise NOTresult = ~i;print("result = " result "\n");// 9. Negationresult = -i;print("result = " result "\n");
DOORS DXL - Basic data types » TheCloudStrap (4)

Assignment Operations on Integer type in DXL

Here is another example DXL script to demonstrate the various assignment operation you can do on integer type.

// www.TheCloudStrap.Com/************************************************************************* $FILENAME: d2.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************************************************************************/int i = 15, j = 2, result = 0;// assignment operationresult = i;print("result = " result "\n");// +=result += j;print("result = " result "\n");// -=result -= j;print("result = " result "\n");// *=result *= j;print("result = " result "\n");// /=result /= j;print("result = " result "\n");// %=result %= j;print("result = " result "\n");// |=result |= j;print("result = " result "\n");// &=result &= j;print("result = " result "\n");
DOORS DXL - Basic data types » TheCloudStrap (5)

Conclusion

This was part-2 of the DOORS DXL tutorial. The intention of this article was just 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.

DOORS DXL – Basic data types

DOORS DXL - Basic data types » TheCloudStrap (6)

Admin

This post was published by Admin.

Email: admin@TheCloudStrap.Com

Related posts:

  1. DOORS DXL – Introduction
  2. DOORS DXL Function
  3. DOORS DXL Array
  4. DOORS DXL Items
  5. DOORS DXL Table Operation
  6. DOORS DXL File Operation
  7. DOORS DXL Dialog Box
  8. DOORS DXL Trigger
  9. 5+ Best Practices for DXL Scripting in IBM DOORS: Ensuring Efficiency and Maintainability
  10. Customizing IBM DOORS with DXL: Tailoring the Tool to Fit Your Organization’s Needs
DOORS DXL - Basic data types » TheCloudStrap (2024)
Top Articles
Latest Posts
Article information

Author: Saturnina Altenwerth DVM

Last Updated:

Views: 6444

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Saturnina Altenwerth DVM

Birthday: 1992-08-21

Address: Apt. 237 662 Haag Mills, East Verenaport, MO 57071-5493

Phone: +331850833384

Job: District Real-Estate Architect

Hobby: Skateboarding, Taxidermy, Air sports, Painting, Knife making, Letterboxing, Inline skating

Introduction: My name is Saturnina Altenwerth DVM, I am a witty, perfect, combative, beautiful, determined, fancy, determined person who loves writing and wants to share my knowledge and understanding with you.