How do I only count up every second time in my while condition?
I only know how to count up everytime like this " $c_id=++$c_id; "
you can use a variable and increment it every time in the loop and then check if the variable is even or not. if the variable is even you can use increment your variable $c_id
Related
In Google Sheets, from one sheet I am trying to lookup the game info for the next game based on a game schedule that is maintained on a second sheet. The game dates and times in the schedule are maintained in separate columns as displayed below.
For example, since it's now 11:55am on 2/14, I'm looking for a function that will return row # 8 based on the schedule below.
Game Schedule
Thank you!
You can try
=ARRAYFORMULA(TRANSPOSE(
INDEX(Schedule!A3:C15, MATCH(NOW(),Schedule!A3:A15+Schedule!B3:B15,1)+1)
))
MATCH to assume that the range A3:A16+B3:B16 is sorted in ascending order and return the largest value less than or equal to search_key NOW(). We're using ARRAYFORMULA for corect summing A3:A16+B3:B16 as row by row. The one is added to move the pointer of INDEX to the line below.
My sample sheet
B2:
=TODAY()
B3:
=INDEX(SPLIT(NOW(), " "),,2)
B4:
=INDEX(INDIRECT("Schedule!"&ADDRESS(MATCH(B2+B3, Schedule!A1:A+Schedule!B1:B, 1)+1, 3)))
I find that there are two ways to calculate the date in AutoHotKey:
Use EnvAdd, which is synonymous with var += value
Convert the date to the YYYYMMDDHH24MISS format, and calculate it as if it's a regular number, then convert back to date format
It seems that using EnvAdd is better, because it has a parameter to determine the time unit. (Using the second method may lead to unaccepted value, such as days 62 or month 20.) But since EnvAdd only changes the current value of the input variable, not assign the result to another variable, so if I want to have keep the original one, I have to do this:
a:=b
a+=10
This is counter-intuitive, because the original value is stored in a new variable, while it's more natural to expect the original value is stored in the old variable.
Is there a way to keep it more natural to read?
Do you mean something like this?
a:=b+10
I was confused. I should have used:
b := a
b += 10, months
I'm using opentsdb. I have ONE time series, with values at 10-minute intervals. I want to specify a start time and an end time, and get back a single number that is the sum of all the values in the specified time range. I tried what I thought to be correct
...start=<start>&end=<end>&m=sum...
but got back all the individual values rather than their sum.
Add the element downsample="0all-sum"; apparently, the "0all" is interpreted as "the interval containing all timestamps".
I am using R to create a variable which can increment after certain operations.
i.e., I have a variable called node and I want to write a function to increment it like node1, node2, node3..etc., each time the function is called.
Is this possible?
Please help
I would use a list in your case node <- list(). You can now use the increment to save the your value to the "position" in the list like node[[i]] <- 'my value'. Just increment i like you wanted to do with the variable name. Access the value by node[[1]] etc.
I'm setting up a dashboard in Workfront. I want to create a custom view that I'm calling "Est Variance" which, at the task level, will compare a tasks planned hours to complete (workRequired) with actual hours to complete (actualWorkRequired). In other words, we planned for 10 hours but it took 15, so the value displayed should be +50%.
The calculation is Planned Hours (minus) Actual Hours (divided by) Planned Hours. I came up with the following code for the view:
displayname=Est Variance
linkedname=direct
namekey=Est Variance
querysort=actualWork
shortview=true
textmode=true
valueexpression=ROUND(SUB({actualWorkRequired},{workRequired}))/({workRequired})*100
valuefield=actualWorkRequired
valueformat=compound
viewalias=actualworkrequired
... which returns the correct value, but I'm trying to make the following changes:
CONCAT a "%" after the value
Round to the nearest whole number
Add rules that would display any positive value in red, and any negative value in green.
For tasks returning "0" (planned hours = actual hours), display nothing.
1.) CONCAT a "%" after the value
2.) Round to the nearest whole number
Setting the valueformat=doubleAsPercentRounded will accomplish both, so simplify the valueexpression to be
valueexpression=SUB({actualWorkRequired},{workRequired})/{workRequired}
3.) Add rules that would display any positive value in red, and any negative value in green.
You can use the conditional formatting to color the results depending on their value.
i.e.
styledef.case.0.comparison.icon=false // show the value instead of the icon
styledef.case.0.comparison.leftmethod=Est Variance // column name
styledef.case.0.comparison.lefttext=Est Variance // column name
styledef.case.0.comparison.operator=lt // less than operator
styledef.case.0.comparison.operatortype=double // data type
styledef.case.0.comparison.righttext=0 // target value
styledef.case.0.comparison.trueproperty.0.name=textcolor // tranform on true
styledef.case.0.comparison.trueproperty.0.value=03a219 // green
styledef.case.0.comparison.truetext= // ignore
4.) For tasks returning "0" (planned hours = actual hours), display nothing.
Finally a simple IF statement in the valueexpression can make the value be an empty string when the result is 0
IF(condition, trueStatement, falseStatement)
valueexpression=IF({actualWorkRequired} = {workRequired}, "", SUB({actualWorkRequired},{workRequired})/{workRequired}
Good luck!