Hi,
Who can answer me how to use named variables in subexes? There are examples:
1. Numbered variables:
subex"My name is $1, I'm $2 years old." % [ "Aleksej", "36" ]
2. Named variables:
subex"My name is $name, I'm $age years old." % [ ? ? ? ]
Hi,
Who can answer me how to use named variables in subexes? There are examples:
1. Numbered variables:
subex"My name is $1, I'm $2 years old." % [ "Aleksej", "36" ]
2. Named variables:
subex"My name is $name, I'm $age years old." % [ ? ? ? ]
I think named variables might have a bug in subexes.
Example:
echo subex"My name is $name, I'm $age years old." % ["Aleksej", "36"]
will return My name is Aleksej, I'm Aleksej years old.
While the following works like expected:
echo subex"My name is $name, I'm $2 years old." % ["Aleksej", "36"]
Edit: Araq said he's working on a solution to this, so it should be on github soon :P
Hi Brenton,
Thank you for contacting Araq! ;)
Interesting, what is future syntax of this feature.
I think it will be useful for parsing shell conf files. Like this:
Conf file:
VarA="123"
VarB="abc$VarA"
VarC="$VarB.tar.gz"
Nimrod code:
Read line by line,
split line to variable name and its value,
assign value to variable,
if value contain '$' then execute subex with new variable's name and all known variables.
In the future it may be done like this:
$&"See here: $variable and some more here: $rubbish" % ["Tada!", "Ok?"]
Also a present: http://www.trixarian.net/downloads/aporia-0.1.2.tazpkg - Yep, it's the Nimrod based IDE with syntax highlighting included. Should make editing nimrod code easier.
I think, better will be like a tuple: [variable:"Tada!", rubbish:"Ok?"]
because variable's order can change. And maybe I want to add more variables to the right side, while left side contains less items.
For what I need it -- see above.
Still unusable for my goals. Maybe I can write code, but big and uneffective...
I've compiled Aporia too. But my Aporia frequently hangs, have no 'Close' or 'Exit' entry in 'File' menu, and sometimes don't close own window by pressing on cross. Killall helps. I want to test your pkg.
And what about Nimrod official SliTaz's receipt (in wok-undigest, I think). Brenton, can you write this receipt? I'm not familiar with cooker and receipts, what about you?
subexes were designed so that the order of the variables don't matter. You can order them within the string or even do them in reverse order if you feel like it.
For Aporia, it's down to how you compile it. The readme file is wrong. To make it work without weird bugs, you need to compile it with nimrod c -d:release - any other way breaks it. That's how I compiled the one I packaged :P
A receipt for it would be tricky since you need a nimrod package first. Also the download link with regards to github is also weird.
Hmm. How compiler can guess which variable I mean in the right part of subex? I can write there any strings or variables...
...and will first named variable in the left part is assigned to the first entry in the right part, and so on. Right?
In this case using of numbered variables ($3, $1, $[true|false]2 and so on) gives me more flexible access to result.
It can tell using references like it explains in the table @ http://nimrod-code.org/subexes.html
Mind you, plain old strutils should also have a similar level of flexibility.
You must log in to post.