VAR array compile issue


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838

    Cool VAR array compile issue

    Hi guys, thanks for help to date and ill try and return the favor as i learn more about the pic programming.

    the following code will not compile when i use the variable T and loop , where if i expand the code out and assign a number in place of Varable T its very happy ,

    It there away to do this without expanding out the code and not use fixed number in place of varable T

    Regards

    sheldon

    Code:
    
            '-------------- Low Address /High Address /Data / Inv Data bytes  --------------        
       For T = 1 to 4            
        FOR Index = 7 TO 0 step -1               ' Loop for 8 bits data start at bit 7-0 and send
           IF STDByte[T].0[Index] = 0 THEN        ' Get polarity of each data bit to send
            Space = Zero                         ' Pulse time = Burst (560us) + Zero (560us) = 1.12mS for a "0" data bit
           ELSE
            Space = One                          ' Pulse time = Burst (560us) + One (1680us) = 2.24mS for a "1" data bit
          ENDIF
         
           GPIO.0 = 0                            ' Set Output low
           pauseus Burst                         ' load the burst for 0.56ms       
           GPIO.0 = 1                            ' Set Output high
           pauseus space                         ' High for duration of either Zero or One value ,for each address/data b
           Total[T] = Total[T] + space + burst   ' store total time of string  
        NEXT Index                               ' Loop until 8 data-bits sent of DByte(X)
       Next T

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,182


    Did you find this post helpful? Yes | No

    Default Re: VAR array compile issue

    Have a variable like
    Code:
    Temp VAR BYTE
    Then swap the variables in your array.
    Your new code will look like below.

    Code:
            '-------------- Low Address /High Address /Data / Inv Data bytes  --------------        
       For T = 1 to 4            
        
        FOR Index = 7 TO 0 step -1               ' Loop for 8 bits data start at bit 7-0 and send
           
           temp = STDByte[T]
           
           IF temp.0[Index] = 0 THEN             ' Get polarity of each data bit to send
            Space = Zero                         ' Pulse time = Burst (560us) + Zero (560us) = 1.12mS for a "0" data bit
           ELSE
            Space = One                          ' Pulse time = Burst (560us) + One (1680us) = 2.24mS for a "1" data bit
           ENDIF
    
           STDByte[T] = temp
         
           GPIO.0 = 0                            ' Set Output low
           pauseus Burst                         ' load the burst for 0.56ms       
           GPIO.0 = 1                            ' Set Output high
           pauseus space                         ' High for duration of either Zero or One value ,for each address/data b
           Total[T] = Total[T] + space + burst   ' store total time of string  
        NEXT Index                               ' Loop until 8 data-bits sent of DByte(X)
        
       Next T
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: VAR array compile issue

    thanks Sayzar , but i tried that before i posted , and just then , still get bad expression error and syntax error , using picbasic pro 5.0.0.0 , pbpx 3.0.4.1

    is there something i am missing ??

    Cheers

    sheldon


    temp = STDByte[T] - bad expression error
    STDByte[T] = temp - syntax error

  4. #4
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: VAR array compile issue

    i think i found the issue i forgot to define dbbyte var when i changed it over from dbyte1, cheers

Posting Permissions

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