flat assembler
Message board for the users of flat assembler.
Index
> Main > Macro if val * |
Author |
|
revolution 28 Jun 2013, 23:42
If you want to compare values then use = or eq instead of eqtype. Also the backslashes in the second level match will be stripped by the outer match, it might be better to use another separator character.
|
|||
28 Jun 2013, 23:42 |
|
Roman 30 Jun 2013, 19:06
revolution "compare values then use = or eq instead of eqtype"
did not help |
|||
30 Jun 2013, 19:06 |
|
bitRAKE 30 Jun 2013, 20:00
This worked for me:
Code: macro FioMul chs { match d1\d2\d3 , chs \{ if \`d2 = `+ display "2+4",13,10 else if \`d2 = '*' display "2*4",13,10 end if \} } FioMul 2\*\4 FioMul 2\+\4 A) need to escape ` operator to depth of usage with blackslash. (this delays evaluation until d# has correct value) B) character values are being compared but you have used symbol *. (valid methods are `* and '*') Hopefully, repeating her/his advise helps. |
|||
30 Jun 2013, 20:00 |
|
Roman 01 Jul 2013, 05:14
bitRAKE
Thanks dude. Respect |
|||
01 Jul 2013, 05:14 |
|
Roman 01 Jul 2013, 05:30
This macro work fine (FioMul 2*4 or FioMul 2+4)
macro FioMul chs { match d1\d2\d3 , chs \{ if \`d2 = `+ invoke MessageBox,0,"2+4",'o',0 end if if \`d2 = `* invoke MessageBox,0,"2*4",'o',0 end if \} } But if i want write this: FioMul 2+3*4+5-7*2+1+2 or i want write FioMul 2+34+57*21+2 How to make a FioMul macro to take this all values and ganerate right code ? |
|||
01 Jul 2013, 05:30 |
|
bitRAKE 01 Jul 2013, 06:44
You would need to read about how an expression parser works. There are many good tutorials online. There are many good examples on the board here.
A simplistic way would be to break the expression into a series of <op> <val> pairs. We would ignore operator precedence and handle them in order. This might not be sufficient though - depending on your ultimate goal. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
01 Jul 2013, 06:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.