Community discussions

MikroTik App
 
paris9
newbie
Topic Author
Posts: 32
Joined: Mon Feb 03, 2014 9:31 am

Please help with a string conversion

Sun Mar 30, 2014 9:26 pm

The output below currently gives me the hex to ascii conversion for one and a string for the other.
How can I get "A" as the result for both of the statements below?

{
:put "\41";

:local a "41";
:put "\\$a";
}

Output:
A
\41
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12658
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help with a string conversion

Mon Mar 31, 2014 4:39 am

Simply ask!
:global tmpHex value=41;
:global funHex2Char value=[:parse (":global tmpChar value=[:put \"\\".$tmpHex."\"]")];
$funHex2Char;
:put ("\\".$tmpHex." = ".$tmpChar)
Notice: when exec $funHex2Char display one "A" (in this case) on terminal, but if used on the script, do not print anything (except if the string are launced from terminal.



If I solved your problem, please add Karma!
 
paris9
newbie
Topic Author
Posts: 32
Joined: Mon Feb 03, 2014 9:31 am

Re: Please help with a string conversion

Mon Mar 31, 2014 7:59 am

Thank you! You solved my problem :D
 
obadaabdullah
Frequent Visitor
Frequent Visitor
Posts: 71
Joined: Wed Jan 08, 2014 7:41 pm

Re: Please help with a string conversion

Mon Mar 31, 2014 9:55 am

Simply ask!
:global tmpHex value=41;
:global funHex2Char value=[:parse (":global tmpChar value=[:put \"\\".$tmpHex."\"]")];
$funHex2Char;
:put ("\\".$tmpHex." = ".$tmpChar)
Notice: when exec $funHex2Char display one "A" (in this case) on terminal, but if used on the script, do not print anything (except if the string are launced from terminal.



If I solved your problem, please add Karma!
you r just great
respect