How do I use a global variable in a JavaScriptlet? - Tasker Tips & Tricks

Okay, I'm trying to make parse a json file with a JavaScriplet.
I'm going through and pulling out data based on if a specific data set of the json matches a specific word in an array.
For example,
var arr = parsed data
For i = 0 to end
If arr.data.wall.color = "Red" var wallname = arr.data.wall.name
So if I do it like that, it works great. But I want to be able to put a variable in there. If I do this, it works:
var colorname = "Red"
var arr = parsed data
For i = 0 to end
If arr.data.wall.color = colorname var wallname = arr.data.wall.name
Obviously a local variable. But I want to use a Global variable... one I've already set in a different task. So in task 1 I set ColorName = "Red"
And then in task 2:
var arr = parsed data
For i = 0 to end
If arr.data.wall.color = ColorName var wallname = arr.data.wall.name
...which doesn't work. I read else where that you need to use global() to access global variables in Scriptlets, but trying that doesn't work:
If arr.data.wall.color = global(ColorName) var wallname = arr.data.wall.name
Nor does adding the percent sign anywhere seem to work. Any ideas what I'm doing wrong?

I'm fairly certain the format is: global('VarName')
So if you were doing a JSON read from data returned in the global %HTTPD variable: JSON.parse(global('HTTPD')).current_observation.icon
Try using the apostrophe's like: global('ColorName')

Related

How to pdocread Extended Rom ?

Hi All,
I used aWizard to read out my Wizard's ExtRom, but do not know how to write it back.
I want to read out the ExtRom in .nba format, I studied the aWizard , I believe since " pdocread.exe 0 0x3900000 ROM\OS.nba " can read out the os, then theoretically " pdocread.exe ??? 0xA00000 ROM\ExtRom.nba " should be able to read out ExtRom in .nba format.
I do not know about programming, can someone be kind enough to point out what the ??? in above should be.
Will the following info has some hints?
Cmd>r2sd all
***** user area size = 0x1E100000 Bytes
R2SDBackup() - Download type = 5
usTotalBlock = 1 sizeof(SDCARD_SIGNATRUE_TABLE)=512
Start address = 0x80000000 , Length = 0x800 (IPL)
Start address = 0x80000800 , Length = 0xC0000 (SPL)
Start address = 0x800C0800 , Length = 0x40000 ( )
Start address = 0x80100800 , Length = 0x280000 (GSM)
Start address = 0x4E3D4C0 , Length = 0x3900000 (OS)
Start address = 0x743D4C0 , Length = 0xA00000 (EXTROM)
Thanks a lot!
Any idea about " pdocread.exe 0 0x3900000 ROM\OS.nba "?
Is 0 the starting offset address & 0x3900000 the size of the os rom part?
I have read the info in wiki.xda-developers.com, but my programming knowledge is too bad for me to understand it!
(just for reference), i posted a detailed explanation on http://www.spv-developers.com/forum/showthread.php?t=2888
willem

[Q] How to modify a file in \system\etc?

Hello,
I would like to modify the file \system\etc\srs_processing.cfg
Specifically, change this below:
//=-=-=-=-=-=-=-=-=-=-=-=-
//BLOCK: (srs_route_out) Routing - Output Device Routing
//=-=-=-=-=-=-=-=-=-=-=-=-
//INFO: srs_route_out:routing_info = 0 = int, 1 = ext, -1 = disallow srs processing, -2 = int dsp, -3 = ext dsp // Routing Values
srs_route_out:wired_headset = 1 // DEVICE_OUT_WIRED_HEADSET -
srs_route_out:wired_headphone = 1 // DEVICE_OUT_WIRED_HEADPHONE -
To:
//=-=-=-=-=-=-=-=-=-=-=-=-
//BLOCK: (srs_route_out) Routing - Output Device Routing
//=-=-=-=-=-=-=-=-=-=-=-=-
//INFO: srs_route_out:routing_info = 0 = int, 1 = ext, -1 = disallow srs processing, -2 = int dsp, -3 = ext dsp // Routing Values
srs_route_out:wired_headset = -1 // DEVICE_OUT_WIRED_HEADSET -
srs_route_out:wired_headphone = -1 // DEVICE_OUT_WIRED_HEADPHONE -
Note the change in BOLD
Can this change be done with rooted stock without having the device reset?
A local.prop file for instance?
Thank you!
I don't think so. But I explain how to modify system files safely on rooted stock in my HD/HD+ stock tips thread linked in my signature. See item 15.
Sent from my Nook HD+ running CM10.1 on emmc.
leapinlar said:
I don't think so. But I explain how to modify system files safely on rooted stock in my HD/HD+ stock tips thread linked in my signature. See item 15.
Sent from my Nook HD+ running CM10.1 on emmc.
Click to expand...
Click to collapse
I understand -- I'll give it try!
Thanks!

Can't get MAC address

