Shop OBEX P1 Docs P2 Docs Learn Events
Find value from longfill — Parallax Forums

Find value from longfill

bennettdanbennettdan Posts: 614
edited 2010-12-30 14:12 in Propeller 1
Hello,
What I want to know is how to loop through say three longs that i have used the "LONGFILL" instruction to enter the values to see if they match a know value then execute a function if they match.

Comments

  • andrewsiandrewsi Posts: 59
    edited 2010-12-29 20:01
    I'd love to try to help, but I'm finding your description very hard to understand. LONGFILL will take a certain value and fill a range of memory with that value repeatedly. What are you trying to compare, and what are you trying to accomplisb?
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-12-29 23:22
    As Andrew points out, longfill will fill the group of longs with the same value -- longmove copies a set of values from one location to another. You could write a simple compare method like this to see if one set of longs matches another:
    pub lcompare(pntr1, pntr2, len) | count
    
      count := 0
    
      repeat len
        if (long[pntr1][count] == long[pntr2][count])
          count += 1 
        else
          quit 
    
      return (count == len)
    

    You have to pass the addresses of the arrays you want to check, as well as the length. If they match, you get true back, otherwise false.
  • AribaAriba Posts: 2,690
    edited 2010-12-30 03:34
    If you define the 3 longs as an array, then you can access them easy.
    VAR
     long longvars[3]
     long ok, i
    
    PUB TestIt
      longfill(@longvars, 9999, 3)  'fill the 3 longs
      ok := true
      repeat i from 0 to 2
        if longvars[i] <> 9999      'test if value matches
          ok := false
    
    If you only have a pointer to the 3 longs then use the methode that JonnyMac shows.

    Andy
  • bennettdanbennettdan Posts: 614
    edited 2010-12-30 14:12
    Thanks Andrew, Jon and Andy
    Let me see if I understand you gentlemen right if I have the Pointer name and Length of the long I am looking for then Jon's example will return true it if it is match. If I want to scan each Value in an array of longs then Andy's example will look at each Value not just the name and length. Is this Correct?
Sign In or Register to comment.