Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting a MuiCycle event and its selected option
#9
Okay, there are some strange things with your program for me. First off is that MUIWaitEvent is a little bit broken, and program flow continues even if no event has occurred. I don't know why that is but I suspect a bug in the MUI library that makes it behave identically to MUIEvent. This means that the loop runs constantly, which it should not. This in itself still isn't a real problem, except that you're checking the event code for the value of MyChoice, but that's always going to be zero as well. MyChoice2 is also going to be zero, but once one Case of a Select is triggered, all the other Cases are ignored. Because the event is triggered constantly with a 0, and MyChoice is also 0, it's always the first entry that triggers. That works correctly though, displaying the value of the entry in the first cycle gadget. It means that the code for reading the second cycle gadget should work but never gets to run.

You'll notice that the value is displayed even when the notifies for the cycle gadgets are commented out. Again, this is because your loop is running constantly and always triggering the first Case with 0 = 0. I'm not sure exactly what you were trying to do with the notifies, but the MUISet method requires two arguments following it: the attribute to set and the value to set it to. It doesn't set a variable contents, and you need to use a special #MUIV_ constant to set an attribute to the value of another gadget. That would be used for automatically setting a string gadget to the value of a slider for example, but can't be used for setting variables. so those notifies are effectively doing nothing (and maybe writing garbage to memory in some cases so be careful...)

What you need to do is first set up your loop so it only responds to event codes other than zero, then you need to either use MUINotifyApp to send the events to the application, or use MUINotify with the application object as a target (which is just what MUINotifyApp does anyway). So swap this code for the second part of your program and see the difference:
Code:
MUINotifyApp 11,#MUIA_Window_CloseRequest,1,-11
MUINotifyApp 2,#MUIA_Cycle_Active,#MUIV_EveryTime,2
MUINotifyApp 3,#MUIA_Cycle_Active,#MUIV_EveryTime,3

success=MUIOpenWindow (11)


Repeat
  ev.l=MUIWaitEvent
  Select ev
    Case 2
      cy=MUIGetCycle (2)
      NPrint "MyChoice is CyTest ",cy+1
    Case 3
      cy=MUIGetCycle (3)
      NPrint "MyChoice is CyTest ",cy+4
    End Select
Until ev=-11

MUICloseWindow 11

End
It works for me with the rest of your program untouched, and I think it's what you're looking for. The notifies set up an event code of 2 for the first cycle gadget and 3 for the second cycle gadget. The main loop then only responds on a 2 or a 3. It should never respond on a 0, because that means no event occurred.
Zitieren


Nachrichten in diesem Thema

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 3 Gast/Gäste