![]() |
Telelogic Rhapsody (steve huntington) | ![]() |
Topic Title: Declaring a variable in Reporter Plus Topic Summary: Created On: 6-Sep-2005 17:56 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
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, "") |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
: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... |
|
![]() |
|
![]() |
|
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 |
|
![]() |
Telelogic Rhapsody
» Rhapsody Category » Rhapsody
»
Declaring a variable in Reporter Plus
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.