I was wonder if it possible to execute entire story as given steps for verification.
I mean :
Story 1
Given ..
When ..
Then ..
Story 2
Given ...
When ...
Then Story1 passed
Any way to achieve this scenario ?
Related
I would like to implement a rule that checks if the new data entered in the current node is lower than the one in another node that I update in the same request.
I explain myself with some code:
// x1 and x2 are some Integer
let update : [String : Any] = [
"/Users/\(userId!)/A" : ServerValue.increment(NSNumber(value : x1)),
"/Feedback/\(userId!)/B" : x2
]
dbRef.updateChildValues(update)
And here is the rule:
".validate" : "newData.isNumber() && (root.child('Users').child('$uid').child('A').val() >= newData.val())"
I have two questions:
Since the safety rule of B depends on the new value of A, am I sure that A has been modified before the update of B (since, in the code, the update of A is placed before that of B).
Why my rule for B just doesn't work (regardless of whether B is updated before or after A, because the difference in my tests is so great that it shouldn't reject the request), I've seen examples similar to mine on the net and the syntax looks good.
Thanks for your attention !
The newData variable contains the data as it will exist after the write operation is completed (assuming it is allowed).
So your newData.isNumber() checks the new value of the node.
But your root.child('Users')... is checking the current data in the database, so before the write operation. Since you want to check the post-write value, you have to navigate from newData to the root by calling parent() as many times as needed. So if the rule in your question is defined on /Feedback/$uid/B, that'd be:
newData.parent().parent().child('Users')...
This also looks like a mistake:
child('$uid')
This tries to use the literal string '$uid', while you more likely want to use the value of the $uid variable. That'd be:
child($uid)
I'm building a moving and sensing bot in CoppelliaSim for school. CopelliaSim uses Lua for scripting. Basically every time the bot's forward sensors hit something, one of three if statements will run. I want it to count how many times any of these if statements runs, and once that count gets to a certain amount (like 20), I'll run something else, which will do the same thing (find collisions, add to the count, reach an amount, and switch back to the first).
i=0
result=sim.readProximitySensor(noseSensor) -- Read the proximity sensor
-- If we detected something, we set the backward mode:
if (result>0) then backUntilTime=sim.getSimulationTime()+3
print("Collision Detected")
i=i+1
print(i)
end
result=sim.readProximitySensor(noseSensor0) -- Read the proximity sensor
-- If we detected something, we set the backward mode:
if (result>0) then backUntilTime=sim.getSimulationTime()+3
print("Collision Detected")
i=i+1
print(i)
end
result=sim.readProximitySensor(noseSensor1) -- Read the proximity sensor
-- If we detected something, we set the backward mode:
if (result>0) then backUntilTime=sim.getSimulationTime()+3
print("Collision Detected")
i=i+1
print(i)
end
Above is the start of a function and one of the three If statements. I'm printing just to see if it actually increments. It is printing, but it is not incrementing (just 1 over and over). This bot has 3 sensors on it (an if statement for each sensor) and it adds 1 to i for the first collision and ignores the rest, even if it's from the same sensor. I feel like my problem is just some simple syntax issue with Lua that I don't know and can't find how to properly fix.
I'm happy to provide more code if this little snippet was not sufficient to answer this question.
Assuming that you have a looping function such as sysCall_actuation which is being executed per simulation step. As Joseph Sible-Reinstate Monica has already stated, you are setting your variable i back to zero every time a simulation step is executed. To achieve your goal, you would have to set your variable to 0 outside your function. There are two appropriate approaches to achieve that:
Define the variable outside any function, in the beginning of your file (or before you define any function that uses your variable e.g right before the definition of sysCall_actuation).
-- Beginning of the file.
local i = 0
..
function sysCall_actuation()
..
i = i + 1
..
end
Define your variable in sysCall_init function, which is the appropriate approach in CoppeliaSim.
function sysCall_init()
i = 0
..
end
Finally, you can use your variable in your sysCall_actuation function with basic comparison operations:
function sysCall_actuation()
..
if i > 20 then
i = 0 -- Reset 'i' so this function will not be running every step again and again.
-- Do something here.
..
end
As a side note, practice using local variables whenever you can, to keep the memory clean and avoid having ambiguous variables.
I'm working in a project that uses the IBM SPSS but I had some problems to set a dummy variable(binary variable).The process to get the variable is following : Consider an any variable(width for example), to get the dummy variable, we need
to sort this variable in the decreasing way; The next step is make a somatory of the cases until a limit, the cases before the limit receive the value 1 in the dummy variable the other values receive 0.
Your explanation is rather vague. And the critical value you give in the printscreen should be 2.009 in stead of 20.09?
But I think you mean the following.
When using syntax, use:
compute newdummyvariable eq (ABr gt 2.009477106).
To check if it's okay:
fre newdummyvariable.
UPDATE:
In order to compute a dummy based on the cumulative sum, the answer is as follows:
If your critical value is predetermined, the fastest way is to sort in decending order, and to use the command create with csum() to compute an extra variable which I called ABr_cumul. This one, you use to compute the newdummyvariable. As follows:
sort cases by ABr (d).
create ABr_cumul = csum(VAR00001).
compute newdummyvariable = (ABr_cumul le 20.094771061766488).
fre newdummyvariable.
the dummy comes from the sum of all cases, after decreasing order raqueados when cases of a variable representing 50% of the variable t0tal, these cases receive 1 and the other 0 ...
I asked a question similar to this the other day, but another bug popped up "attempt to concatenate table and string"
local questions={
EN={
Q2={"Who is the lead developer of Transformice?","Tigrounette"},
Q4={"What is Eminem's most viewed song on youtube?","I love the way you lie"},
Q6={"What is the cubic root of 27?","3"},
Q8={"What are the first 3 digits of Pi","3.141"},
Q10={"What is the most populated country?","China"},
Q12={"What is the plural of the word 'Person'?","People"},
Q14={"Entomology is the science that studies ...?","Insects"},
Q16={"Who was the creator of the (bot ran) minigame fight?","Cptp"},
Q18={"The ozone layer restricts ... radiation","Ultraviolet"},
Q20={"Filaria is caused by ...","Mosquitos"}
}
local main = questions.EN["Q"..math.random(1,20)].."%s" -- bug here
local current_answer_en = string.gsub(current_question_en,1,2)
What type of object is questions.EN["Q"..math.random(1,20)]? Say random is 15, what type of object is questions.EN["Q6"]? It is a {"What is the cubic root of 27?","3"}, which is a table, which Lua doesn't know how to concatenate with a string ("%s" in your case). If you want to concatenate with the first item of this table, then
local main = questions.EN["Q"..math.random(1,20)][1] .. "%s"
Note however that you will need the "random with step" function that I posted in math.random function with step option?, otherwise you could get that the table EN["Q"..something] is nil (if the random number is an odd number, in the code you posted).
Note sure what you are trying to do with current_question_en but if you are trying to extract the question and answer you could do something like this:
local QA = questions.EN["Q"..math.random(1,20)] -- this is a table
local question, answer = QA[1], QA[2]
The other option is that you build your table like this:
local questions={
EN={
Q2={q="Who is ..?", a="Tigrounette"},
Q4={q="What is ...?", a="I love the way you lie"},
...
}
}
Then you could use
local QA = questions.EN["Q"..math.random(1,20)] -- this is a table
print("The question:", QA.q)
print("The answer:", QA.a)
Not sure what you're trying to do with string.gsub but it does not take integers as 2nd and 3rd args.
I have gone through msdn article, read whitepaper on number sequences and made number sequences a lot many times. But in this scenario I need some help.
Scenario is; I want to get next sequence number through x++ code using just number sequence code and no reference etc.
I have tried following (and many others but this is nearest solution) ;
static void myTestJob(Args _args)
{
NumberSeq num;
num = NumberSeq::newGetNumFromCode('SAO-Y');
info(num.num()) ;
}
It generates number sequence against some number sequence codes, but for other it throws error that;
"Number sequence does not exist."
I have tried many other options mentioned on many other blogs and tried to explore AX as well, but now need some assistance.
P.S. I'm not creating number sequence using x++ code but from front end (organization administration).
I am able to suppress the exception by using following;
num = NumberSeq::newGetNumFromCode(<<someNumberSequenceCode>>, NumberSeqScopeFactory::createDefaultScope(), true, true);
As, fourth optional parameter of NumberSeq::newGetNumFromCode(,,,true); says not to throw exception on missing reference.
boolean _dontThrowOnMissingRefSetUp = false,
As I said earlier, I have created number sequence from organization administration without writing any code (EDT, class, parameters table etc. stuff) so no reference was generated and I think I was getting exception due to this.
Please have a look at your number sequence that you have set up. I recon it has something to do with the numbersequence scope.
Make sure the scope of the number sequence is valid within the company you are calling this.
It's work, but not raice result: Voucher not generated.
Working way:
num = NumberSeq::newGetNumFromCode(<<someNumberSequenceCode>>,
NumberSeqScopeFactory::createDefaultScope(), **false**, true);
When my Number Sequence - Scope is setup as Shared I can use this code:
numSequence = NumberSeq::newGetNumFromCode(<<someNumberSequenceCode>>, NumberSeqScopeFactory::createDataAreaScope(curext()), true, true);
When my Number Sequence - Scope is setup as Company I can use this code:
numSequence = NumberSeq::newGetNumFromCode(<<someNumberSequenceCode>>);