Setting variable

99 views
Skip to first unread message

Db

unread,
Jul 26, 2015, 1:27:31 PM7/26/15
to Android Send/Expect
I am trying to set a variable in tasker but have completely no idea how to get the variable out of the Recorded data


The

Recorded data is

STATUS\r\n\r\n================================================================\r\n HDMI/HDBT Matrix-4x4 Status\r\n FW Version: 1.8\r\n\r\nPower\tIR\tKey\tAPM\tBeep\r\nON \tON \tON \tOFF\tOFF\r\n\r\nInputPort\tEdidIndex\tHDMIconnect\r\n01\t\tFORCE___00\tYes\r\n02\t\tFORCE___00\tYes\r\n03\t\tFORCE___00\tYes\r\n04\t\tFORCE___00\tNo\r\n\r\nOutputPort\tSelectInput\tHDMI/HDBTconnect EnableOutput\r\n01\t\t02\t\tYes/Yes\t\t No\r\n02\t\t02\t\tNo/Yes\t\t Yes\r\n03\t\t02\t\tNo/Yes\t\t Yes\r\n04\t\t04\t\tNo/No\t\t Yes\r\n================================================================\r\n\r\nMatrix-4x4> "

I am attempting to get the Enable output Status

n03\t\t02\t\tNo/Yes\t\t Yes

The last yes is the value of the variable I would like set

What would I have to set as my expect to try and achieve this so far anything I have tried has failed.

Any help would be greatly appreciated.

Thanks


David

unread,
Jul 26, 2015, 6:57:54 PM7/26/15
to android-s...@googlegroups.com, diarma...@googlemail.com
Aside from creating the Tasker variable(s) in an expect statement (see here and here) this is mostly just a regular expression problem.
Displaying your data with System.out.println shows that it is formatted for human reading:

STATUS

================================================================
              HDMI/HDBT Matrix-4x4 Status
              FW Version: 1.8

Power IR Key APM Beep
ON ON ON OFF OFF

InputPort EdidIndex HDMIconnect
01 FORCE___00 Yes
02 FORCE___00 Yes
03 FORCE___00 Yes
04 FORCE___00 No

OutputPort SelectInput HDMI/HDBTconnect    EnableOutput
01 02 Yes/Yes    No
02 02 No/Yes    Yes
03 02 No/Yes    Yes
04 04 No/No    Yes
================================================================

Matrix-4x4> 

Is there an option to get this report with CSV encoding?  It would be a bit easier to match with a regular expression.  But if not, what you have can still be matched. 

Your desired matching indicates that you want to match output number 03.   So perhaps something like the following would work:

(?s)^.*EnableOutput.*\r\n03[\t]+[^\n]*(?<status>Yes|No)\r\n

The (?s) puts the expression into DOTALL mode.

If it matches, the Tasker variable %status is set to Yes or No.
 

Db

unread,
Jul 27, 2015, 12:19:23 PM7/27/15
to Android Send/Expect
Thanks David for the help i had missed the link to regex webiste in previoud posts.

The(?s) commmand forced closed the send expect app.

I got it sorted with a lot longer and probably cumbersome approach but i got all the outputs statuses and inputs set to local variables.

Thanks again for the help

Reply all
Reply to author
Forward
0 new messages