How would I round a variable in tasker?
Let's take for example %info. It is 1.4567 I would like to round it to 1.5.
I found a guide showing that there is a command: round(%info). But it doesn't work.
Use round(%your_variable_name_here)
Check do Maths
Or long way
Split %info (1.4567) using .
Section %info2 to first character after .
If %info2 is greater(or) than 5 = %info +1
If %info2 is less than 5 = do nothing
Related
Hey,
I am working on something for work and it has to do with a simple database (excel file) with data kept in rows. This data is accessed using a userform that looks up a query that happens to be the data kept in the first column of the spreadsheet. Basically, each row contains 46 cells, including the first cell (the query).
I am hoping to use the same userform to search, update, save, print and quit excel. So far search works:
Code:
Sub CommandButton1_Click()
dim query as range
set query = range("A:A")
call readData(query.find(TextBox1, lookat:=xlWhole).row)
End Sub
Private Sub readData(x as integer)
Dim boxes as range
set boxes = range("A:A")
TextBox1 = boxes.cells(x).offset(0,0)
TextBox2 = boxes.cells(x).offset(0,1)
....
End Sub
This works fine for search; however, as there is 45 boxes containing different kinds of data, I would rather read the cells from the spreadsheet using a loop and setting the TextBoxN as a static array:
Code:
Sub readData(x as integer)
***** VB treats array(45) as an array having 46 elements *****
dim textBoxArray(45) as [u]Variant[/u]
set textBoxArray = array(TextBox1, TextBox2... TextBox46)
For i = 1 to 46
textBoxArray(i-1) = cells(x, i)
Next i
End Sub
Note that "query.find(TextBox1, lookat:=xlWhole).row" returns the row number of the query and this is passed as an integer to the readData sub-routine and is referred to as "x".
I would like to do this for the read and then do the same, although opposite for the update (i guess I could call it the 'write' back to the excel worksheet).
The problem is, with this code I get an error that says the array is not declared or arranged (Japanese laptop: 配列は割り当てられません。)
Question 1
Any of you developers with any vb experience know how I can correctly declare my array (would be nice if I could decare the array globally so that I don't have to re-declare it for every sub-routine, and I can just use the for loop in each sub-routine)?
At present, all the code is within the userform and I cannot seem to declare outside of a subroutine:
Code:
Public boxArray(45) as Variant
Sub CommandButton_Click()
...
End Sub
Question 2 SOLVED I removed the "set" from the line where I filled the array with each textbox. Tested it again and all data is flowing correctly. Only need question 1 answered.
Thank you.
Hey all, thanks for the replies; I didn't think the thread would be this popular.
I solved the problem with global variables. Instead of setting a fixed array size in the main code section dec area, I found another way of assigning values to all 46 textboxes.
Instead of:
Code:
Dim boxArray(45) as Variant
boxArray(45) = array(TextBox1, TextBox2, ... TextBox46)
then
Code:
For i = 1 to 46
boxArray(i-1) = cells(x,i)
Next i
I used vb's Control method/function (no array necessary):
Code:
For i = 1 to 46
Control("TextBox" + CStr(i)) = cells(x,i)
Next i
So i turned 46+ lines into 6+ lines into 3 lines.
MODS, this thread may be closed. THanks.
so I'm making a time table that changes the unit background color based on the present time like collage class timer thingy
and i want to know how to get the time from the phone and compare it to the user input
do i have to force the user to save the time column ?
how do i call the time function
Doshaa said:
so I'm making a time table that changes the unit background color based on the present time like collage class timer thingy
and i want to know how to get the time from the phone and compare it to the user input
do i have to force the user to save the time column ?
how do i call the time function
Click to expand...
Click to collapse
There are many ways of doing this. You can do below:
Code:
//declare the format as final:
final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm");
//Then get the current time in string format:
String time = dateFormat.format(new Date());
Hey Ara! Thanks for tackling this series. I know that AC ranges from 101 articles, to device rumor mill articles, to tasker tutorial type articles, and based on comparing the comments of the full spectrum of articles, it looks like the tasker crowd might not be as large as some of the other crowds that read and are interested in ACs other stories, so... props to ya for taking on the giant.
I've been using tasker since I had the OG Droid and have loved its functionality. Lately though, I've been stumped on one thing in some of my tasker profiles that I just can't seem to nail down. It's a function that you may or may not be familiar with unless you've done other types of programming, specifically logic programming like ladder logic (PLC). I'm looking for an ON DELAY TIMER, not just a timer that begins and continues counting when a series of contexts (permissives) is activated, but a timer that will ONLY count while the contexts are true, and will stop counting AND RESET when at least one of the contexts isn't true. This way, if you want something to happen 5 minutes after your screen is on and your screen hasn't shut off into sleep mode, it will execute a task, but if for some reason the screen does shut off before 5 minutes, it will not execute the task and will begin counting from 0 sec the next time the screen turns on. I've tried to make custom ON DELAY TIMERS with variables and other methods, but my profiles just don't work the same as if there were just a simple ON DELAY TIMER task built in (Currently with variables, I can only start a timer based on contexts, and then check in an amount of time to see if the contexts are still true at the end of the timer, but nothing to stop the profile if a context goes false during the timing... so with my screen example, tasker can't tell the difference between the screen turning on for a minute, off for 3 minutes and on for 2 minutes and the screen being on for 6 minutes straight.). Anyway, if you, or anyone reading this stupid long comment, knows where to find this ON DELAY TIMER, or how to create one in tasker, please spread the wealth! Thanks!
Phone number Search
You can accomplish this but it will eat some RAM.
Have contexts trigger delay timer task.
In delay timer :
1 add variable, say %timer and add 1.
2 wait 1 second
3 stop task if criteria are not met.
4 goto step 1 (variable add) if %timer < set number.
5 whatever action you want triggered when counter reaches end
You can add some steps before the #1 listed for a dialog, spinner, etc if you want user to set new time each use.
Hope this helps.
Zac
Not sure if this is the right forum for this question, sorry if it isn't.
I'm trying to calculate a time in the future, by adding some value to %TIMES. I'm adding 24 hours max. For some reason, the variable I'm storing the result in, ends up like this: 1.515....E9. Normally, this wouldn't be an issue, but for some reason, not a single application in Tasker seems to be able to handle this scientific notation, so I'm stuck with a useless number. Is there a way I can prevent Tasker from writing this number in this notation, or is there a way to convert it to a regular number?
Tim
The %TIMES variable is the current time in seconds since January 1, 1970. A very big number.
Typically time values are manipulated by doing a "variable convert" action.
Could you post your task DESCRIPTION here? Long press the task to select it -> 3-dot menu -> export -> description to clipboard.
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
I'm currently doing this through Variable Set. It's been a long time since I used tasker (set once and forget, right), so it's probably something dumb I'm doing wrong.
Here's the description (and thank you for providing instructions on how to do it):
Update Times (25)
A1: AutoAlarm [ Configuration:No configuration needed Timeout (Seconds):5 ]
A2: Variable Set [ Name:%minsBefore To:20 Recurse Variablesff Do Mathsff Appendff ]
A3: Variable Set [ Name:%preAlarmTime To:%TIMES+%seconds-(%minsBefore*60) Recurse Variablesff Do Mathsn Appendff ]
A4: Variable Set [ Name:%dismissNotification_preAlarmTime To:%TIMES+%seconds-(120*60) Recurse Variablesff Do Mathsn Appendff ]
A5: Variable Convert [ Name:%preAlarmTime Function:Seconds to Date Time Store Result In:%readable_preAlarmTime ]
Click to expand...
Click to collapse
Some notes:
I know A2 is weird and useless currently, it's a placeholder for something I'm gonna add later.
Action A4 is also irrelevant at the moment, again a placeholder for later.
Action A5 throws an error, due to %minsBefore being stored in scientific notation (I'm assuming, see error below)
15.17.29/Variables doreplresult: |%preAlarmTime| -> |1.51539179987E9|
15.17.29/E Variable Convert: %preAlarmTime -> %preAlarmTime
15.17.29/E Variable Convert: %readable_preAlarmTime -> %readable_preAlarmTime
15.17.29/E Variable Convert: %preAlarmTime: failed.
15.17.29/E result: stop task (error)
15.17.29/Variables doreplresult: |%preAlarmTime| -> |1.51539179987E9|
15.17.29/Variables doreplresult: |%readable_preAlarmTime| -> |08:15|
15.17.29/E Error: 1
15.17.29/MacroEdit action finished exeID 1 action no 4 code 596 status: Err next 4
Click to expand...
Click to collapse
In A3, try using the round function on the seconds variable;
%TIMES+round(%seconds)-(%minsBefore*60)
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
ktmom said:
In A3, try using the round function on the seconds variable;
%TIMES+round(%seconds)-(%minsBefore*60)
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
Click to expand...
Click to collapse
I'm almost beyond belief.. That fixed it instantly, brilliant catch, thank you!
A tiny addition, for anyone else who might face this later:
Using round on just %seconds gave me an incorrect time later on, in conversions (one minute too early). I fixed this by using round on (%seconds-(%minsBefore*60)), which fixed it.
The other, probably better, solution would be to go into the AutoAlarm settings and set the decimal point setting to 0. The round() was my quick way to get to that [emoji56]
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
ktmom said:
The other, probably better, solution would be to go into the AutoAlarm settings and set the decimal point setting to 0. The round() was my quick way to get to that [emoji56]
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
Click to expand...
Click to collapse
That indeed also fixes it. I did notice the extra numbers, making for milliseconds, I should've realized that such a setting would be available in this kind of app, lol. Thanks again!
Hi,
I have an issue with Tasker on my Oreo car stereo.
With Tasker I am not able to adjust the screen brightness:
Code:
Profile: Night (7)
State: Twilight [ Configuration:From CIVIL DUSK to CIVIL DAWN at Device location. ]
Enter: Dimmer ON (5)
Stay Awake
A1: Display Brightness [ Level:0 Disable Safeguard:eek:n Ignore Current Level:eek:ff Immediate Effect:eek:ff ]
A2: Set Tasker Icon [ Icon:mw_action_bookmark_border ]
Exit: Dimmer OFF (6)
A1: Display Brightness [ Level:255 Disable Safeguard:eek:n Ignore Current Level:eek:ff Immediate Effect:eek:ff ]
A2: Set Tasker Icon [ Icon:mw_action_bookmark ]
Even the manual executing of the task it doesn´t change the brightness.
Any hints how to get this working?
I used exactly this task on earlier radio with Android 7 and it is still working fine on my Phone with Android 7.
I think the behavior is related to Andoid 8, could that be possible?
Is adaptive brightness turned off?
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
ktmom said:
Is adaptive brightness turned off?
Click to expand...
Click to collapse
Yes it is turned off in the Android settings, to not use the head lights.
Even if I switch off adaptive brightness in the task it doesn´t do anything.
The unit itself has no light sensor, so I need something which dims the screen brightness independant of the head lights.
rigattoni said:
Hi,
I have an issue with Tasker on my Oreo car stereo.
With Tasker I am not able to adjust the screen brightness:
Code:
Profile: Night (7)
State: Twilight [ Configuration:From CIVIL DUSK to CIVIL DAWN at Device location. ]
Enter: Dimmer ON (5)
Stay Awake
A1: Display Brightness [ Level:0 Disable Safeguard:eek:n Ignore Current Level:eek:ff Immediate Effect:eek:ff ]
A2: Set Tasker Icon [ Icon:mw_action_bookmark_border ]
Exit: Dimmer OFF (6)
A1: Display Brightness [ Level:255 Disable Safeguard:eek:n Ignore Current Level:eek:ff Immediate Effect:eek:ff ]
A2: Set Tasker Icon [ Icon:mw_action_bookmark ]
Even the manual executing of the task it doesn´t change the brightness.
Any hints how to get this working?
I used exactly this task on earlier radio with Android 7 and it is still working fine on my Phone with Android 7.
I think the behavior is related to Andoid 8, could that be possible?
Click to expand...
Click to collapse
Hi Mate.
I have exactly the same problem. Did you get a solution?
I have a Xtrons Android 8 unit and brightness does not work , exactly like you explained.
Did you get a solution?
Hi,
there will be no solution until they use the Adroid_API as it should be.
Tasker uses the API, but the dev of our version seems to use different folder structures.
If I have a look at the traces I find the following entry:
Code:
05-07 13:45:54.415 292 292 E Lights Hal: write_int failed to open /sys/class/backlight/rk28_bl/brightness
/sys/class/backlight/rk28_bl/brightness would be the correct folder used by the API.
The reason for this issue is, that the folder rk28_bl does not exist. The file "brightness" is stored in folder:
/sys/class/backlight/backlight/brightness
I´m thinking about a method to get a workaround for this issue, but I don´t have the needed time to do it in the moment.
Hello,
I have the same issue. Did you find how to fix this?
alek_05 said:
Hello,
I have the same issue. Did you find how to fix this?
Click to expand...
Click to collapse
I got a new firmware for my Pumpkin and use FCC car launcher, which is able to do it.
rigattoni said:
Hi,
there will be no solution until they use the Adroid_API as it should be.
Tasker uses the API, but the dev of our version seems to use different folder structures.
If I have a look at the traces I find the following entry:
/sys/class/backlight/rk28_bl/brightness would be the correct folder used by the API.
The reason for this issue is, that the folder rk28_bl does not exist. The file "brightness" is stored in folder:
/sys/class/backlight/backlight/brightness
I´m thinking about a method to get a workaround for this issue, but I don´t have the needed time to do it in the moment.
Click to expand...
Click to collapse
Try this, run shell with tasker :
settings put system screen_brightness=216
value : 0 to 216
philippe734 said:
Try this, run shell with tasker :
settings put system screen_brightness=216
value : 0 to 216
Click to expand...
Click to collapse
No that can not work... and it does not work with OREO head units... at least not with mine.