Randomize 2 values -- ideas?
+ Reply to Thread
Results 1 to 3 of 3

Hybrid View

  1. #1

    Default Randomize 2 values -- ideas?

    I have 2 variables --

    BRON VAR 224

    BROFF VAR 0

    I know I can use SWAP to do just that but trying to figure out a way I can possibly setup another variable that will give me either 224 or 0 on a random basis. I'm thinking it's impossible but maybe someone can offer something. RANDOM uses too many possibilities but my goal, like I say are just these 2 values. And it wouldn't have to be a prefect random, just the appearance of it. ??

    Thanks, although I think I'm dreaming on this.

  2. #2

    Default Re: Randomize 2 values -- ideas?

    Seems like EVERYTIME I post, I think of something 5 minutes later. Maybe use RANDOM and then an IF statement

    IF # is > than or < than that should do it I'm thinking.

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,193

    Default Re: Randomize 2 values -- ideas?

    Code:
    BRON CON 224
    BROFF CON 0
    
    RandVal var byte
    GetVal var byte
    
    Start:
    
        Random RandVal
        if RandVal // 2 = 0 then 
            getval = BRON 
        else
            getval = BROFF
        endif
    
    goto start
    
    Or
    
    Start:
    
    
        if TMR0 // 3 = 0 then 
            getval = BRON 
        else
            getval = BROFF
        endif
    
    goto start
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Project ideas
    By lockjawz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th May 2011, 00:34
  2. Project ideas 2
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th February 2011, 18:59
  3. Project ideas
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th May 2010, 23:34
  4. Multitasking Ideas
    By HYETİK in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 15th April 2009, 07:50
  5. Any ideas on how to accomplish this?
    By bartman in forum General
    Replies: 18
    Last Post: - 27th January 2007, 01:48

Members who have read this thread : 20

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