Change variable increment/decrement into mid-loop?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,127


    Did you find this post helpful? Yes | No

    Default Re: Change variable increment/decrement into mid-loop?

    And yes, CNT=1 should be added in the beginning, or absolutely unexpected behavior will be generated (just tested)

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Change variable increment/decrement into mid-loop?

    Regarding negative numbers, as long as both variables are of the same size what you did will work:
    Code:
    Cnt VAR BYTE
    Add VAR BYTE
    
    Cnt = 100
    Add = -1
    
    Cnt = Cnt + Add   ' Cnt now = 99
    But if Cnt was a WORD and Add a BYTE then Cnt woul equal 354.

Similar Threads

  1. Replies: 27
    Last Post: - 9th April 2015, 04:51
  2. Can not change variable while using DT_INT?
    By hvguy0 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 29th March 2013, 23:05
  3. Altering a variable in a loop.
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 18th September 2012, 06:24
  4. Change a variable to the opposite?
    By Hylan in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 21st June 2012, 07:00
  5. Let a variable change from bin to dec.
    By Roy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th May 2004, 19:57

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