Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Variable syntax questions

  1. #1
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    129

    Variable syntax questions

    Starting to figure out the software, but running into a few problems. I think I I have these things right, but haven't found these specific answers. I'm figuring a lot out as I go, but I don't want to hit any walls later because I misunderstood how something works, also don't have all my pieces here yet to trial & error it a lot.

    1. In a "Then" "change variable" scenario what is the proper syntax to make changes?
    Numeric
    "d+1" adds 1 to whatever the variable currently is
    "+1" does the same?
    is there a way to set it to a specific value?
    Boolean
    "+1" = True? "-1" = False ?

    2 Proper way to use an output state as a variable. If a DigOut is "on" does it have a property that can be read?
    Example: IF DigOut1 is On THEN ......
    In the graphic editor it would be the DigOut connected to an output node. This returns an error on config open about it needing a "secondary boolean" something - cant read the entire error due to the size of the error box. Do i have to set a variable each time? If i choose "set" to a boolean variable, does it change to true if the DigOut is on & false if it is off?

  2. #2
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    9,851
    1.
    Numeric:
    d# = change of #
    # = set to #

    so:
    d+1 is var = var 1
    d-42 is var = var - 42
    +42 is var = 42
    -1 is var = -1

    Boolean uses true false. So you set to "true" or "false".

    In MDX 0 = false, 1 = true if it has to. Do not rely on this. If it can evaluate it as a number then it will. If it has to do a boolean compare it will attempt to parse it to a number but again it is something you should not rely on.




    2.
    In the configurator when you select a digital output to put in a Logical Block, it is the current state of the Digital Output.

    If DigOut1 is ON requires a "is ON" part to it. If you connect Digital Output to Output, then you are saying "If Digital Output". Now in most languages the == true is implied, this is not the case with MDX. You have to put an equals and a 1. This is one time when you would use the internal number to boolean conversion.

    You can pass the Digital Output to a variable if you want but it is unneccessary.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  3. #3
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    129
    Quote Originally Posted by 2k1Toaster View Post
    1.
    Boolean uses true false. So you set to "true" or "false".

    In MDX 0 = false, 1 = true if it has to. Do not rely on this. If it can evaluate it as a number then it will. If it has to do a boolean compare it will attempt to parse it to a number but again it is something you should not rely on.
    ????? if it has to ???????????
    I think this is causing me all kinds of hell - from my minute VB6 background (in college, 5yrs ago), I assume True=1, False=0 and use 0 and 1 as often as possible.

    The default in "change variable" is "+0" That implies, to me, that the field should be numeric. Does typing in "True" work better than +1? Can't evaluate it in simple manner right now, see next question

    Quote Originally Posted by 2k1Toaster View Post
    If DigOut1 is ON requires a "is ON" part to it. If you connect Digital Output to Output, then you are saying "If Digital Output". Now in most languages the == true is implied, this is not the case with MDX. You have to put an equals and a 1. This is one time when you would use the internal number to boolean conversion.
    Syntax problem noted BUT,
    Using:
    IF DigOut1 == 1 Then
    (typing out the graphical representation)
    gives me a compile error (?). No pop-up box or notification, but when I run MDX with that logic statement saved, it immediately dies (process closes in task manager). the MDX icon appears in the sys tray, but disappears as soon as the mouse passes over it. No Then statements, just the If logic
    I'm guessing Digital Output state & a number (0 or 1) are not compatible with "==" What is "This is one time when you would use the internal number to boolean conversion." Is there a function/setting I'm missing?

    Hopefully I'll figure out what I'm doing wrong before you respond, hate having to get help for things that should be simple.
    I think MDX is a great way to control the FB. I just need to get my brain functioning they way MDX wants it to. Might have something to do with how we spell "Analog" differently Comments/Definitions/Examples for the different fields would help my non-programmer brain a lot as some of the terminology isn't obvious to me.
    Thanks for your help

  4. #4
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    129
    OK now I'm really confused.

    Since I can't compare whether a DigOut is on or off, i used an analog in as my trigger to change a variable from False to True.



    IF Variable_Input_0 is > 2 THEN
    Change My Variable to True
    Change Variable_Input_1 to d+1
    ELSE
    Change My Variable to False



    If/Then Node Debugger never shows #3 as true (even when Var_In_0 = 3, 4, 5, whatever)
    My Variable never changes to True, however Var_In_1 changes to d+1 with the logic timer, then back to d when the input timer refreshes the variable. The graph shows that the d+1 is being executed, why not my variable = true?

  5. #5
    Low Bitrate GadgetBandit's Avatar
    Join Date
    Oct 2008
    Posts
    100
    Var = False

    What does the block look like for:

    If Var = "True"
    Do Function

    Do I have to do a boolean comparison?


    Thanks,
    GadgetBandit

  6. #6
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    9,851
    Quote Originally Posted by Iamthehor View Post
    ????? if it has to ???????????
    I think this is causing me all kinds of hell - from my minute VB6 background (in college, 5yrs ago), I assume True=1, False=0 and use 0 and 1 as often as possible.
    Well that is why your professors should have told you to never do that. It is very bad programming practice. (I do it all the time though )

    If it has to because it is the last resort. It tries to parse it as a number first. If it succeeds, then it returns from the internal function and passes back a numeric value. If it cannot parse it, then it tries to parse it as a boolean from a string. If that doesnt parse it returns 0.

    So by using 1 and 0, you are passing back 1 and 0 not true/false. And MDX will not compare numeric vs. boolean. There is basically a compiler and assembly based processor that I programmed under the hood that manages all this dirty work. There is nothing built in that does this sort of thing that can be exposed to someone without the source.

    The default in "change variable" is "+0" That implies, to me, that the field should be numeric. Does typing in "True" work better than +1? Can't evaluate it in simple manner right now, see next question
    That is just the default. You can change it to anything you want. You can change it to "fluffy penguins" and it will accept it. But it will fail both the numeric parse and boolean parse, and will evaluate to 0 (numeric).

    Type in "true" and "false". I cant remember but I am pretty sure that is case sensitive.

    Syntax problem noted BUT,
    Using:
    IF DigOut1 == 1 Then
    (typing out the graphical representation)
    gives me a compile error (?). No pop-up box or notification, but when I run MDX with that logic statement saved, it immediately dies (process closes in task manager). the MDX icon appears in the sys tray, but disappears as soon as the mouse passes over it. No Then statements, just the If logic
    I'm guessing Digital Output state & a number (0 or 1) are not compatible with "==" What is "This is one time when you would use the internal number to boolean conversion." Is there a function/setting I'm missing?
    I'll look into that dieing, but you can also just tie the digtal output to the logic block output as well. It is a boolean output, and that is what the logic block output looks for.

    Hopefully I'll figure out what I'm doing wrong before you respond, hate having to get help for things that should be simple.
    I think MDX is a great way to control the FB. I just need to get my brain functioning they way MDX wants it to. Might have something to do with how we spell "Analog" differently Comments/Definitions/Examples for the different fields would help my non-programmer brain a lot as some of the terminology isn't obvious to me.
    Thanks for your help
    I am working on a manual for all of this. It's going to be a novel by the time it is done... MDX is a complex beast.

    Quote Originally Posted by Iamthehor View Post
    OK now I'm really confused.

    Since I can't compare whether a DigOut is on or off, i used an analog in as my trigger to change a variable from False to True.



    IF Variable_Input_0 is > 2 THEN
    Change My Variable to True
    Change Variable_Input_1 to d+1
    ELSE
    Change My Variable to False



    If/Then Node Debugger never shows #3 as true (even when Var_In_0 = 3, 4, 5, whatever)
    My Variable never changes to True, however Var_In_1 changes to d+1 with the logic timer, then back to d when the input timer refreshes the variable. The graph shows that the d+1 is being executed, why not my variable = true?
    because I had a bug. I mucked around with the logic not too long ago, and voila a bug appeared where it would not evaluate a boolean variable other than false. Fixed now, I will try to get an update out tomorrow.

    Quote Originally Posted by GadgetBandit View Post
    Var = False

    What does the block look like for:

    If Var = "True"
    Do Function

    Do I have to do a boolean comparison?


    Thanks,
    GadgetBandit
    No just tie the variable(get) to the logic block output. It needs to be a boolean variable though. If it is a numeric variable you get problems like above.


    Also, because of this, I have tried to add more generic type casting to the old "compiler" inside of MDX.

    Basically what happened was everything was string parsed until fall 2008-ish. Then I made a compiler out of the string parsing code to convert it into basic integers passing variables and a program counter essentially. Basically mimicking the nature of a microcontroller in software. But that old string parse code is run once (at startup) to essentially compile. Statements like (false == 1) will fail in the string parser so it will never end up in the assembly area and worst case is the program will crash.

    So I just spent the good majority of the night updating the compiler section to use the same parsing routines as the assembly section. So if it crashes in one place it will crash in both. Hopefully that wont happen.

    Now it will do if(false == 1) statements, but it is being passed off into at worst case 3 catch statements which is a major system resource hog especially if you do this multiple time per logic block and call that code hundreds of times a second...

    I will try to get an update out soon. I have been migrating to a new laptop all week and I dont have everything setup yet to where I can get updates out.
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  7. #7
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    129
    I am working on a manual for all of this. It's going to be a novel by the time it is done... MDX is a complex beast.
    You're not kidding. Some of my frustration seems to come from bugs though, so it looks like I understand more than I though I did.

    So i'm not an idiot? I was convinced 3 was not greater than 2.
    I'll update and see what i can figure out.

  8. #8
    Fusion Brain Creator 2k1Toaster's Avatar
    Join Date
    Mar 2006
    Location
    Colorado, but Canadian!
    Posts
    9,851
    Quote Originally Posted by Iamthehor View Post
    You're not kidding. Some of my frustration seems to come from bugs though, so it looks like I understand more than I though I did.

    So i'm not an idiot? I was convinced 3 was not greater than 2.
    I'll update and see what i can figure out.
    The majority of bugs that you will find will be from the new logic. It is completely different than what had been working and stable for two years. Graphics and other such things I would suspect something else first since those have been good for years.

    And no you aren't an idiot, you are picking it up much faster than most. Once you figure out how MDX thinks, I think it becomes much easier to understand and realize what you have to do to make it do what you want it to!
    Fusion Brain Version 6 Released!
    1.9in x 2.9in -- 47mm x 73mm
    30 Digital Outputs -- Directly drive a relay
    15 Analogue Inputs -- Read sensors like temperature, light, distance, acceleration, and more
    Buy now in the MP3Car.com Store

  9. #9
    Low Bitrate GadgetBandit's Avatar
    Join Date
    Oct 2008
    Posts
    100
    My understanding:

    [IMG][/IMG]


    The code generated works great.

    <if fire_on="logic" minimum_delta_vote_time="100" id="Root Function #">
    <variable do="get" name="b1"></variable>
    <then>
    <do function="Change Variable" functionTargetID="my variable" vote_opinion="12" vote_priority="Low"></do>
    </then>
    </if>



    But if I reload into Configurator, I get the following:




    I have to use Configurator to help build blocks and then cut & paste it into Macromedia where I manage the ever growing monster. If the syntax is correct, then, I'm only curious about the error message.

    GadgetBandit

  10. #10
    Constant Bitrate
    Join Date
    Jun 2004
    Posts
    129
    Quote Originally Posted by GadgetBandit View Post
    My understanding:

    [IMG][/IMG]


    The code generated works great.

    <if fire_on="logic" minimum_delta_vote_time="100" id="Root Function #">
    <variable do="get" name="b1"></variable>
    <then>
    <do function="Change Variable" functionTargetID="my variable" vote_opinion="12" vote_priority="Low"></do>
    </then>
    </if>



    But if I reload into Configurator, I get the following:




    I have to use Configurator to help build blocks and then cut & paste it into Macromedia where I manage the ever growing monster. If the syntax is correct, then, I'm only curious about the error message.

    GadgetBandit
    I've been getting the same thing, I think 2k1 has spotted a few bugs. Trying to figure out a way around the very error you're getting caused me to find the problems I've posted here - the analog_in not evaluating correctly and a digital output not evaluating as true and kicking into the output node (or as == 1).

Page 1 of 2 12 LastLast

Similar Threads

  1. INFILL G4 - Australian and New Zealand Questions Answered
    By INFILLG4 in forum General MP3Car Discussion
    Replies: 20
    Last Post: 04-30-2008, 12:21 AM
  2. Replies: 8
    Last Post: 05-19-2007, 07:39 PM
  3. Replies: 8
    Last Post: 03-25-2007, 10:20 PM
  4. Replies: 4
    Last Post: 12-29-2006, 01:16 PM
  5. Replies: 4
    Last Post: 04-18-2004, 11:50 PM

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
  •