Here is the pseudo code which I would like to write using Robot Framework. If it cannot be done using the framework is there any alternative:
${balMethodID}= Set Variable If ${balMethodID} == None ${newBalMethodID}
Basically if the value of variable is None then I want to assign a new value. The value of the variable is becoming None when its initial value is not None.
Set Value If can be given two values; the first will be used if the condition is true, the second is if the condition is false. If you want to keep the original value if the condition is false, use the original value as the last argument:
${balMethodID}= Set Variable If ${balMethodID} == None
... # value if true # value if false
... ${newBalMethodID} ${balMethodID}
Related
I have just created a window, containing a fill-in field (TestField) and a checkbox (chk_TestField):
DEFINE VARIABLE TestField AS INTEGER VIEW-AS FILL-IN.
DEFINE VARIABLE chk_TestField AS LOGICAL VIEW_AS TOGGLE-BOX.
It is very simple to change the value of the fill-in field, based on the checking of the checkbox, something like:
ON VALUE-CHANGED OF chk_TestField IN FRAME DEFAULT-FRAME
DO:
TestField = 5.
END.
However, I'm interested in changing an attribute of the Fill-in field itself, not the integer it represents (I would like to make the fill-in field read-only), how to I do this?
I've tried:
ON VALUE-CHANGED OF chk_TestField IN FRAME DEFAULT-FRAME
DO:
TestField.Read-Only = NOT(chk_TestField).
END.
This, obviously, does not work.
ASSIGN TestField:READ-ONLY IN FRAME {&FRAME-NAME} = TRUE.
or
ASSIGN Table.TestField:READ-ONLY IN FRAME {&FRAME-NAME} = TRUE.
I need to get the value of first tgrp param in this string using Kamailio :
$var(x) = <sip:xxxxxxxxx;tgrp=0001000;trunk-context=xx.xx.xx.xx#xx.xx.xx.xx:5060;transport=UDP;user=phone;tgrp=237>
I’m trying $var(y) = $(var(x){param.value,tgrp}); but it’s getting the last value of tgrp which is 237>.
Noting that first tgrp is not always in the second index , some other parameters can be added to the string.
How to get the value of first occurrence of tgrp param ?
param.value string operations designed to work with unique params names.
You can loop over all params using for loop and checking {param.name,index}
Try a solution based on xavp_params_explode():
https://kamailio.org/docs/modules/stable/modules/pv.html#pv.f.xavp_params_explode
Something like:
xavp_params_explode("$(var(x){s.unbracket})", "x");
xdbg("$xavp(x=>tgrp[0])"); # <- print the value of first parameter tgrp
The index [0] can be omitted, without it first value being returned, but if you want the second param value, then use [1] as index.
I am trying to create a function which will look at two vectors of character labels, and print the appropriate label based on an If statement. I am running into an issue when one of the vectors is populated by NA.
I'll truncate my function:
eventTypepriority=function(a,b) {
if(is.na(a)) {print(b)}
if(is.na(b)) {print(a)}
if(a=="BW"& b=="BW",) {print("BW")}
if(a=="?BW"& b=="BW") {print("?BW")}
...#and so on
}
Some data:
a=c("Pm", "BW", "?BW")
b=c("PmDP","?BW",NA)
c=mapply(eventTypepriority, a,b, USE.NAMES = TRUE)
The function works fine for the first two, selecting the label I've designated in my if statements. However, when it gets to the third pair I receive this error:
Error in if (a == "?BW" & b == "BW") { :
missing value where TRUE/FALSE needed
I'm guessing this is because at that place, b=NA, and this is the first if statement, outside of the 'is.na' statements, that need it to ignore missing values.
Is there a way to handle this? I'd really rather not add conditional statements for every label and NA. I've also tried:
-is.null (same error message)
-Regular Expressions:
if(a==grepl([:print:]) & b==NA) {print(a)}
In various formats, including if(a==grepl(:print:)... No avail. I receive an 'Error: unexpected '[' or whatever character R didn't like first to tell me this is wrong.
All comments and thoughts would be appreciated. ^_^
if all your if conditions are exclusives, just call return() to avoid checking other conditions when one is met:
eventTypepriority=function(a,b) {
if(is.na(a)) {print(b);return()}
if(is.na(b)) {print(a);return()}
if(a=="BW"& b=="BW",) {print("BW");return()}
if(a=="?BW"& b=="BW") {print("?BW");return()}
...#and so on
}
You need to use if .. else statements instead of simply if; otherwise, your function will evaluate the 3rd and 4th lines even when one of the values is n/a.
Given you mapply statement, I also assume you want the function to output the corresponding label, not just print it?
In that case
eventTypepriority<-function(a,b) {
if(is.na(a)) b
else if(is.na(b)) a
else if(a=="BW"& b=="BW") "BW"
else if(a=="?BW"& b=="BW") "?BW"
else "..."
}
a=c("Pm", "BW", "?BW")
b=c("PmDP","?BW",NA)
c=mapply(eventTypepriority, a,b, USE.NAMES = T)
c
returns
Pm BW ?BW
"..." "..." "?BW"
If you actually want to just print the label and have your function return something else, you should be able to figure it out from here.
I use latest Robot Framework.
I need to assign a value to my variable depending on value of an argument. That's how it would be in JavaScript:
ITEM_SELECTOR = RECENT_ITEM_SELECTOR + (
position === 'last' ? ':last-child' : ':nth-child' + '(' + position + ')'
)
This is how I try to write it in Robot Framework:
${ITEM_SELECTOR} = Run Keyword If ${position} == 'last' ${RECENT_ITEM_SELECTOR}:last-child
... ELSE ${RECENT_ITEM_SELECTOR}:nth-child(${position})
but this way ${RECENT_ITEM_SELECTOR}:nth-child(${position}) is considered a keyword, not assigned to ITEM_SELECTOR.
Then I try to preprend it with No Operation, but then my return value is considered its argument and I get Keyword 'BuiltIn.No Operation' expected 0 arguments, got 1.
How can I write it?
Since you are calling run keyword if, you have to give it a keyword to run. You can use set variable to make your code work:
${ITEM_SELECTOR} = Run Keyword If ${position} == 'last'
... Set variable ${RECENT_ITEM_SELECTOR}:last-child
... ELSE
... Set variable ${RECENT_ITEM_SELECTOR}:nth-child(${position})
However, you can also use set variable if for a slightly more compact and readable solution:
${ITEM_SELECTOR} = Set variable if ${position} == 'last'
... ${RECENT_ITEM_SELECTOR}:last-child
... ${RECENT_ITEM_SELECTOR}:nth-child(${position})
I have the following block of code.
reportViewer.ServerReport.ReportPath = LookUpFacade.GetReportFileNameFromDefinition(reportDisplayType.ReportDefinitionID);
reportViewer.ServerReport.SetParameters(reportParameterCollection);
When I add a parameter called "Car" with a value of "Honda", it shows in the reportParameterCollection, but after I set the ReportPath, and I do a reportViewer.ServerReport.GetParameters(), the parameter "Car" is there with a Values property (it can contain multiple values) that is empty (count of 0).
The reportParameterCollection has "Car" with a value of "Honda" but once I call SetParameters, the value is overridden in the ServerReport.GetParameters().
Any ideas?
Actually it had nothing to do with the code. I was passing in the incorrect parameters. I was passing a student id that didn't belong to the requested school.