![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Creating functions Topic Summary: Created On: 17-Aug-2005 16:26 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: There sure is. It is, in fact, just like in C/C++.....here's an example: int numObjects(string mod_name) { //code for your function... } Then to call it: int objs = numObjects("/Products/product1") -Chris | |
![]() |
|
Is there a way to create functions in DXL scripts? I have some code I wrote in DXL and want desperately like to create a function/subroutine that I could call in the body of my "main" program (like one would do in C/C++ programs). I would need to pass parameters (arguments) to my function when I make a function call.
|
|
![]() |
|
![]() |
|
There sure is. It is, in fact, just like in C/C++.....here's an example:
int numObjects(string mod_name) { //code for your function... } Then to call it: int objs = numObjects("/Products/product1") -Chris |
|
![]() |
|
![]() |
|
Functions with no parameters still need to have the parenthesis () when declared. Functions that don't return a value are declared as type "void" (perhaps these are called "subroutines"). Those that have neither had better be updating a global variable, such as this:
int g_NumCalls = 0 void UpdateNumCalls() { g_NumCalls++ } UpdateNumCalls UpdateNumCalls() // Its better to use empty parens when calling parameterless functions // ... it makes understanding its a function easier when reading, and there are times // .... when it really matters. print g_NumCalls "\n" // prints "2" Functions with a return value had better set that value in each "return" statement, such as "return(i)". The calling Main program does NOT have to use the return value. if UpdateNumCalls returns the number of calls so far, the Main can still do this: "UpdateNumCalls()" and the returned integer is ignored. - Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Creating functions
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.