Modifying a variable?


Closed Thread
Results 1 to 3 of 3
  1. #1
    ybrisson's Avatar
    ybrisson Guest

    Default Modifying a variable?

    Hello all,

    I would like to know if there's a way to minimise the number of
    "IF THEN" in this following (simplified) situation.
    (I'm new to picbasic!).


    value VAR byte

    x VAR byte

    y0 VAR byte
    y1 VAR byte
    y2 VAR byte
    y3 VAR byte
    .
    .
    .
    y15 VAR byte 'or y VAR byte[16]?


    If x = 0 Then y0 = value
    If x = 1 Then y1 = value
    If x = 2 Then y2 = value
    If x = 3 Then y3 = value

    ... and so forth

    So is there a way to modify variable "y" by using the "x" one?

    ie: yx, y.x, y[x], ???

    Thank you
    Last edited by ybrisson; - 9th October 2003 at 13:13.

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    This is an alternative you can consider...

    value var byte
    x var byte
    y var byte [16]

    For x=0 to 15
    if y[x]=x then y[x]=value
    next x

    Melanie

  3. #3
    Billyc's Avatar
    Billyc Guest


    Did you find this post helpful? Yes | No

    Angry PicBasic Pro and PicBasic use different syntax for their compilation source programs

    Can any one shed light on Melabs Compilers PicBasic Pro & PicBasic . THey have different suntaxes declaring /defining variables syntax is totally different. I bought the PicBasic Standard compiler and the manual that comes with it is really really bad. Can anyone direct me to a tutorial paid or unpaid that simply shows the user how to write the correct PicBasic code for THE PICBASIC COMPIIER (Micro Engineering Labs, Inc)it's worth a bottle of Newcastle BRown ! Why do they make it so confusing and why don't they make the syntax the same for both versions of the compiler!! A reply would be appreciated WWC Bolton MA 01740 USA

Similar Threads

  1. EEPROM Variables (EE_Vars.pbp)
    By Darrel Taylor in forum Code Examples
    Replies: 79
    Last Post: - 26th October 2012, 00:06
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. set flags within a variable?
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 24th October 2006, 11:07
  5. WORD vs BYTE variable lengths
    By bartman in forum General
    Replies: 0
    Last Post: - 28th November 2005, 21:16

Members who have read this thread : 1

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