basics programming


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Bonjour et bienvenue Olivier,

    Yes there is many different way. If you have multiple choice on multiple var it's a little bit more coding on your side. BUT if you have multiple conditions to test on a single var, and then jump to a specific routine, you have at least 3 choices

    1. few IF THEN

    Code:
            Choix VAR BYTE
            
    Start:
            '
            '       some code here
            '
            IF Choix=1 then gosub Routine1
            IF Choix=2 then gosub Routine2
            IF Choix=3 then gosub Routine3
            goto start
            
    Routine1:
            '
            '   plah plah plah
            '
            return
    
    Routine2:
            '
            '   plah plah plah
            '
            return
    
    Routine3:
            '
            '   plah plah plah
            '
            return
    SELECT CASE
    Code:
            Choix VAR BYTE
            
    Start:
            '
            '       some code here
            '
            SELECT CASE CHOIX
                CASE 1 
                    gosub Routine1
                    '
                CASE 2
                    gosub Routine2
                    '
                CASE 3
                    gosub Routine3
                    '
                END SELECT
                
            goto start
            
    Routine1:
            '
            '   plah plah plah
            '
            return
    
    Routine2:
            '
            '   plah plah plah
            '
            return
    
    Routine3:
            '
            '   plah plah plah
            '
            return
    BRANCHL
    but this one AS-IS, use GOTO, so, as Henrik said, you can't use RETURN without tricks
    Code:
            Choix VAR BYTE
            
    Start:
            '
            '       some code here
            '
            '       choix=   0      1         2         3
            '                '      '         '         '
            branchl choix,[Start,Routine1, Routine2, Routine3]
            goto start
            
    Routine1:
            '
            '   plah plah plah
            '
            goto start
    
    Routine2:
            '
            '   plah plah plah
            '
            goto start
    
    Routine3:
            '
            '   plah plah plah
            '
            goto start
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  2. #2
    Join Date
    Feb 2007
    Location
    France Bourgoin Jallieu
    Posts
    2


    Did you find this post helpful? Yes | No

    Smile Great

    Now i think, i have understood architecture of my program,

    Now i will try to create a sinus wave with variable duty cycle with a PIC18F458



    Thanks



    Olivier

Similar Threads

  1. Data Programming Error at 0000
    By cpatnoi in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 22nd May 2009, 03:37
  2. Problems programming
    By Lionheart in forum General
    Replies: 4
    Last Post: - 7th December 2008, 16:51
  3. PIC programming algorithm - where is it to find?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th June 2007, 18:31
  4. Some questions for programming
    By fnovau in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2006, 16:04
  5. MELab Programming
    By tarr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd March 2006, 13:36

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts