Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Function calling
Topic Summary: Calling an #include function
Created On: 7-Aug-2008 09:52
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 7-Aug-2008 09:52
User is offline View Users Profile Print this message


Mark Williamson

Posts: 79
Joined: 12-Sep-2005

Hi all,

I have managed to cobble together a basic dxl script to create a user option DB and a separate function which copies a Formal module template with the user provided name and description. Both of these DXL scripts run ok independently but I'm having difficulty calling the function from the #include.

It is probably obvious but I am a DXL novice on a steep learning curve!

My code is attached below:

Thanks

Mark

// Create Test Option Menu

/*
This script generates an Functional dialog that provides the user the ability to select required function.
*/
#include <C:\Documents and Settings\Mark Williamson\My Documents\DOORS\My DXL\TTG\includes\Create Adhoc Test.inc>
string options[] = {"Create Adhoc test", "Create Baseline test", "Search existing tests", "Add test results","Search Test Results","Create Test Report","Search existing reports"}

string user = doorsname

DB OptionDB = create("TTG Options", styleFixed|styleCentered|styleFloating)
DBE cNameDBE = field(OptionDB, "User: ",user, 20, false)
DBE oFrameDBE = frame(OptionDB, "User Options", 200, 280)
DBE optionDBE = verticalRadioBox(OptionDB, "Options", options, 0)
optionDBE -> "top" -> "inside" -> oFrameDBE

void getOption(DB dbe)
{
int o = get (optionDBE)
string opt = options[o]"\n"
print opt
}
apply (OptionDB,"Select",getOption)
show OptionDB

/// Create Adhoc Test Dialog

/*
This script generates an Functional dialog that provides the user the ability to create a new test as Adhoc or Baseline and copy a template module with user supplied name and description
*/
void createTest (DB NewTest)
{
string user = doorsname

DB NewTestDB = create("Create New Adhoc Test", styleFixed|styleCentered|styleFloating)
DBE cNameDBE = field(NewTestDB, "User: ",user, 20, true)

DBE adhocDBE = field (NewTestDB,"Test Title","Enter test title here",20,false)
DBE adhocDescDBE = field (NewTestDB,"Test Description","Enter test description here",20,false)
cNameDBE ->"right"->"unattached"
string title = (get adhocDBE)
string desc = (get adhocDescDBE)
confirm (NewTest, "This will create a new formal module in the database for selection of test requirements with the title: "title " and the description " desc)
string modname = "/Terminal Test Generator/TTG Application/" title

if(!exists module modname)
{
copy(module "Test Module template",title,desc)
refreshDBExplorer
hide NewTestDB
}
else
{
infoBox "Module already exists"
}
apply (NewTestDB,"Select",createTest)

show NewTestDB
}

-------------------------

mark_williamson@synthesys.co.uk
http://www.synthesys.co.uk
----------------------------------------
Report this to a Moderator Report this to a Moderator
 7-Aug-2008 10:55
User is offline View Users Profile Print this message


Peter Albert

Posts: 232
Joined: 30-Dec-2005

Basically, an #include <myFile> statement is used as if the content of 'myFile' was put directly in the source code at the place of the #include statement itself. In your example, in order to 'jump' into the included file, a line à la 'createTest(OptionDB)' after 'print opt' would do the trick.

Please note that my answer assumes that you want to use the 'createTest' routine as a callBack for the man 'OptionDB' dialog box. If that is true, calling the parameter variable in the routine header 'NewTest' is actually slightly obfuscating the code, and it might be confused with the 'DB NewTestDB' variable you are defining below.

Regards,

Peter
Report this to a Moderator Report this to a Moderator
 7-Aug-2008 11:07
User is offline View Users Profile Print this message


Mark Williamson

Posts: 79
Joined: 12-Sep-2005

Hi Peter,

Many thanks. I was 99% there and just needed to specify OptionDB with createTest.

Regards

Mark

-------------------------

mark_williamson@synthesys.co.uk
http://www.synthesys.co.uk
----------------------------------------
Report this to a Moderator Report this to a Moderator
 8-Aug-2008 08:38
User is offline View Users Profile Print this message


Mark Williamson

Posts: 79
Joined: 12-Sep-2005

One step forward and two steps back. The function is now being called but the 'Apply' button is now not displayed within the DB created by the function. Is this something to do with the OptionDB callback in the function call?

Thanks

Mark

-------------------------

mark_williamson@synthesys.co.uk
http://www.synthesys.co.uk
----------------------------------------
Report this to a Moderator Report this to a Moderator
 8-Aug-2008 09:56
User is offline View Users Profile Print this message


Peter Albert

Posts: 232
Joined: 30-Dec-2005

I can't replicate the problem, both buttons are properly displayed. Did you do any more changes to the code compare to what is above? On a side note, I would recommend to put the 'copy module' part into a separate callback routine. As it is now, the copy perm is executed before the user has a chance to provide module name and description.

Cheers,

Peter
Report this to a Moderator Report this to a Moderator
 8-Aug-2008 11:42
User is offline View Users Profile Print this message


Mark Williamson

Posts: 79
Joined: 12-Sep-2005

Hello again Peter, thank you for your help and advice. I'm getting there slowly.

The OptionDB is displayed correctly with Select and Close buttons, but when NewTestDB is displayed (selected from OptionDB), only the close button is visible.

I had noticed that the confirm and copy perm was being executed prior to the NewTestDB display, but haven't been able to create a separate call back routine where it is in scope.

void createTest (DB NewTest)
{
string user = doorsname

DB NewTestDB = create("Create New Adhoc Test", styleFixed|styleCentered|styleFloating)

DBE cNameDBE = field(NewTestDB, "User: ",user, 20, true)

DBE adhocDBE = field (NewTestDB,"Test Title","Enter test title here",20,false)
DBE adhocDescDBE = field (NewTestDB,"Test Description","Enter test description here",20,false)
cNameDBE ->"right"->"unattached"

string title = (get adhocDBE)
string desc = (get adhocDescDBE)

confirm (NewTest, "This will create a new formal module in the database for selection of test requirements with the title: "title " and the description " desc)
string modname = "/Terminal Test Generator/TTG Application/" title

if(!exists module modname)
{
copy(module "Test Module template",title,desc)
refreshDBExplorer
show NewTestDB
}
else
{
infoBox "Module already exists"
}
show NewTestDB
apply(NewTestDB,"Select",createTest)

}


Mark

-------------------------

mark_williamson@synthesys.co.uk
http://www.synthesys.co.uk
----------------------------------------
Report this to a Moderator Report this to a Moderator
 8-Aug-2008 12:02
User is offline View Users Profile Print this message


Peter Albert

Posts: 232
Joined: 30-Dec-2005

You accidentally placed the "apply" perm after the "show" perm. Any code after 'show' is never executed, hence the button is never displayed.

Attached a quick hack of your code with the 'copy' perm in a separate callBack routine.

Cheers,

Peter
Report this to a Moderator Report this to a Moderator
 8-Aug-2008 14:15
User is offline View Users Profile Print this message


Mark Williamson

Posts: 79
Joined: 12-Sep-2005

Hi Peter,

Many thanks for your persistance. I have much to learn. I think I now understand the callback usage and the benefit of creating separate call back routines. Your copyModule perm has given me an excellent example to work from.

Thanks

Mark

-------------------------

mark_williamson@synthesys.co.uk
http://www.synthesys.co.uk
----------------------------------------
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.