|
 |
02-19-2009, 02:39 PM
|
#1
|
|
Low Bitrate
Join Date: Jun 2004
Posts: 98
|
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?
|
|
|
|
|
|
Advertisement
|
Sponsored links
|
02-20-2009, 12:32 AM
|
#2
|
|
Fusion Brain Creator
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
|
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.
|
|
|
02-20-2009, 04:36 PM
|
#3
|
|
Low Bitrate
Join Date: Jun 2004
Posts: 98
|
Quote: Originally Posted by 2k1Toaster 
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 
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
|
|
|
02-20-2009, 05:15 PM
|
#4
|
|
Low Bitrate
Join Date: Jun 2004
Posts: 98
|
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?
|
|
|
02-24-2009, 12:21 AM
|
#5
|
|
Low Bitrate
Join Date: Oct 2008
Posts: 87
|
Var = False
What does the block look like for:
If Var = "True"
Do Function
Do I have to do a boolean comparison?
Thanks,
GadgetBandit
|
|
|
02-24-2009, 03:24 AM
|
#6
|
|
Fusion Brain Creator
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
|
Quote: Originally Posted by Iamthehor 
????? 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.
Quote:
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.
Quote:
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.
Quote:
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 
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 
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.
|
|
|
02-24-2009, 01:14 PM
|
#7
|
|
Low Bitrate
Join Date: Jun 2004
Posts: 98
|
Quote:
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.
|
|
|
02-24-2009, 02:50 PM
|
#8
|
|
Fusion Brain Creator
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
|
Quote: Originally Posted by Iamthehor 
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!
|
|
|
|
Sponsored links
|
|
Advertisement
|
|
02-24-2009, 07:10 PM
|
#9
|
|
Low Bitrate
Join Date: Oct 2008
Posts: 87
|
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
|
|
|
02-24-2009, 10:58 PM
|
#10
|
|
Low Bitrate
Join Date: Jun 2004
Posts: 98
|
Quote: Originally Posted by GadgetBandit 
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).
Last edited by Iamthehor; 02-24-2009 at 11:01 PM.
|
|
|
02-24-2009, 11:13 PM
|
#11
|
|
Low Bitrate
Join Date: Jun 2004
Posts: 98
|
Quote: Originally Posted by 2k1Toaster 
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! 
I'll keep that in mind so that i don't beat my head against the wall for so long next time, I'll just blame it on you. Other than the frustrating problems I've been running into, the more I use MDX, the more I like it. Very powerful, very flexible. I think I'm going to have the most trouble with the graphics side, I suck at photoshop.
Keep up the good work. Patiently waiting for my v4 to arrive so that i can start putting my Fireworks Launcher together.
|
|
|
02-25-2009, 01:23 AM
|
#12
|
|
Fusion Brain Creator
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
|
Update went out to fix the crashes. As for the function is unreadable, that was put in as a safety check because people were tying things like multiplication blocks to outputs and wondering why it wouldnt work. I will try to clean up the code in there to be smarter.
-- Nick
|
|
|
02-25-2009, 08:13 PM
|
#13
|
|
Low Bitrate
Join Date: Oct 2008
Posts: 87
|
Is this button not working, me(I am lucky to be consistantly hittin' on 3 cylinders) or the boolean issue?
<button id="My Display Button 1" enabled="yes" function="change variable" functionTargetID="boolean_1" vote="attached" vote_opinion="True" vote_priority="High">
<images imagePrimary="content . . . \Blank B.png"></images>
<display size="400, . . . er="0"></display>
<vote_options minimum_delta_vote_time_down="20" minimum_delta_vote_time_up="20"></vote_options>
<up_click up_click_function="change variable" up_click_functionTargetID="boolean_1" up_click_vote_opinion="False" up_click_vote="attached" up_click_vote_priority="High"></up_click>
</button>
I'm assuming that I still have to declare the variable. a text label only displays the declared "False".
GadgetBandit
|
|
|
02-25-2009, 08:25 PM
|
#14
|
|
Fusion Brain Creator
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
|
Quote: Originally Posted by GadgetBandit 
Is this button not working, me(I am lucky to be consistantly hittin' on 3 cylinders) or the boolean issue?
<button id="My Display Button 1" enabled="yes" function="change variable" functionTargetID="boolean_1" vote="attached" vote_opinion="True" vote_priority="High">
<images imagePrimary="content . . . \Blank B.png"></images>
<display size="400, . . . er="0"></display>
<vote_options minimum_delta_vote_time_down="20" minimum_delta_vote_time_up="20"></vote_options>
<up_click up_click_function="change variable" up_click_functionTargetID="boolean_1" up_click_vote_opinion="False" up_click_vote="attached" up_click_vote_priority="High"></up_click>
</button>
I'm assuming that I still have to declare the variable. a text label only displays the declared "False".
GadgetBandit
all variables must be declared in the variable section or they do nothing.
And there is no more more boolean issue, the update last night fixed it.
|
|
|
02-25-2009, 10:58 PM
|
#15
|
|
Low Bitrate
Join Date: Oct 2008
Posts: 87
|
I used this compter for a presentation and had turned off the updater.
This is cool stuff your doing!!
GadgetBandit
|
|
|
|
Sponsored links
|
|
Advertisement
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:56 PM.
| |