Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic Rhapsody (steve huntington)
Decrease font size
Increase font size
Topic Title: Declaring a variable in Reporter Plus
Topic Summary:
Created On: 6-Sep-2005 17:56
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
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.
 6-Sep-2005 17:56
User is offline View Users Profile Print this message


Sue Strane

Posts: 12
Joined: 17-Jun-2005

How do you declare a variable in Reporter Plus Q language?

this is how I would like to do it:
string x
string s
string y

x = match(`new [a-zA](*)`, $opnBody) and s = replace(`'new`, x, "") and y=replace(`(*)`, s, "")
Report this to a Moderator Report this to a Moderator
 12-Sep-2005 16:05
User is offline View Users Profile Print this message


Andreas Themis

Posts: 265
Joined: 29-Nov-2005

Hi Sue,

try something like:

let x= expr1 in expr2.

See the page 10 of Q language in Rhapsody 6.0.

Note: global variables are not supported

Regards,
Andreas
Report this to a Moderator Report this to a Moderator
 14-Sep-2005 08:26
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

Hi Andreas!

I too have wanted to set variables in ReporterPLUS, and come to the conclusion that there is no such feature... at least, there is no way to define a variable in the form that we normally understand one - a named datum stored in memory and modified/referenced by a program.

So, I'm very interested in your recommendation to try the "let" expression. If I understand correctly, the expression:

let x = expr1 in expr2

simply substitutes all occurences of "x" in "expr2" with the value of "expr1".

I'm finding it difficult to see how to use this... Please do you have a practical example you could let us see?

best regards,
Simon

-------------------------
Simon Morrish
simon.morrish@eu.panasonic.com
http://panasonic.co.uk
Panasonic ideas for life
Report this to a Moderator Report this to a Moderator
 14-Sep-2005 15:03
User is offline View Users Profile Print this message


Andreas Themis

Posts: 265
Joined: 29-Nov-2005

Hi Simon!

I agree. It's specialised and not needed in most cases, but it can be used to simplify expressions.

How about this. If you add a text node, you could have a sequence of expressions that extract any information from anywhere in the model...in one text node.

"The version of Rhapsody application that is running is: «let myObject = model->[application] in $Version of myObject»"

This could simplify the template, especially if you want to build up some textual body that extracts from various areas of the model.


You can test these expressions by using the Q-Tester. Right-click in the Model View of the ReporterPLUS browser (top right), on the project[Project] and run the above in the Q-Tester (you may need to add some text in the Rhapsody model descriptin first).

You can use the Q-Tester anywhere, it's handy to test Q-expressions instead of trying to generate the report and see if it worked or not.

So now let's start combining things:

let x = model->[project]->[useCaseDiagrams]{$name="Dishwasher"} in $displayName of x + " Name: " + $displayName

This extracts the displayName of usecase diagram Dishwasher, followed by its display name.

Or we could maybe add another expression - all in one (beauty of expression and let):

let x = expr1 in let y = expr2 in x + y

Etc etc

Regards,
Andreas
Report this to a Moderator Report this to a Moderator
 15-Nov-2005 14:01
User is offline View Users Profile Print this message


Jessica Patla

Posts: 26
Joined: 2-Nov-2005

:mad:

I am still very confused on the let function and how it relates to declaring a variable. Here is what I wish to do:

In my project there is a ThreadPkg, which contains five classes: Thread1a, Thread2a, Thread3a, Thread4a and ThreadWhenFree. I wish to see if these Threads are inside an implementation of an operation ($opnBody) with path (model->[project]->[containedPackages]->[classes]->[operation]). Here is the thing, I do not wish to hard code a thread, meaning, I do not want to write out Thread2a.
What I really wish to do, but it is not possible:
match($name of the thread, $opnBody)...but we all know that the match function wants a string...
Report this to a Moderator Report this to a Moderator
 16-Nov-2005 10:18
User is offline View Users Profile Print this message


Simon Morrish

Posts: 127
Joined: 17-May-2005

Yes, I agree. It's frustrating, isn't it! Match takes a regular expression (not strictly a string) which must be a constant.

I can't think of a direct solution to your problem, but here are some thoughts:

[list=1]
[*]The let expression really does not define a variable: Q doesn't do variables. Instead, it provides value substitution. I think of it more like a C/C++ #define/macro.
[*]If you're trying to achieve hyperlinks to and between operation bodies, you might be better off looking at a tool such as [URL=http://www.doxygen.org/][COLOR=Navy]Doxygen[/COLOR][/URL], which does as excellent job of this.[/list]
regards,
Simon

-------------------------
Simon Morrish
simon.morrish@eu.panasonic.com
http://panasonic.co.uk
Panasonic ideas for life
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic Rhapsody forum.
There are currently 1 users logged in.
You have posted 0 messages to this forum. 0 overall.

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