Nested variables ?

295 views
Skip to first unread message

Benoit-Pierre DEMAINE aka DoubleHP

unread,
May 26, 2012, 9:29:40 AM5/26/12
to Tasker
Hello; new to this group; using Tasker since last August, and having
very much fun with it :)

Any kind of nested variables ?

In short, I am trying to design contextual help: some scenes (not all)
have a Help button; when you press it short, helps is printed above
the scene. When you press it long, the same text is shown, but in
edition mode.

I have a scene called Bar.

I have variable FooBar.

The scene contains a Text box, where the shown text must be the
content of %FooBar. But I want to be able to copy-paste the Text
object from a scene to an other one without having to edit it (I don't
want to have to edit the Text object to update the text content
field).

So, I need something close to
${Foo{$Bar}}

Array is not what I need: variables are called after the scene name. I
can not change the scene names to pure numbers just to be able to use
arrays.

The other way around could work: name the variables just like the
scenes; but there would still be two issues:
- how to get an equivalent of ${$Bar} ?
- I want to prefix these variables to have them grouped in the
variable list
- I don't have this in all scenes, but if a scene has a Text object,
then it will also have a TextEdit object: both shall point to the same
variable; and this variable shall be specific to the scene.

I have tried other approaches, but the only to make this help stuff
usable and usefull is to let the user edit it live, above the live
scene. Can not be done under Tasker Scene editor.

Thanks.

DEMAINE Benoit-Pierre

unread,
May 28, 2012, 1:18:25 PM5/28/12
to Tasker
Any one can help me ?

In short, i need to store the name of a variable inside an other variable.

--
>o_/ DEMAINE Benoit-Pierre (aka DoubleHP) http://benoit.demaine.info/
If computing were an exact science, IT engineers would'nt have work \_o<

"So all that's left, Is the proof that love's not only blind but deaf."
(FAKE TALES OF SAN FRANCISCO, Arctic Monkeys)

easiuser

unread,
May 29, 2012, 9:36:28 AM5/29/12
to tas...@googlegroups.com
If you want to copy the contents to the clipboard, you could set an action to do that with a long press on the help text. Or you could launch a menu popup to perform any other type of action like copy, paste and replace, paste and append, etc. 
 
If you need the user to select a portion of the text, you could copy the contents into a separate text edit box (scratch pad) where the user could select and manipulate the text without effecting your scene.

DEMAINE Benoit-Pierre

unread,
May 30, 2012, 10:40:52 PM5/30/12
to tas...@googlegroups.com
None of those case. I just need to store the name of a variable into a
variable, and then, read it.

Doing any other way would be PITA for me.

Dennis

unread,
Jun 6, 2012, 1:52:17 PM6/6/12
to tas...@googlegroups.com
What about:
%BARNUM=List,OF,Your,Scenes --  variable split %BARNUM
%temp=%BARNUM(#?%BAR)
%Foo(%temp)

$BARNUM obviously being defined somewhere else, globally.
Whenever you create a new scene with help text you could append the scenes name to %BARNUM
Just try not to accidentally delete it! :)

Benoit-Pierre DEMAINE

unread,
Jun 14, 2012, 11:14:09 AM6/14/12
to tas...@googlegroups.com
After very long time ... I have understood it now.

So, Tasker does not accept index by name, but, you use the (undocumented) search in array feature to find the offset of a word, and then, grab content from a twin array (one array for names, one for contents).

It's not as clean as I wanted, but, it will do the job, and will remain better than the other approaches.

Will create stuff on the fly, and only for required case (only some scenes have help, not all). Now, adding the help button will be enough, without having to manually add any var, or tweak any array: on help button press, if help line does not exist, backend task can create it on the fly.

Many thanks.


On 6 June 2012 19:52, Dennis <dennish...@googlemail.com> wrote:
What about:
%BARNUM=List,OF,Your,Scenes --  variable split %BARNUM
%temp=%BARNUM(#?%BAR)
%Foo(%temp)

$BARNUM obviously being defined somewhere else, globally.
Whenever you create a new scene with help text you could append the scenes name to %BARNUM
Just try not to accidentally delete it! :)



