Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » RCP Testing Tool » ECL command(Need to increment a val(variable) and assign it to a new variable)
ECL command [message #1426758] Fri, 19 September 2014 07:11 Go to next message
raghavendra l is currently offline raghavendra lFriend
Messages: 6
Registered: September 2014
Junior Member
Hi,

i have declared a val in a let block as shown in below snippet and i need to increment the num by 1:

let[val num 0]{
if(some condition)
$num|plus 1
}

show-alert [str $num]
}

the value always remains 0 even after entering the if.

can some one please guide is this the right way to do it ?

regards
raghav
Re: ECL command [message #1426808 is a reply to message #1426758] Fri, 19 September 2014 08:37 Go to previous messageGo to next message
Ulyana Skorokhodova is currently offline Ulyana SkorokhodovaFriend
Messages: 280
Registered: July 2014
Senior Member
Hi Raghav,

I can see a few reasons here.





  1. Syntax. It should be this way:
    let[val num 0] {
       if [some condition] {
          show-alert [...]
       }
    }
    

  2. You can't increment an already declared variable (in ECL). You have different ways:



    • create your custom procedure:
      proc "modify-if" [val x]{
       if[get-view "Test Explorer" | get-tree | get-property itemCount -raw | eq 1]{
        $x | plus 1
       }-else {
       $x
       }
      }
      
      let[val num 0]{
        let [val newNum [modify-if $num]]{
       show-alert [$newNum | str]
         }
      }
      

    • declare another variable
      let [val num2 [$num | plus1]] 

    • use the following construction
          show-alert [$num | plus 1 | str]




    Please do not forget to use -raw argument and eq if you use get-property in a condition block:
    let[val num 0]{
       if [get-view "Test Explorer" | get-tree | get-property itemCount -raw | eq 1]{
            show-alert [$num | plus 1]
       }
    }
    


Please let me know if it helped.

Yours sincerely,
Ulyana.

[Updated on: Tue, 23 September 2014 08:57] by Moderator

Report message to a moderator

Re: ECL command [message #1428750 is a reply to message #1426808] Mon, 22 September 2014 09:24 Go to previous messageGo to next message
raghavendra l is currently offline raghavendra lFriend
Messages: 6
Registered: September 2014
Junior Member
Thanks ulyana,

I was trying to modify the already declared variable which i learnt from your input, that it is not possible.

i need to know, is it possible to create my own RCPTT/ECL command and inject it to RCPTT ??

if yes ? can you please share me the reference links or documents to do the same.

Thanks in advance

Regards

raghav

Re: ECL command [message #1429457 is a reply to message #1428750] Tue, 23 September 2014 08:54 Go to previous messageGo to next message
Ivan Inozemtsev is currently offline Ivan InozemtsevFriend
Messages: 0
Registered: January 2015
Hi Raghav,

As RCPTT is an open-sourced successor of a commercial tool (Q7), we haven't yet migrated all documentation and samples. We have a slightly outdated new command guide here http://help.xored.com/display/ECL/New+Command+Guide and sample github repository here https://github.com/xored/q7.extensions.ecl. The main reason why documentation is outdated, is that you should take ECL plugin sources from RCPTT Git repository (http://git.eclipse.org/c/rcptt/org.eclipse.rcptt.git/), and all plugins/namespaces in ECL has been renamed from org.eclipse.ecl* to org.eclipse.rcptt.ecl*. Once we'll update a documentation and examples, I'll publish new links here.

Alternatively, if you'd provide more information about what are you trying to achieve with a custom command, we might guess a possible alternative solution by using existing ECL commands.

Thanks,
Ivan

Re: ECL command [message #1438766 is a reply to message #1429457] Mon, 06 October 2014 13:09 Go to previous messageGo to next message
raghavendra l is currently offline raghavendra lFriend
Messages: 6
Registered: September 2014
Junior Member
Hi Ivan,

Thanks for the info, kindly inform me once the ECL plugin documents are updated.

We are planning for few custom commands as we came across certain problems which could not be solved using commands available, as far the knowledge i have on ECL
kindly correct me if am wrong on the below analysis:

1. need a mechanism to read values from Excel sheet/DB.
2. need a mechanism to increment a variable value/reassign value after declaring.
3. need a mechanism to generate HTML reports/ customized one.
4. need a mechanism to populate the list values while running the script.

please let me know is their any exiting solution/work around for the above problems ?And also is it possible to build a custom command for the above ??


I fond an issue while retrieving values from a declared list, please find the below snippet

list "2.10" "2.20" "2.30" "2.40"| get 0|show-alert

the value i get is 2.1 but i expected 2.10 can you please help me on the same as well.

Thanks in advance

Regards

raghav




Re: ECL command [message #1439405 is a reply to message #1438766] Tue, 07 October 2014 06:08 Go to previous messageGo to next message
Olga Yurchuk is currently offline Olga YurchukFriend
Messages: 245
Registered: September 2014
Senior Member

To resolve your problem with floating point numbers you can use concat command:
list [concat "2.10"] [concat "2.20"] [concat "2.30"] [concat "2.40"]| get 0|show-alert

It's not natural and easy solution we will try to find easier way to resolve that problem later.


Yours sincerely,
Olga.
Re: ECL command [message #1439406 is a reply to message #1438766] Tue, 07 October 2014 06:09 Go to previous messageGo to next message
Olga Yurchuk is currently offline Olga YurchukFriend
Messages: 245
Registered: September 2014
Senior Member

Hi Raghav,

There are
1. Currently it is possible to read a data from CSV file (and it is easy to save an Excel spreadsheet to a csv file) by using read-csv-file command (http://download.xored.com/q7/docs/ecl-api/latest#read-csv-file).

2. Variables are immutable and once set, their value cannot be changed, but we use a term 'variable' as it more familiar and recognizable. Their value cannot be changed, but you can declare new variables as many as you need.

Possibly loop (http://download.xored.com/q7/docs/ecl-api/latest#loop) can help you this way:

// Example 1. returns how many times a 81 is divisible by 3
loop [val count 0] [val n 81] {
    if [mod $n 3 | eq 0] {
        recur [$count | plus 1] [$n | div 3]
    } -else {
        log [format "The answer is %d" $count] //prints 'The answer is 4'
    }
}


Variable count is incremented there in the body of recur.

Also you can increment your variable using command global with the key -override:
global [val j 8] 
log $j

global [val j [plus  1 $j]] -override
log $j

But we don't recommend increment variables this way, because it will be difficult to support such code.

3. To create custom reports you can parse our XML report or extend org.eclipse.rcptt.reporting.reportRenderer extension point as it is done in http://git.eclipse.org/c/rcptt/org.eclipse.rcptt.git/tree/core/org.eclipse.rcptt.reporting/src/org/eclipse/rcptt/reporting/internal/FileReportGenerator.java and our other renderers. You can also add custom properties to report nodes from runtime by using org.eclipse.rcptt.reporting.core.ReportManager class.

4. You can create the list values by using command repeat (http://download.xored.com/q7/docs/ecl-api/latest#repeat):
repeat -index [val x] -times 100 -command {
    emit $x
} | to-list

You can replace "emit $x" by element you need.

Please let me know if my answer helped you. If it didn't, could you please clarify what exactly problems do you have in items 1, 2, 3, 4.


Yours sincerely,
Olga.
Re: ECL command [message #1735838 is a reply to message #1439406] Thu, 23 June 2016 08:04 Go to previous messageGo to next message
Angel Fraile is currently offline Angel FraileFriend
Messages: 10
Registered: June 2016
Junior Member
Hi everybody, I am new here an this is my first post Smile. I want to rescue this issue because it fits well with my problem (at least the first part and the tittle)

I want to count the items that are checked in my table. The first column is a checkbox. I know that is not possible to increment a variable, but the idea with the code it is easy to see with the example:

proc "count-checked" {
	with [get-view "vew" | get-table "table"] {
		let [val item -input] [val count [int 0]] {
			get-items | foreach {
		    		let [val item -input] {
			    		if [$item | get-property checked -raw | equals true] {
			      			$count | plus 1
			      		}
		    		}
			}
			$count | equals 2 |verify-true
	        }
	}
}


Maybe there is an easier way to solve the problem, for sure you could help me. Thanks!
Re: ECL command [message #1735992 is a reply to message #1735838] Fri, 24 June 2016 08:39 Go to previous messageGo to next message
Angelo Luciani is currently offline Angelo LucianiFriend
Messages: 129
Registered: September 2015
Location: Milan
Senior Member

To increment I suggest to use recursion

loop [val count 1] [val n 5] {

    if [$count | lt $n] {

        show-alert $count

        recur [$count | plus 1] [$n]

    } -else {

      show-alert "completed"

    }
}

to handle the variable I suggest to use global variables.
In RCP TT is useful to use global variable .
1.Declare the variable
global [val perspective "Initialized"]

2.To assign a dynamic variable override the global variable
global [ val perspective [get-table | get-property[concat [concat "getItems().TableItem[" $count ] "].getText()" ] -raw]  ] -override










[/code]


"Ce sont les petits désirs qui rendent un jeune homme hardi."
Giovanni Giacomo Casanova

[Updated on: Fri, 24 June 2016 08:41]

Report message to a moderator

Re: ECL command [message #1736305 is a reply to message #1735992] Tue, 28 June 2016 10:41 Go to previous messageGo to next message
Angel Fraile is currently offline Angel FraileFriend
Messages: 10
Registered: June 2016
Junior Member
Hello, thanks for the answer. I was not sure about to use global variables, but it is a good solution to resolve my problem. Here an example:
global [val count 0] 

proc "count-checked" {
	with [get-view view | get-table  table]] {
		get-items | foreach {
	    	let [val item -input] {
	    		format "project %s" [$item | get-property checked -raw] | log
	      		if [$item | get-property checked -raw | equals true] {
	      			global [val count [plus 1 $count]] -override
	      			format "project %s" [$count] | log
	      		}
	    	}
	   }
	   $count | equals 2 |verify-true
	}
}


Thanks again!
Re: ECL command [message #1736412 is a reply to message #1736305] Wed, 29 June 2016 10:31 Go to previous messageGo to next message
Kuntal Nandy is currently offline Kuntal NandyFriend
Messages: 1
Registered: June 2016
Junior Member
Hi, I am new to RCCPT. I have a table with multiple columns and 3rd column is a series of checkbox.
Scenario - I am trying to see if any checkbox is checked, then I will make it uncheck, else I will skip that row.
My code -
show-alert "1"
if [ get-view "Field rights (217/1616)" | get-table | get-cell 2 2 | get-property checked -raw | equals true ]
{
show-alert "2"
get-view "Field rights (217/1616)" | get-table | get-cell 2 2 | mouse down -count 1
get-view "Field rights (217/1616)" | get-table | select [get-item Item -column "Data range" -index 2]
get-view "Field rights (217/1616)" | get-table | get-cell 2 2 | mouse up -count 1
}
show-alert "3"

but if I give TRUE, then does not matter if it is checked or not for it goes inside the if block and toggle the selection.

Please help with this situation. Thanks in advance
  • Attachment: Error1.jpg
    (Size: 11.53KB, Downloaded 238 times)
Re: ECL command [message #1737010 is a reply to message #1736412] Tue, 05 July 2016 06:39 Go to previous messageGo to next message
Andrey Sobolev is currently offline Andrey SobolevFriend
Messages: 75
Registered: February 2015
Member
Hi,

You need to use "eq" command instead of equals, it was because for compatibility reasons 'equals' command is designed for constructing of verify handler and for use with 'verify-true' commands.

"if [ get-view "Field rights (217/1616)" | get-table | get-cell 2 2 | get-property checked -raw | eq true ]" should work fine.

Best regards,
Andrey.
Re: ECL command [message #1747954 is a reply to message #1426758] Thu, 17 November 2016 09:54 Go to previous message
Md. Mosiur Rahman Palash is currently offline Md. Mosiur Rahman PalashFriend
Messages: 7
Registered: February 2015
Junior Member
hi folks,

Is there any way to get try exception message in catch block

//ex:
try
{
some error while executing rcptt code
}
-catch
{
log - exception message
}

thanks..
Previous Topic:Select a data in a list
Next Topic:Try-Catch-Exception
Goto Forum:
  


Current Time: Fri Apr 19 08:35:42 GMT 2024

Powered by FUDForum. Page generated in 0.02194 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top