Announcement

Collapse
No announcement yet.

Run Multiple Loops in the Main Loop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Run Multiple Loops in the Main Loop

    Hello
    I want to know if it's possible to run Multiple Loops in the main loop asynchronously?
    The reason for this is that I want the 4D Screen to talk to 2 serial devices/ Respond to two serial devices .

    Please help....

  • #2
    Don't need multiple loops, just set up the second one using a comms buffer (same as first one), then check com_count() for each sequentially in the single main loop
    Mark

    Comment


    • #3
      Thank you for the reply Mark,

      Do you maybe have some sort of example I can use?

      Comment


      • #4
        Hmm,

        Create a new Genie program (with nothing in it)

        Build it.

        Save as and select type of ViSi project.

        The main loop starts at line 419, the first block of code processes comm input, if any is ready, the second block of code processes the touch screen.

        Just duplicate the first block and change it to use com1.

        You will also need to duplicate the setup code for the comm port, say lines 387-389
        Mark

        Comment


        • #5
          So I did everything you told me to after that I added some code to read the com ports.After everything I build it and it had no errors but for some reason is my button disabled to go to the next Form.
          Is there something I'm missing?

          Comment


          • #6
            I can't imagine what that might be. Use File, Zip project and post it here.
            Mark

            Comment


            • #7
              Here it is, thank you for the help
              Attached Files

              Comment


              • #8
                Gee, you've modified that code quite a bit.

                You have added an 'extra' repeat forever loop that means the true main loop (that reads the com port and processes touch) will never be entered

                You've also got a second lot of comms inits that use the same comms buffer.

                Hard to know just what's meant to happen with all that odd code.
                Mark

                Comment


                • #9
                  So I did some changes and got it right, but now I've got a second problem.

                  I want to use a if statement to switch to the second form but it's not working

                  Please Help

                  Here is my code:

                  char_com0 := serin(); //Returns: -1 if no character is available
                  if (char_com0 >=0) // is there a character?
                  reply := Form1();
                  serout1(char_com0); // send to com1
                  endif

                  //characters on com1
                  char_com1 := serin1(); //Returns: -1 if no character is available
                  if (char_com1 >=0 )
                  reply := Form1();
                  serout(char_com1); // send to com0
                  endif

                  Comment


                  • #10
                    I'm not sure what Form1(); is meant to do, or really what you are trying to achieve.

                    If you want to activate form 1 then ActivateForm(1); is what you need.
                    Mark

                    Comment


                    • #11
                      Wow it's really that simple!! It works thanks a lot Mark :D

                      Comment

                      Working...
                      X