--
>o_/ DEMAINE Benoit-Pierre (Gmail) (aka DoubleHP) http://benoit.demaine.info/

Dennis

unread,
Jun 14, 2012, 12:26:51 PM6/14/12
to tas...@googlegroups.com
Great!
Well, it's documented (  http://tasker.dinglisch.net/userguide/en/variables.html ), but somewhere around I've read that even Pent forgot about this feature. It is a nice thing, just rarely used.
Also, I had to dig around a bit in the documentation to find some other variables I remembered:
So, you could use %scene_name to make this a bit more universal.
Aka, in a scene a "do i need to create" could be launched.
IF %BARNUM~*%scene_name*
FLASH "This is the first time this scene ever runs, so here I launce whatever I want to do as create. Big part of it obviously is to get the documentation structure going, so the documentation can always be done inside the scene, not just in Tasker"
VARIABLE SET %BARNUM = %scene_name APPEND ON
VARIABLE SPLIT %BARNUM
VARIABLE SET %temp=%BARNUM(#?%scene_name)
VARIABLE SET %Foo(%temp) = "This is the default help text for scene %scene_name, please change it by long clicking the help button"
END IF
This could even go into its own task that you could just reference from each scene, so it might save you some typing.

DEMAINE Benoit-Pierre

unread,
Aug 12, 2012, 10:23:01 PM8/12/12
to tas...@googlegroups.com
After a very very very long reflexion, I finally understand precisely what
you meant.

In short:
- the only thing that exists are linear arrays
- array index must always be a number
- the only way to simulate a 2D array, or nested variables is to store
values in one array, search a patern in it, get the index of this match,
and use this index to read an other twin array.

In some complex case, the value read in the second array will be a complex
number (integer vs decimal, or units vs tens vs hundreds for a 10x10x10
table) ...

I had never used such a limited language, so I had never needed to cut
down array manipulation; even in ASM it's more simple: multiply indexes,
add a base address, and you got a cell; if need to grab the coordinates,
search the patern in the whole memory, deduce relative address, and you
can recompute the coordinates. Tasker forces me to use more basic tools,
what makes things somehow more complex for me.

But today, I REALLY need a rich array.

And I have finally fully understood what can be done in Tasker, and what
can't. Now, I know how to do what I need :)

On 14/06/12 18:26, Dennis wrote:
> Great!
> Well, it's documented (
> http://tasker.dinglisch.net/userguide/en/variables.html ), but somewhere
> around I've read that even Pent forgot about this feature. It is a nice
> thing, just rarely used.
> Also, I had to dig around a bit in the documentation to find some other
> variables I remembered:
> http://tasker.dinglisch.net/userguide/en/activity_elementedit.html#tap
> So, you could use %scene_name to make this a bit more universal.
> Aka, in a scene a "do i need to create" could be launched.
> IF %BARNUM~*%scene_name*
>
> FLASH "This is the first time this scene ever runs, so here I launce
> whatever I want to do as create. Big part of it obviously is to get
> the documentation structure going, so the documentation can always be
> done inside the scene, not just in Tasker"
> VARIABLE SET %BARNUM = %scene_name APPEND ON
> VARIABLE SPLIT %BARNUM
>
> VARIABLE SET %temp=%BARNUM(#?%scene_name)
> VARIABLE SET %Foo(%temp) = "This is the default help text for scene
> %scene_name, please change it by long clicking the help button"
>
> END IF
> This could even go into its own task that you could just reference from
> each scene, so it might save you some typing.
>


--
>o_/ DEMAINE Benoit-Pierre (aka DoubleHP) http://benoit.demaine.info/

Dennis Hessling

unread,
Aug 13, 2012, 5:22:17 AM8/13/12
to tas...@googlegroups.com
What do you do with Tasker to get to variables of that size?
Also, keep in mind that the variables do not really need linear numbering without skips.
So %VAR(010101) to %VAR(101010) is possible without occupying the %VAR(029999).
Otherwise, just use them in in JavaScript and hand them back down to Tasker.

DEMAINE Benoit-Pierre

unread,
Aug 13, 2012, 12:34:47 PM8/13/12
to tas...@googlegroups.com
On 13/08/12 11:22, Dennis Hessling wrote:
> What do you do with Tasker to get to variables of that size?

I don't need 3D arrays ATM; but I do need heavy arrays.

ATM, I am working on a package manager. So, one array need to contain the
full list of installed packages, and a linked list of package names, and
versions ...

I try to dev my GUI to use indexes as far as possible, to avoid having to
ever use a search routine (that would be horribly slow).

> Also, keep in mind that the variables do not really need linear numbering
> without skips.
> So %VAR(010101) to %VAR(101010) is possible without occupying the
> %VAR(029999).

I know that the array can have holes; but arrays accepting text as indexes
would have been way easier for me.

Tasker is a half object language.

> Otherwise, just use them in in JavaScript and hand them back down to Tasker.

Never learnt JS, and I refuse to dev in JS on my mobile phone. I do mobile
dev, and I do not want my mobile phone projects to depend, need, or
require any PC to dev.

If I can't do it with just my phone, I just won't do it.

And I am getting too old to learn JS, even for desktop use.

Dennis Hessling

unread,
Aug 13, 2012, 1:07:12 PM8/13/12
to tas...@googlegroups.com
You can still just type your stuff in Tasker.
No need for a PC.
It's not that hard.
But, by what you're telling you probably rather want a SQL-DB, that's easier and faster with datasets this size.
Yet, all possible on your phone.
Also, I'm quite sure there's a DB with that info in there already on your phone.

DEMAINE Benoit-Pierre

unread,
Aug 13, 2012, 1:23:05 PM8/13/12
to tas...@googlegroups.com
On 13/08/12 19:07, Dennis Hessling wrote:
> You can still just type your stuff in Tasker.
> No need for a PC.
> It's not that hard.
> But, by what you're telling you probably rather want a SQL-DB, that's
> easier and faster with datasets this size.
> Yet, all possible on your phone.
> Also, I'm quite sure there's a DB with that info in there already on your
> phone.
>

again found a bug :'(

I Can't dev any thing in tasker

every single day I dev with it, I find a bug ...

Dennis Hessling

unread,
Aug 13, 2012, 1:37:36 PM8/13/12
to tas...@googlegroups.com
A variable bug in Tasker?
Seems unlikely, lots of others have created great things in Tasker.
Sure, there's a minor bug here and there from time to time, but variables are pretty fixed.
Also, if you just said what's wrong, people could help you with the bug.
Either a workaround, a hint of misuse of Tasker or a fix from Pent.
But all that's just possible if you give a little more detail.

DEMAINE Benoit-Pierre

unread,
Aug 13, 2012, 1:37:51 PM8/13/12
to tas...@googlegroups.com
I am VERY angry.

This is really the worst one I ever found in Tasker (but I have still
found worst in other dev suites)

No more comment.
2012-08-13_19-32-26.jpg

DEMAINE Benoit-Pierre

unread,
Aug 13, 2012, 1:40:04 PM8/13/12
to tas...@googlegroups.com
On 13/08/12 19:37, Dennis Hessling wrote:
> A variable bug in Tasker?

today, yes: a bug about var handling !!!

yesterday, no less than 4 bugs, all with repro

including a systematical force close in App Factory.

> Seems unlikely, lots of others have created great things in Tasker.
> Sure, there's a minor bug here and there from time to time, but variables
> are pretty fixed.
> Also, if you just said what's wrong, people could help you with the bug.
> Either a workaround, a hint of misuse of Tasker or a fix from Pent.
> But all that's just possible if you give a little more detail.

better leave computer and phone on the side for a few hours, I am really
out of nerves now !

DEMAINE Benoit-Pierre

unread,
Aug 13, 2012, 1:41:08 PM8/13/12
to tas...@googlegroups.com
On 13/08/12 19:37, Dennis Hessling wrote:
> Seems unlikely

what's unlikely for other people ... always occurs for me.

ex: multiple car accidents the same day ...

Pent

unread,
Aug 14, 2012, 2:26:09 AM8/14/12
to Tasker
> This is really the worst one I ever found in Tasker (but I have still
> found worst in other dev suites)

It's more an ommision that a bug, but I'll fix it for next version.

Pent
Reply all
Reply to author
Forward
0 new messages