variable: remove last 3 characters - Tasker Tips & Tricks

Hello.
I want to remove the last 3 characters of a variable.
Was thinking of
A1. Test Variable: %variable
Type: Length
Store Result In: %length
A2. Variable Subtract: %length Value: 3
But then in Variable Section I don't find a way for saying that I want the character from 1 to %length of %variable (in Length seems I can only set a number).
How can I do it?
Thanks.

Also in Variable Subtract action would be useful to have the Value given by a variable, but I can't see it neither

Found out: it was being in Beginner mode.
Unchecked that I can use a varibale both in Variable Subtract and in Variable Section

Related

[Q] Using variables between packages

I am hooking into 2 different packages in my handleLoadPackage and I have a private static variable in the enclosing class. When handleLoadPackage gets called for the first package, I set the private static variable and log it and it looks fine. When handleLoadPackage gets called for the second package, I try to log the private static variable and it's not set. This is directly in handleLoadPackage and not inside any hooks. Is what I'm trying to do not possible because of the calling contexts? How do I share information between hooked functions between multiple packages?
The problem is that you basically have two different variables, not one — a different one for each package. When you update the variable in package A, the variable in package B is untouched.
You'll need to communicate between the two packages somehow, using e..g a BroadcastReceiver.
GermainZ said:
The problem is that you basically have two different variables, not one — a different one for each package. When you update the variable in package A, the variable in package B is untouched.
You'll need to communicate between the two packages somehow, using e..g a BroadcastReceiver.
Click to expand...
Click to collapse
Thanks. After I posted this and thought about it for a while I came to this conclusion. Each package runs in it's own address space and the handleLoadPackage runs in it's context.

[Q][Dev] Module static fields and handleLoadPackage

Hello,
I've found myself in a situation I can't solve myself, so I hope I can find some help here
In my module, I've got a static field "VERSION_CODE".
In one of my hooks I register a BroadcastReceiver for AfterBootCompleted in which I set the field's value (I use the system Context object).
Then, in handleLoadPackage, when I try to read the field "VERSION_CODE", it has it's default value.
I don't understand this. Are there separate JVMs or something? How do I make that field absolutely global?
If it's a final field (constant) of primitive type (int, boolean, etc.) you won't be able to change it since compiler doesn't use variable but inlines value directly everywhere it's used.
C3C076 said:
If it's a final field (constant) of primitive type (int, boolean, etc.) you won't be able to change it since compiler doesn't use variable but inlines value directly everywhere it's used.
Click to expand...
Click to collapse
It isn't declared final.

Help with comparing variables

This is probably simple for a programmer, but as a newb, I am getting stuck.
I have 2 variables and I want to check if the first is contained in the second
so, %event = Phone and %check = WorkPhoneReport
I have tried :
*%event* ~ %check
*%event* ~R %check
*%event\* ~ %check
And several other similar patterns. What to do to get this test working?
I am trying to read my calendar and not process the same event a second time. So, each item it reads is appended to another variable, then on its next loop, it compares the new event to the check variable to see if it was processed already. Don't know if I should be using an array instead of a variable, and if I can use an array in a if/then statement....
Any help is appreciated!!
Figured out a way.
Variable Search and Replace:
Variable %check Search %event store in %matches
then in the if statement just check if %matches is set.
If there's a simpler way, please let me know, this task is at 50 commands, never hurts to shorten it.
Code:
%check ~R .*%event.*
In Regex format, dot (.) can be any character including having no character there, and star (*) means repeat previous character as much as possible.
So .* means "look for no character or any number of any characters", and .*%event.* means "look for %event with something or nothing before it, and something or nothing after it"

How to get only time from datetime

Hi,
im using a tasker plugin that generates at one point a variable of datetime in seconds...
i can convert it to datetime for example 4-17-17 01,30 ...
but then i need to extract the time only to use it somewhere else...
the problem is, i can not use variable section because the position of time changes... in december it will be 12-17-17 01,30
so... what is the way to extract the time only?
Thanks
Variable split.
Leave the splitter empty. It defaults to space (" ")

[GUIDE][Difficulty: Beginner] Automatically check for Kernel or Rom Updates on XDA

