+ Reply to Thread
Results 1 to 4 of 4

Thread: (E2) Variable self-check

  1. #1
    Wire Noob CDRW's Avatar
    Join Date
    May 2007
    Posts
    10

    Default (E2) Variable self-check

    This is a really simple question, Is there a way for expression 2 to self-check an internal variable to see if it exists or not? I'm having a problem where I want to check a variable so a statement executes one time but the variable isn't defined yet as it is at the beginning of the code. So it has no value. I can't seem to find a way to force it to check and see if it exists or not, which was something simple in E1. (Granted this doesn't create internal variables just because you reference them) PS: (!Variable) is not working for this purpose. I probably would have asked in IRC if I could access it at the moment.

  2. #2
    Wire Sofaking ZeikJT's Avatar
    Join Date
    Dec 2008
    Location
    California
    Posts
    1,391

    Default Re: (E2) Variable self-check

    Quote Originally Posted by CDRW View Post
    This is a really simple question, Is there a way for expression 2 to self-check an internal variable to see if it exists or not? I'm having a problem where I want to check a variable so a statement executes one time but the variable isn't defined yet as it is at the beginning of the code. So it has no value. I can't seem to find a way to force it to check and see if it exists or not, which was something simple in E1. (Granted this doesn't create internal variables just because you reference them) PS: (!Variable) is not working for this purpose. I probably would have asked in IRC if I could access it at the moment.
    Remember, you must list the variable under the @persist or @output for it to be included like you want it to.

    After that, I believe that the instant a variable is referenced it is created. So if it is a number it should default to 0, if it is a string it might default to "", and so on.

    Try comparing it to those first.

    Also, if you are trying to have a run-once command I think the first() is now working. It will return 1 if it is on the first interval and 0 after that.
    Against stupidity the Gods themselves contend in vain.
    -Friedrich Schiller

    The flame puts me in the mood to "Do it!".
    -Dart, Legend of Dragoon

  3. #3
    Wire Noob CDRW's Avatar
    Join Date
    May 2007
    Posts
    10

    Default Re: (E2) Variable self-check

    Quote Originally Posted by ZeikJT View Post
    Remember, you must list the variable under the @persist or @output for it to be included like you want it to.

    After that, I believe that the instant a variable is referenced it is created. So if it is a number it should default to 0, if it is a string it might default to "", and so on.

    Try comparing it to those first.

    Also, if you are trying to have a run-once command I think the first() is now working. It will return 1 if it is on the first interval and 0 after that.
    It's not a persistent variable or something to be outputted. It's just an internal variable. And it doesn't seem to be creating it on reference as everything I can find to reference it to, it won't even validate unless the variable exists when referencing it.

    However, if first() is working (Assuming it uses the format if(first())) Then the whole argument is moot because having it define the variables I need to preform the operation on first run and just making them persistent variables would solve my problem altogether.
    Thank you

  4. #4
    Expressionism 2.0 Syranide's Avatar
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    4,573

    Default Re: (E2) Variable self-check

    Not quite sure what you mean.
    But yes, you cannot use a variable before it has been set to anything, this is to prevent some common mistakes such as incorrect naming etc.

    E.g. you can't do this:
    Code:
    @inputs
    @outputs
    A = B
    B has no value, and there is no possibility that it would ever have been given a value, thus till will generate an error, because it is an obvious mistake.

    But it will never prevent you from using a variable that has any purpose.

+ Reply to Thread

Similar Threads

  1. Can I check what a Console Screen says with E2?
    By ThePearl in forum Installation and Malfunctions Support
    Replies: 16
    Last Post: 02-12-2009, 02:01 PM
  2. Check out my web site YAY
    By Tuollaf in forum Off-Topic
    Replies: 26
    Last Post: 11-19-2008, 11:39 PM
  3. Check if a certain key is pressed?
    By Overkill in forum Wiremod General Chat
    Replies: 12
    Last Post: 10-14-2007, 01:47 AM
  4. CHECK THIS OUT !
    By Mechanical433 in forum Off-Topic
    Replies: 7
    Last Post: 06-28-2007, 02:23 AM
  5. E-gate dosn't check correctly
    By Sharpshot in forum Bug Reports Archive
    Replies: 4
    Last Post: 06-15-2007, 03:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots