Hello
I’m trying to overwrite an array value. The array containing the values that need to be changed is %ObdFuelAvgArr the index of the value I’m trying to set is %ObdPlaceHolder and the value that I’m trying to insert is %ObdPercent. I’ve tried various ways of entering this into tasker. The latest iteration was this:
Code:
Variable Array
%ObdFuelAvgArr(%ObdPlaceHolder)
Values
ObdPercent
Could someone help me find a solution?
Thanks,
Loren
You need to Use the Array Push action probably in conjunction with the Fill Spaces parameter. Depending on whether the array element is already occupied, you may need to empty it before updating using a Variable Clear.
From the Tasker user guide: variables page;
Inserting Elements
Use the Array Push action.
The Fill Spaces parameter might need more explanation. It is only relevant if one or more of the array elements are undefined. As an example, if we have the array elements %arr1 and %arr3 containing apple and banana:
Array Push %arr1, 1, pear
leaves %arr1, %arr2 and %arr4 containing pear, apple and banana.
but Array Push %arr2, 1, pear, Fill Spaces
leaves %arr1, %arr2 and %arr3 containing pear, apple and banana.
Removing Elements
Use the Array Pop action. Note the difference between Array Pop and Variable Clear: Pop reduces the number of elements in the array, while Clear merely changes elements to undefined.
Example: if we have the array elements %arr1, %arr2, %arr3 containing apple,pear and banana:
Variable Clear %arr2
leaves %arr1 and %arr3 containing apple and banana.
but Array Pop %arr2
leaves %arr1 and %arr2 containing apple and banana.
Click to expand...
Click to collapse
"Good judgment comes from experience, and a lot of that comes from bad judgment." - Will Rogers
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.
Fir example:
app://80C8133B-168C-48C7-B95F-08D6331AE891/_default#/Microsoft.Mcx.Mobile.UpdaterShell;component/Views/AdminView.xaml
What's the structure of this URI?
"app://" - URI scheme, tells the OS how to handle the request (app launcher).
"80C...891" - App's ProductID GUID. Unique for every app (but does not change on updates). Identifies the app in question.
"/_default" - Use the app's normal launch task (as opposed to a launch task for a live tile or something).
"#" - URI fragment indicator, specifies where within the app to navigate to.
"Microsoft.Mcx.Mobile.UpdaterShell" - Name of the assembly containing the desired XAML file (the specification method is WP standard for embedded resources).
";" - Separator between the assembly and the path within the assembly; standard in WP.
"component/Views/" - Path to the embedded XAML view that you want to open (also WP standard format for embedded resources).
"AdminView.xaml" - the name of the (embedded) XAML file that you want to open.
Hope that helps.
I am trying to section the whole array using FOR action, but it's not working. I've read all the available guides on this and it should be working but it's not. I would be greatful if you could spot an error in my logic.
I have created an array, using variable split. It's called %Testor and it consists of three variables:
%Testor1 - ABCD
%Testor2 - EFGH
%Testor3 - IJKL
Then I used FOR action where I specified Variable: %item and Items: %Testor()
Then, within the FOR action I created a Section action with Name: %item, From: 1 and Length: 2. I closed the FOR action with END FOR.
Despite doing the above the %Testor1, %Testor2 and %Testor3 variables are still, respectively, ABCD, EFGH and IJKL.
Can you maybe spot what am I doing wrong? Thanks in advance!
First, let’s come to terms with… the terms in Tasker. Many of the concepts may be new to you, and they can be a bit overwhelming, especially to neophytes. But, once you get the logic of Tasker, you’ll find that it’s a truly powerful app even for programming noobs.
Action — The basic element of Tasker. It refers to phone or tablet functions and features that perform something or brings the phone to a certain state. Tasker supports more than 200 actions grouped into 21 categories.
Task — A group of actions. Usually linked to a trigger or “context”, but can also be a free-floating, standalone task executed manually. A task can be run within another task. You can clone, export, import, and lock tasks.
Context — Situations or conditions which, when true, trigger the execution of the task(s) associated with it.
Profile — Some sort of “container” or “package” for context(s) and linked task(s). You can define several contexts for a single profile, and all those conditions must be true for the linked tasks to run.
Variable — A name for an unknown value that can change over time, like the battery level or the date.
Scene — A custom-made user interface. You can create your own layout of buttons, menus, popups, and other UI elements.
Project — A group of profiles, tasks, scenes, and variables. Each project has its own tab (at the bottom of the main screen) with a user-defined project name. You can also export or import projects. You can even export a custom project as a standalone Android app (APK): just tap on the project name/icon, select Export, and choose “As App.”
Is it possible to call a Javascript function that exists within a WebView from Tasker? I tried calling a URL on the WebView of "javascript:FUNCTION_NAME()", but that did not seem to work.
This is a completely random example. Lets say, from Tasker, that I want to be able to change the background color of the body of the WebView.
In the webview, I have the code
JavaScript:
function ChangeBGColor(NewColor)
{
document.body.style.backgroundColor=NewColor;
}
I want to be able to call ChangeBGColor() from Tasker with a color.
I remember having this same question a while back and was unable to find a solution that didn't involve sending HTTP requests, so I came up with a really weird hacky solution. I'm not sure its going to work for your situation, but maybe it can give you some ideas.
On the web side- have a transparent div element that occupies a single pixel. Put it in a corner or somewhere you won't accidently touch it. Now, add an event listener to it like this:
element.addEventListener('touchend', (e)=> {
let x = e.changedTouches[0].clientX;
let y = e.changedTouches[0].clientY;
renderColor(x, y);
});
On the Tasker side- If you don't already have it, download AutoInput, which is plugin that was created by Joao Diaz before he took over development of Tasker, and its incredibly cheap for what it does. You can use it to simulate a swipe gesture that starts at that exact spot on the screen, and ends at the coordinates you specify. You now have a way to send two values from tasker to you Javascript with a possible range of your screen resolution.
This might be challenging if you want the full spectrum of colors, because ideally you would want 3 parameters with 256 possibe values (0 for 00 and 256 for FF), so you'll have to figure out a way to encode and decode your color. You could either dumb down the resolution of colors and then use some math involving the modulus operator, but a better way would be to send the data via two swipe gestures, which would give you 4 parameters to work with- so to send white with full opacity (FFFFFFFF), simulate a swipe starting at 0,0 and ending at 256, 256 (FF or 256 for your alpha value, and the same for red), have your Javascript function store that in a variable. Then, send the second swipe which in this case will be the same as the first, and you now have 4 values to give you your color. Keep in mind you'll want to offset everything by 1 or you wouldn't be able to send black, since swiping from 0,0 to 0,0 won't trigger anything.