Currently I can get it to work if I use:
private static String address = "00:00:00:25:02:80";
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
But I want to be able to use:
Intent intent = getIntent();
newAddress = intent.getStringExtra(DeviceListActivity.EXTRA_DEVICE_ADDRESS);
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(newAddress);
So I've seen this code in other examples but It doesn't work on mine?
I have also tried other methods.
String newAddress = mBluetoothAdapter.getAddress();
This also doesn't work.
So can anybody help me with this I want to get the MAC address on it's own to connected device without declaring it.
Hello,
Check here.
Have you inserted the permission in the manifest? (android.permission.BLUETOOTH)
What does mBluetoothAdapter.getAddress() return for you?
Check also here for the remote device's MAC.

get eta using google maps api and travel mode=transit

Hello,
I implemented what is described HERE without problems, but now i would like to get the ETA using public transport routes. I changed what it seemed the most natural
Code:
travelmode=transit
instead of
Code:
travelmode=driving
(according to described in maps api documentation), but i still get travel time equal to driving mode.
Any ideas of what to do?
Regards,
Ok, after looking at google maps api documentation and analyzing the json output of the request, i got a solution.
First, replace in path "travelmode" for "mode", that is this:
Code:
/maps/api/directions/json?origin=%start&destination=%destination&[B]travelmode=driving[/B]&departure_time=now&key=%api
for this:
Code:
/maps/api/directions/json?origin=%start&destination=%destination&[B]mode=driving[/B]&departure_time=now&key=%api
And replace second and third line in the javascriplet:
Code:
var routetraffic = routeSplit.routes[0].legs[0].duration_in_traffic.text;
for this:
Code:
if (global('mapsTravelMode')=='driving'){
var routetraffic = routeSplit.routes[0].legs[0].duration_in_traffic.text;
var routename = routeSplit.routes[0].summary;
} else if (global('mapsTravelMode')=='transit') {
var routetraffic = routeSplit.routes[0].legs[0].duration.text;
var routename = 'going in public transportation';
}
Where %mapsTravelMode store the travel mode, in my case i use 'transit' or 'driving' that i set up manually.
If someone can get the first item in route that is not walking (i.e. the first transport to take), it would be great.
first bus obtained
hello,
to get the first non walking transportation, replace line:
Code:
var routename = 'going in public transportation';
with
Code:
var steps = t.routes[0].legs[0].steps;
for (var i = 0; i<steps.length; i++){
if (steps[i].travel_mode=='TRANSIT'){
break;
}
}
var routename = steps[i].transit_details.line.agencies[0].name;
var routename = routename + ' ' + steps[i].transit_details.line.short_name;
Shortname for bus notworking in javascriplet
Does any one have a download like for this task with the javascriplet changes I can't seem to get the shortname for the busses to work at all all I get is duration time

Can't get info back into android app from php webpage

My english is very bad, so i hope you understand.
I make my own apps, and most off the time in fragment activities
On my website i have a php script, that will check if the username and password is correct filled in in the application.
I hace to get back from the website the userID, firstname and email address from the database, this info is stored in a json format like below:
Code:
$result1["rol"] = $rol;
$result1["login"] = $login;
$result1["username"] = $Qusername;
$result1["userid"] = $userID;
$result1["mail"] = $Qmail;
echo json_encode($result1);
my php scipt woks perfectly, only how to get the $result1 back to android app??
I have the following on my website visible
Code:
{"rol":"9","login":"1","username":"christiaan","userid":"9998","mail":"c.***@h***e.nl"}
And I tried to read that in android with:
Code:
val apiResponse = URL(urlW).readText()
val url = URL(urlW)
val urlConnection = url.openConnection() as HttpURLConnection
val text = urlConnection.inputStream.bufferedReader().readText()
tUser.text = text
urlConnection.disconnect()
urlW contains the full link.
I write app in kotlin.
I have it almost working, but now the app crashes when it's an incorrect username or password:
Code:
val urlW = "http://www.*****.nl/mobile.php?username=*****&password=*****"
//webA.visibility = View.VISIBLE
webA.loadUrl(urlW)
// Request a string response from the provided URL.
val stringRequest = StringRequest(
Request.Method.GET, urlW,
{ response ->
// Display the first 200 characters of the response string.
val onlineString = "${response.substring(0, 200)}"
val explodeOnline = onlineString.split("#").toTypedArray()
tUser.text = explodeOnline[1] + " : " + explodeOnline[2] + " \n " + explodeOnline[3] + " : " + explodeOnline[4]
tPass.text = explodeOnline[5] + " : " + explodeOnline[6] + " \n " + explodeOnline[7] + " : " + explodeOnline[8] + " \n " + explodeOnline[9] + " : " + explodeOnline[10]
},
{ tUser.text = "That didn't work!" })
// Add the request to the RequestQueue.
queue.add(stringRequest)

Categories

Resources