07-22-2005 11:00 AM
07-22-2005 01:54 PM
Wow,
That is really neat. I never would have thought to do it that way.
I started it by dividing the two and putting it through a integer case structure, but I never could figure out how to set the damn case structure up and get it to work. For my own curiosity, which may also help for my last project, how would I setup a case structure if I took hits/bats outside of the case structure put that value through the case structure then out of the case structure to display the outcome on a message? I'm assuming I need to multiple the value by 1000 and divide on the outside, since the interger can't be decimal values.
I was thinking I could take an integer case structure using three scenerios one being if 0 then no at bats would be the result, if between 0 and .300 then keep swinging then greater then .300 potential hall of famer. This seemed like an easier approach then what you submitted (I would have no way thought of setting it up that way, but i'm sure there are multiple ways of doing the same thing).
This is an interesting program as mentioned, I think this portion of the class, the few weeks that it was with little to no assistance is not very helpful. It really needs to be taught with more instruction and on hands help. (the now, 20 total minutes of lecture time was taught/shown on a projector screen, no instruction help is/was given when we actually had the program in our hands).
Hopefully this will help me with the last project that is due...which I'm dreading. You guys are more help then the professor. All I asked from him was some sort of example that had similar properties to it...he never provided a damn thing.
Bob
07-22-2005 02:04 PM
07-22-2005 03:39 PM
I certainly am not the expert as you are by any stretch of the imagination...lol. How do you say in the case structure values up in the little box greater then something but less then something else?
Respectfully, It would seem that it would work. Once again, I’m not as knowledgeable as you are so i'll play the devils advocate...I just want to understand how these things work...lol Your setup worked perfectly I just never would have thought to do it that way...I wish I did so I would have received more points for completing the problem.
When I did it, I called the default default value 0 to show "no at bats" and wired it to the outside of the case structure. I had no idea how to set up the other part of the case structure. I know that "..300" meant less then or equal to 300, and "300.." meant 300 or greater, I didn't now how to put the case structure so it said something like greater then 0 but less then 299 for the "keep practicing" and greater then 300 for potential hall of famer. The reason why I used 300 is it needs an integer value...so no matter what the value is from the division outside the box, as long as it is multiplied by 1000 before the case structure it should work?
Thanks for your comments!
Bob
07-22-2005 03:42 PM
07-22-2005 05:10 PM
You would say e.g. "1..299".
@bobl7777 wrote:
I certainly am not the expert as you are by any stretch of the imagination...lol. How do you say in the case structure values up in the little box greater then something but less then something else?
@bobl7777 wrote:
When I did it, I called the default default value 0 to show "no at bats" and wired it to the outside of the case structure. I had no idea how to set up the other part of the case structure.
07-22-2005 05:48 PM
07-23-2005 04:05 PM
@bobl7777 wrote:
I suppose one flaw I noticed was if I put 17 hits in it and 15 at bats, then it didn't display the correct statement...but it's impossible to hit more then what you were at bat. How would I limit this?
07-23-2005 09:27 PM
"Another, simpler, alternative would be to add an external case structure which will check whether hits is equal to or smaller than at bats and if it isn't, wire the proper error message into the string."
Good point. Ok just to test this out...I have attempted to do as you say though can't get that to work:-(. I am unsure about a few things. Actually, the sign that I woudl need is greater then (x>y) correct? From what I understand, if x (hits) is greater then y (at bats), then the value is true, if not then false. I was thinking to put it on the before the case structure, then run it into anohter...though that won't work. I can state this out verbally, just not get it to work.
My thoughts on how it should run "if hits >bats true then (new case structure) text to display "hits cannot be greater then at bats". If hits > bats is false then go through everything else as previously written. Problem I see is how to wire up > sign.
Some help please:-).
07-23-2005 10:35 PM
Well, you just wire the two inputs to the comparison operations. Now place a case structure around your existing case structure and wire the comparison output to the selector terminal.
One case will contain the old case structure and the other case will only contain a string diagram constant containing your error message. Both feed to the indicator.
- Outer case checks for at-bats=0 as before.
- if at-bats is not zero (default) do the division and decide between three cases:
(1) 0..299 -> keep swinging
(2) 300..1000 -> potential hall ...
(3) Default: -> Hits>at bats (result >1000)
This should take care of all possibilities. Notice that I use unsigned integers (U32) for the inputs so negative inputs cannot occur. Otherwise you would also need to check if the inputs are negative and create another error if this is the case.