Hello together,
this is a little, yet, in my opinion, useful profile(s) to check for Kernel or Rom Updates on XDA (or any other web page).
The profile is set-up easily and doesn't need much effort or experience to achieve the desired automatic updater. Some values can be adjusted to your liking, but more about that in the following text.
Without further ado:
Kernel/Rom Update Profile(s)
1. Tasker Profile
Name it "Rom (or Kernel) Update". Trigger: "Time" From 08:00 every 2h til 22:00 [values adjustable]
1.1 Tasks
Add Task under "Network" called "HTTP Get"
Serverort: [copy/paste the URL of the site of the Kernel/Rom]
Timeout: 30
Mime Type: text/html
1.2. Variable Split
Name: %HTTPD
Splitter: for example "[ROM]". Whatever the value before the Kernel/Rom version number might be. In my example the thread title is: "[KERNEL] CleanSlate Kernel v1.7.7 [Wireguard][LED]..." the Splitter would be [KERNEL]
1.3 Variable Split
Name: % HTTPD2
Splitter: in this example "[Wireguard] or whatever stands behind the Kernel/Rom version number
1.4 Notify
Title: Rom(Kernel) Update available! [text adjustable]
Text: %HTTPD21
Search for an update look-alike icon for this notification
If: %HTTPD21 !~ %ROM (If your profile is for a Rom take this. If your profile is for a kernel replace the variable %ROM with %KERNEL)
1.5 Variable Set
Name: %ROM (For Rom) / %KERNEL (for Kernel)
To: %HTTPD21
And that's it! Tasker will now check for updates as often as you set the repetition in the profile trigger (e.g. every 2 hours).
Note: Let the Task run once for the variables to set up. If everything worked you will have a notification in your notification area, because %ROM/%KERNEL at the moment missmatches %HTTPD21. Clear that notificaion and then you're good to go.
But that's not about it. Additionally I have set up a hyperlink to the notification, which will take you to the Kernel/Rom Thread. I'll show you in Step 2, but that's only additionally.
Step 2 - Notification link
2. Create a 2nd profile. Trigger: Clicked notification.
Application owner: Tasker
Title: In this example "Rom(Kernel) Update available!" or whatever is the title of your tasker notification in step 1.4
2.1 Task "Call URL"
URL: [The URL of the Kernel/ROM] (Same like in 1.1)
Done! If you now click on the update notifcation you will be taken to the URL of your Kernel or ROM
Feel free to share and ask questions, if something still remained unclear. I tried to format and explain as best as I can
Follow_and_Feel said:
Serverort: [copy/paste the URL of the site of the Kernel/Rom]
Timeout: 30
Mime Type: text/html
Click to expand...
Click to collapse
For 1.1, for the task Action, which should it be? I assume that the app has changed some things since you posted this, but I'm assuming the Action Category should be Net? And if this is correct, which Net category should it be?
This would be an incredibly useful task! Thank you so much!
JKforUA said:
For 1.1, for the task Action, which should it be? I assume that the app has changed some things since you posted this, but I'm assuming the Action Category should be Net? And if this is correct, which Net category should it be?
This would be an incredibly useful task! Thank you so much!
Click to expand...
Click to collapse
Hey there. No it hasn't changed at all. You need to go into the "Tasks" section to add a task and name it to your liking. Then click the little "+" sign at the bottom right and then it's under "network" --> "HTTP Get". Still the same as always. Hope I could help
EDIT: But I see now what you mean! I forgot to mention which task it is. Already edited, thank you
Follow_and_Feel said:
Hey there. No it hasn't changed at all. You need to go into the "Tasks" section to add a task and name it to your liking. Then click the little "+" sign at the bottom right and then it's under "network" --> "HTTP Get". Still the same as always. Hope I could help
EDIT: But I see now what you mean! I forgot to mention which task it is. Already edited, thank you
Click to expand...
Click to collapse
Haha, yeah, that's what I was confused about. I'm a newb when it comes to Tasker, so I was wondering if I somehow was just missing something haha. Thanks so much!
JKforUA said:
Haha, yeah, that's what I was confused about. I'm a newb when it comes to Tasker, so I was wondering if I somehow was just missing something haha. Thanks so much!
Click to expand...
Click to collapse
No problem buddy. Totally goes on me If you need any further assistance don't hesitate to ask
Follow_and_Feel said:
No problem buddy. Totally goes on me If you need any further assistance don't hesitate to ask
Click to expand...
Click to collapse
Well, if I had a little more experience with Tasker, I would have known what you meant to begin with, but thanks!
ONE more question... for the Variable Split in 1.2 and 1.3. I'm wanting to set this up to get updates for the Nitrogen ROM for the Pixel 2 XL ( https://forum.xda-developers.com/pi...m-nitrogen-os-oreo-substratum-12-feb-t3748293 ). The thread title is:
[ROM] ► [8.1.0_r40] ► [taimen] ► Nitrogen OS Oreo ► Substratum ► (04.July.2018)
Would the splitter for 1.2 be [ROM] and the splitter for 1.3 be [taimen]? Thanks so much for any help!!
Most Tasker profiles/tasks I've seen aren't really that useful for me since most of the things are already included in one way or another with the Pixel 2 or other apps, but this one would be so useful to have! Genius, man.
JKforUA said:
Well, if I had a little more experience with Tasker, I would have known what you meant to begin with, but thanks!
ONE more question... for the Variable Split in 1.2 and 1.3. I'm wanting to set this up to get updates for the Nitrogen ROM for the Pixel 2 XL ( https://forum.xda-developers.com/pi...m-nitrogen-os-oreo-substratum-12-feb-t3748293 ). The thread title is:
[ROM] ► [8.1.0_r40] ► [taimen] ► Nitrogen OS Oreo ► Substratum ► (04.July.2018)
Would the splitter for 1.2 be [ROM] and the splitter for 1.3 be [taimen]? Thanks so much for any help!!
Most Tasker profiles/tasks I've seen aren't really that useful for me since most of the things are already included in one way or another with the Pixel 2 or other apps, but this one would be so useful to have! Genius, man.
Click to expand...
Click to collapse
Sorry for the delay, was a little busy. So: Yes. That would be the splitters for your specific ROM :highfive:
Follow_and_Feel said:
Sorry for the delay, was a little busy. So: Yes. That would be the splitters for your specific ROM :highfive:
Click to expand...
Click to collapse
No worries about the 'delay'. I wasn't expecting an answer for a while since it is during work hours lol. Thank you so much!!!!!
JKforUA said:
No worries about the 'delay'. I wasn't expecting an answer for a while since it is during work hours lol. Thank you so much!!!!!
Click to expand...
Click to collapse
Over here it's 22.42 so I'm not working atm anyway hehe If you wish to speed things up a little we could have a private conversation and I'll help you personally with setting it up (having in mind, that you're new to tasker) or, if you have Telegram, have a chat over there But only if you don't wanna try yourself
Follow_and_Feel said:
Over here it's 22.42 so I'm not working atm anyway hehe If you wish to speed things up a little we could have a private conversation and I'll help you personally with setting it up (having in mind, that you're new to tasker) or, if you have Telegram, have a chat over there But only if you don't wanna try yourself
Click to expand...
Click to collapse
I'm a software engineer, so I'm not exactly an amateur with stuff like this lol, but there does seem to be a learning curve with Tasker. Thanks for helping everybody out. I will just post what I got from the 'Description in Email' function, and if you don't mind, you could just glance over it to make sure I've got everything correct. I'll post this in public so that it might help somebody else trying to learn how to do this. I used different values for when to make checks to see if there is an update. Otherwise, I left everything as default except for the specific values you say to add/change in each action (a little hard to test since I don't know when there will be another update for the Nitrogen ROM):
Profile: ROM update (3)
Time: 11:08AM
Enter: Anon (6)
A1: HTTP Get [ Serverort:https://forum.xda-developers.com/pi...m-nitrogen-os-oreo-substratum-12-feb-t3748293 Path: Attributes: Cookies: User Agent: Timeout:10 Mime Type:text/html Output File: Trust Any Certificateff ]
A2: Variable Split [ Name:%HTTPD Splitter:[ROM] Delete Baseff ]
A3: Variable Split [ Name:%HTTPD2 Splitter:[taimen] Delete Baseff ]
A4: Notify [ Title:ROM Update For Nitrogen Available Text:%HTTPD21 Icon:cust_star Number:0 Permanentff Priority:3 ] If [ %HTTPD21 !~ %ROM ]
A5: Variable Set [ Name:%ROM To:%HTTPD21 Recurse Variablesff Do Mathsff Appendff ]
JKforUA said:
I'm a software engineer, so I'm not exactly an amateur with stuff like this lol, but there does seem to be a learning curve with Tasker. Thanks for helping everybody out. I will just post what I got from the 'Description in Email' function, and if you don't mind, you could just glance over it to make sure I've got everything correct. I'll post this in public so that it might help somebody else trying to learn how to do this. I used different values for when to make checks to see if there is an update. Otherwise, I left everything as default except for the specific values you say to add/change in each action (a little hard to test since I don't know when there will be another update for the Nitrogen ROM):
Profile: ROM update (3)
Time: 11:08AM
Enter: Anon (6)
A1: HTTP Get [ Serverort:https://forum.xda-developers.com/pi...m-nitrogen-os-oreo-substratum-12-feb-t3748293 Path: Attributes: Cookies: User Agent: Timeout:10 Mime Type:text/html Output File: Trust Any Certificateff ]
A2: Variable Split [ Name:%HTTPD Splitter:[ROM] Delete Baseff ]
A3: Variable Split [ Name:%HTTPD2 Splitter:[taimen] Delete Baseff ]
A4: Notify [ Title:ROM Update For Nitrogen Available Text:%HTTPD21 Icon:cust_star Number:0 Permanentff Priority:3 ] If [ %HTTPD21 !~ %ROM ]
A5: Variable Set [ Name:%ROM To:%HTTPD21 Recurse Variablesff Do Mathsff Appendff ]
Click to expand...
Click to collapse
Okay no problem. I think I can't fully follow you atm. What do you mean by "Description in Email" function? Is this a tasker function? Anyways here's what I can tell so far about:
A1: Leave everything blank except MimeTYPE, Timout (10-30 scnds) and, of course, the link to the ROM.
A2/A3: No deleting bases here. No, sit!
A4: Seems fine at first glance
A5: Not a recursive variable, not mathematic. Just stay straight to the description in the OP.
That's what I can tell so far, even though I don't quite know what you've done, since there's a lot of s in it
And one important hint:
You can test your profile (and therefore "fake" that there is a new update) if you set "HTTPD21" in the variable section of your task to any other value. If things work with your profiles there will be an android notification. If not there definately is something messed up. And secondly: Did you run the task once? I mean the entire task "1." from the op? As I stated in red letters you have to run it once in order to make it work, since variables will only be set after the task has run once. Hope this helps in any way and yes. First things with tasker are pretty complicated, that's, I guess, how everybody new to this app feels when coming in touch with it Cheers!
@JKforUA As I just checked the source code for your ROM:
Try splitters "658; [" for the first splitter and "] &#96" for the 2nd. This should soak in the ROM version perfectly
Follow_and_Feel said:
@JKforUA As I just checked the source code for your ROM:
Try splitters "658; [" for the first splitter and "] &#96" for the 2nd. This should soak in the ROM version perfectly
Click to expand...
Click to collapse
As for what I was talking about with the "Description by Email" function, this is what I was talking about: In the 'Profiles' screen, if you long press on one of the profiles and then press the 3 dots in the top right hand corner, there is an 'Export' option where you can get a copy of the profile/task in "Description" or "XML" format. What I copied/pasted was the "Description" of the profile. For A1, it just printed out every option given (but I didn't set anything other than what you say in the OP). A2 and A3, I don't have 'Delete Base' selected, but I guess the export still printed out the parameters. Don't worry lol. Likewise with A5. Surely there is a better way to export or copy a profile/task that will leave out all of the parameters that aren't set to anything. I'll look into that later tonight...
I just tried this with the two splitters you suggested and this is the error I got on my 3rd task (the second splitter). I'll have to wait until I'm home in a little bit to look into this. Looks like HTTPD2 isn't getting set, but I'll check it out in a little bit.:
16.58.50/Variables doreplresult: |%HTTPD2| -> |%HTTPD2|
16.58.50/E Variable Split: %HTTPD2 -> %HTTPD2
16.58.50/Variables doreplresult: |%HTTPD2| -> |%HTTPD2|
16.58.50/E Variable Split: can't split unset value to set %HTTPD2
16.58.50/E result: stop task (error)
16.58.50/Variables doreplresult: |%HTTPD2| -> |%HTTPD2|
16.58.50/E Error: 1
16.58.50/MacroEdit action finished exeID 1 action no 2 code 590 status: Err next 2
Thank you so much for 'holding my hand' through this lol. I'm learning a lot from this.
JKforUA said:
As for what I was talking about with the "Description by Email" function, this is what I was talking about: In the 'Profiles' screen, if you long press on one of the profiles and then press the 3 dots in the top right hand corner, there is an 'Export' option where you can get a copy of the profile/task in "Description" or "XML" format. What I copied/pasted was the "Description" of the profile. For A1, it just printed out every option given (but I didn't set anything other than what you say in the OP). A2 and A3, I don't have 'Delete Base' selected, but I guess the export still printed out the parameters. Don't worry lol. Likewise with A5. Surely there is a better way to export or copy a profile/task that will leave out all of the parameters that aren't set to anything. I'll look into that later tonight...
I just tried this with the two splitters you suggested and this is the error I got on my 3rd task (the second splitter). I'll have to wait until I'm home in a little bit to look into this. Looks like HTTPD2 isn't getting set, but I'll check it out in a little bit.:
16.58.50/Variables doreplresult: |%HTTPD2| -> |%HTTPD2|
16.58.50/E Variable Split: %HTTPD2 -> %HTTPD2
16.58.50/Variables doreplresult: |%HTTPD2| -> |%HTTPD2|
16.58.50/E Variable Split: can't split unset value to set %HTTPD2
16.58.50/E result: stop task (error)
16.58.50/Variables doreplresult: |%HTTPD2| -> |%HTTPD2|
16.58.50/E Error: 1
16.58.50/MacroEdit action finished exeID 1 action no 2 code 590 status: Err next 2
Thank you so much for 'holding my hand' through this lol. I'm learning a lot from this.
Click to expand...
Click to collapse
I'm with you mate So, what came to my mind when reading your reply is: In the OP, this is all ONE big task and you should have bullet points 1.1-1.5 in a single task, in a single profile (which would be "1." - Repeat from xx - til xx). That's not what might cause the problems, since the variables are global, but it's for the aesthetics (If I'm right with the several tasks).
Besides that I really think some screenshots could be of tremendous help, since it's hard to comprehend what causes the errors, if I don't see exactly how you've set it up. To get to the root of the problem I suggest you send me 3 screenshots next:
1. Overview of the profile(s)
2. The task itself in overview. However you named the task: Click on it and then take a screenshot
3. Most important for me to comprehend: Overview of the variables. This is in the variable section either on tasker's home screen or in this "Check for ROM/KERNEL update" tab. If I can see how the variables are stored in combination with the other 2 shots I might figure out problems pretty quickly.
Do that and I'm sure we'll get this straight
P.S.: Don't panic if I suddenly won't reply anymore. It's past midnight here and I might have fallen asleep, but I'll get back to you tomorrow
Guide
Thanks
Hi all,
Thx a lot for this great idea, I can follow the kernel version. [emoji106]
For the Rom, it's different, because the thread title doesn't contain the version number.
Title is "ResurrectionRemix ROM 6.1.0 - Official Weeklies- 8.1.0 by*alex9yust" ( https://forum.xda-developers.com/redmi-note-3/development/rom-resurrectionremix-5-8-0-t3507433 )
An idea could be to check the name of last file on the Rom page (https://sourceforge.net/projects/resurrectionremix-oreo/files/kenzo/), but I don't know if it's possible.
Do you have another idea ?

Categories

Resources