Lookdown command the result not consistent


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    Quote Originally Posted by Charles Linquis View Post
    I forgot to mention -

    If you want to grab the data and don't want to sit around and wait to see if it is OK,
    you can use the following structure:


    Code:
     
    Parse01: Cmd=01 : ARRAYREAD Data_Array,20,Parse02,[WAIT("Status1?")] : GOTO Foundit
    Parse02: Cmd=02 : ARRAYREAD Data_Array,20,Parse03,[WAIT("Status2?")] : GOTO Foundit
    This is a small part of a command parser that I'm currently using. The data you want to test is placed in the array "Data_Array", it will look at the first 20 characters (of course you can change that), and if it finds "Status1?" it jumps to FOUNDIT: and Cmd contains the line where it was found (in this case, 1). If "Status1?" is not found in the string, it jumps to line 2, and checks for "Status1?"

    etc.

    I am sure it was supposed to be "Status2?", just to avoid any confusion here.
    And the previous example was indeed nice; smart.
    This second one is also nice (at least for me).
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

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


    Did you find this post helpful? Yes | No

    Default Re: Lookdown command the result not consistent

    No.

    Suppose that you have an input routine where a computer sends you a bunch of commands to parse, and you have to decode those commands. In my case, I have 45 different commands that I have to respond to. Two of those commands are "Status1?" and "Status2?". My incoming packet (it actually is a pre-processed Ethernet packet) is loaded into Data_Array.

    Say the packet contains "Status2?"

    In the first line in the code example above, I look for "Status1?" in the first 20 characters. Since it doesn't exist, I don't get a match and I jump to line 2 and search for "Status2?" in Data_Array. If it finds "Status2?" (which it will), then I jump to Foundit, and CMD = 2. A SELECT CASE structure using CMD then goes and performs the right thing.

    Another tip for those of you who handle a lot of strings (or ARRAYS as they must sadly be called in PBP):
    It is often very convenient to make the first element of the array (element 0) the length of the array.
    Charles Linquist

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