flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > if ~ defined -> error

Author
Thread Post new topic Reply to topic
Jin X



Joined: 06 Mar 2004
Posts: 104
Location: Russia
Jin X
Code:
if ~ defined x
  display "Variable 'x' is not defined!"
  err
end if    

If will see an error if x is defined later.
There's no error message if err will be replace by assert 0.
But if I will use this block of code multiple times (with different variables instead of x) I can see many error messages.
But I want to stop on the 1st error message.
How can I do this?
Post 14 Feb 2021, 19:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17942
Location: In your JS exploiting you and your system
revolution
Jin X wrote:
But I want to stop on the 1st error message.
How can I do this?
Both assert 0 and err will cause assembly to stop. But assert is a "soft" stop, and err is a "hard" stop.

Assert will allow more passes to resolve variables before erroring.
Err will immediately halt.
Post 15 Feb 2021, 01:21
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 104
Location: Russia
Jin X
Yeah, I understand.
I've defined a const to show only first error with assert Smile

But now I have another problem:
Code:
macro tst x
{
  if ~ defined x
    display 'Error!'
    assert 0
  end if
}

tst a
qqq
a rb 1    

Here I see message "Error!".
qqq generates an error and a becomes undefined. This creates a sense of error in the wrong place.
Is there's a way to avoid "display"ing the custom message in this case.
Post 15 Feb 2021, 16:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17942
Location: In your JS exploiting you and your system
revolution
Move "tst a" further down after the qqq line.

Or change the text to say "x is not defined yet". It isn't actually an error to have undefined variables, so displaying "error" is not strictly correct.
Post 16 Feb 2021, 01:21
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.