Community discussions

MikroTik App
 
DyadyaGenya
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Mon May 08, 2023 10:34 pm

Variable type "nil" but data is printed

Wed May 10, 2023 12:21 am

In a script, I execute a command and write the result to a variable. The result is printed in the terminal. But checking the data type of the variable says that the type is "nil". How can this be?
The script is like this:
:local output [/interface lte at-chat lte1 wait=yes input="AT!GSTATUS?"]
:put $output
:put [:typeof $output]
Is it possible to find out somehow the type of data received by this command?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12558
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Variable type "nil" but data is printed

Wed May 10, 2023 2:04 pm

On terminal is not printed the variable, but the result of the operation, is why the variable is "nil"....
 
DyadyaGenya
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Mon May 08, 2023 10:34 pm

Re: Variable type "nil" but data is printed

Wed May 10, 2023 3:54 pm

On terminal is not printed the variable, but the result of the operation, is why the variable is "nil"....
I realized my mistake, I should have done this

:local ModemResponse
    :set $ModemResponse ( [ /interface lte at-chat lte1 wait=yes input="AT!GSTATUS?" as-value ]->"output" );
:put [ :typeof $ModemResponse ]

Who is online

Users browsing this forum: No registered users and 8 guests