How about String Variables?


Closed Thread
Results 1 to 40 of 41

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    Mine can be if I put all 6 monitors vertically in portrait mode. LMAO!

    Robert
    :P

  2. #2
    Join Date
    Jan 2009
    Posts
    78


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    you have a high ceiling house Demon...

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    OR small screen
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    OK Now that last string of posts are just about the funniest thing I have read around here in a while.

    Or else I am just so tired that I need to get some sleep... Been chasing satelite outages for the last 14 hours and about 500 miles. Spacenet decided to change frequencies in the middle of last night and I woke up to 16 sattelites down. (we use them to bring in electricity load information on a 5 minute basis from major substations in Utah, Wyoming and Nevada.

    Probably just tired...

    You guys and gals are a great bunch.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  5. #5
    Join Date
    Jul 2011
    Posts
    35


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    Yeah, how about STRING variables?????


    Strings are needed ALL THE TIME! I wish PBP would face the music and implement them! Every other compiler I see has them, why not PBP? (And No, I don't want to switch because I've got years and $ invested in this one.)

  6. #6
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    There are many other features besides strings available in other compilers that are not available in PBP.
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    I like strings as well. All my projects have either RS-232 or Ethernet connectivity, and they all have
    menus, user input, etc. I need to handle strings constantly.

    I generally put all my strings into arrays. This is the only way they can be manipulated. Check out
    the ARRAYWRITE command. It is an easy way to load and clear arrays.

    Here is some stuff that I cobbled together that may help the situation. Note that I pulled this from
    various programs, so it has not been tested completely, although most routines should work as-is.
    Use at your own risk!

    Lester may want to move this into the 'code examples' section later.



    Code:
    ;----------------------------------------------------------------------        
            IgnoreCase var bit
            Xs var byte
            Ys var byte
            Zs var byte
            Js var byte
            Ws var byte
            Cmd var byte
            Length1 var word
            Length2 var word
            MaxSearchLen var byte
          
            Str1ArrayLength CON 30
            Str2ArrayLength con 30
            
            MaxCompareLength var byte
            
            Str1 var byte[Str1ArrayLength]
            Str2 var byte[Str2ArrayLength]
    ;---------------------------------------------------------------------------       
       ; Zero out the strings 
         arraywrite Str1,[rep 0\Str1ArrayLength]
         arraywrite Str2,[rep 0\Str2ArrayLength]
    
    ;--------------------------------------------------        
        
    ; Fill input arrays with some test stuff      
           
          ARRAYWRITE Str1,["0123456789ABCDEF"]
          arraywrite Str2,["345"]
    ;-------------------------------------------------      
    
    'LeftString:  ; Str2 contains the leftmost chars of Str1
    ;     Ys = Number of Chars to separate off from Str1      
            YS = 6  ; for testing only
            
    
          If Ys != 0 then 
             For Js = 0 to YS-1
                Str2[Js] = Str1[Js]
             next Js
                Str2[Js] = 0  ; make certain we always end with a nul
          endif  
         return 
    ;----------------------------------------------------  
    ;----------------------------------------------------  
         
    MidString: ; Str2 contains a string of Ys chars derived from Str1 starting at position Zs (zero based) 
        
        ys = 2 :Zs = 4 ; for testing only
    
          If Ys !=0 then
            For Xs = Zs to ((Zs + Ys)-1)
               Str2[Xs-Zs] = Str1[Xs]
            next Xs
               Str2[xs] = 0  ; terminate with a nul
          Endif
           return
    
    ;-------------------------------------------------------------------------------------
    
    RightString:  ; Str2 contains a string consisting of the right-most chars (number defined by Ys) of Str1 
          
           Ys = 4   ; for testing only
    
           Js = Ys - 1
           for xs = Str1ArrayLength to 0 step - 1
                 If Str1[xs] != 0 then
                     Str2 [Js] = Str1[Xs]
                     if Js = 0 then DoneRS
                     Js = Js-1
                  endif
          next xs
    DoneRS:
    ;      return              
    ;---------------------------------------------------------------------------------------         
    LenSTring:  ; Ys contains the length of STR1        
            Js= 0
            While Str1[JS] != 0
               JS = Js + 1
            wend 
            if Js > 1 then  
               Ys = Js - 2 
            else
               YS = 0
            endif  
    ;        return     
    ;----------------------------------------------------------------------------------------        
    InString:   ; Ws contains the position in STR1 where the match with STR2 started
                ; if there is no match, Ws contains 255
                ; if Ignore Case is set to '1', it will, of course, ignore the case.
                
            MaxCompareLength = Str1ArrayLength Min Str2ArrayLength 
            for Xs = 0 to Str1ArrayLength
               If IgnoreCase then 
                    Str2[0] = Str2[0] & %11011111  
                    Str1[Xs] = Str1[XS] & %11011111
               endif     
                   If Str2[0] = Str1[Xs] then   ; Found a match on 1st char of Str2
                   
                   Ws = Xs
                   Js = 1
                     for Ys = Xs + 1 to MaxCompareLength
                        if Str2[Js] = 0 then FoundMatch  ; hit the end of Str2
                           If IgnoreCase then 
                               Str2[Js] = Str2[JS] & %11011111  
                               Str1[Ys] = Str1[Ys] & %11011111
                           endif     
                        if Str2[Js] != Str1[Ys] then NoMatch
                        Js = Js + 1
                     next Ys
                     goto FoundMatch
                  endif
            next Xs            
    NoMatch:
          WS = 255
          return
    FoundMatch:
          return               
    
    ;-----------------------------------------------------------------------------------               
    CommandParser:
    ; Fast searcher! Case sensitive.  Closely based on info provided by Darrel Taylor.
    ; Searches through Str1. If it finds the strings listed in the quotes, it returns which one it found.
    ; the max length of STR1 that will be searched is in MaxSearchLen
       
        Cmd = 255  ; In case of no match
        MaxSearchLen = 20            
     
        Parse01: Cmd=01 : ARRAYREAD Str1,MaxSearchLen,Parse02,[WAIT("Command1")] : GOTO Foundit
        Parse02: Cmd=02 : ARRAYREAD Str1,MaxSearchLen,Parse03,[WAIT("Age")] : GOTO Foundit
        Parse03: Cmd=03 : ARRAYREAD Str1,MaxSearchLen,Parse04,[WAIT("Weight")] : GOTO Foundit
        Parse04: Cmd=04 : ARRAYREAD Str1,MaxSearchLen,Parse05,[WAIT("Address")] : GOTO Foundit
        Parse05: Cmd=05 : ARRAYREAD Str1,MaxSearchLen,Parse06,[WAIT("Command5")] : GOTO Foundit
        Parse06: Cmd=06 : ARRAYREAD Str1,MaxSearchLen,Parse07,[WAIT("Command6")] : GOTO Foundit
        Parse07: Cmd=07 : ARRAYREAD Str1,MaxSearchLen,Parse08,[WAIT("Command7")] : GOTO Foundit
        Parse08: Cmd=08 : ARRAYREAD Str1,MaxSearchLen,Parse09,[WAIT("Command8")] : GOTO Foundit
        Parse09: Cmd=09 : ARRAYREAD Str1,MaxSearchLen,Parse10,[WAIT("Command9")] : GOTO Foundit
        Parse10: Cmd=10 : ARRAYREAD Str1,MaxSearchLen,Parse11,[WAIT("Command10")] : GOTO Foundit
        Parse11: Cmd=11 : ARRAYREAD Str1,MaxSearchLen,Parse12,[WAIT("Command11")] : GOTO Foundit
        Parse12: Cmd=12 : ARRAYREAD Str1,MaxSearchLen,Parse13,[WAIT("Command12")] : GOTO Foundit
        Parse13: Cmd=13 : ARRAYREAD Str1,MaxSearchLen,Parse14,[WAIT("Command13")] : GOTO Foundit
        Parse14: Cmd=14 : ARRAYREAD Str1,MaxSearchLen,Parse15,[WAIT("Command14")] : GOTO Foundit
        Parse15: Cmd=15 : ARRAYREAD Str1,MaxSearchLen,Foundit,[WAIT("Command15")] : GOTO Foundit
        
    Foundit:
        return
    
    ;-------------------------------------------------------------------------------------------
    Charles Linquist

Similar Threads

  1. How to convert HEX Value as formatted BIN String ?
    By Robson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2007, 03:16
  2. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 05:39
  3. Variables not appearing in Watch Window MPLabv7.3
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th June 2006, 15:36
  4. String Parsing
    By eoasap in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th February 2006, 18:20
  5. Message String Table using Readcode
    By mytekcontrols in forum Code Examples
    Replies: 2
    Last Post: - 11th July 2005, 00:17

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