News:

  • August 18, 2026, 05:29:00 AM

Login with username, password and session length

Author Topic: Jump on STRFIND  (Read 11360 times)

jcottrill

  • Full Member
  • ***
  • Posts: 43
Jump on STRFIND
« on: January 12, 2018, 11:13:51 AM »
Would it be possible to add a jump option on FINDSTR to avoid needing to set and later read a bit?  This is available in tools like STREAMOUT and would be nice to see with the string tools.   

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Jump on STRFIND
« Reply #1 on: January 12, 2018, 11:35:08 AM »
Interesting idea.  I will add it to the wish list.

jcottrill

  • Full Member
  • ***
  • Posts: 43
Re: Jump on STRFIND
« Reply #2 on: January 12, 2018, 11:53:08 AM »
Thanks!  It's not hard to setup bits but if you have a couple dozen decision paths off a single string you wind up with a bunch of bits that have no purpose other than helping you make a jump. 

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Jump on STRFIND
« Reply #3 on: January 12, 2018, 12:10:34 PM »
Do you need more of a table lookup, e.g. STRLOOKUP trying to find one of a list of possible strings from the same source input string and string index, so returning a search lookup index (e.g. found string at instruction lookup table index 0, or found the string at lookup table index 1, or found the string at lookup table index 2, or..., or -1 if none of them were found in the STRTABLEFIND.  If you got that index, then you could use a single JMPI following the STRLOOKUP if the resulting lookup table index was >= 0.

Or are you parsing along a string and looking/extracting for the next thing based on what you found, and doing actual sequencing as you parse tokens out of a complex string.

Both are typical coding patterns, regardless.

jcottrill

  • Full Member
  • ***
  • Posts: 43
Re: Jump on STRFIND
« Reply #4 on: January 12, 2018, 12:53:16 PM »
The table lookup is an even better solution as it would simplify the ladder logic and I'm a bit ashamed I didn't think of that.  Is STRLOOKUP a featured function in Do-More or do I just need to implement the functionality in code?  I tried searching the docs but couldn't find anything.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: Jump on STRFIND
« Reply #5 on: January 12, 2018, 01:37:28 PM »
The table lookup is an even better solution as it would simplify the ladder logic and I'm a bit ashamed I didn't think of that.  Is STRLOOKUP a featured function in Do-More or do I just need to implement the functionality in code?  I tried searching the docs but couldn't find anything.

It's NOT there.

But you could create a SUBROUTINE to calculate the equivalent STRLOOKUP index using a FOR/NEXT loop in the subroutine with a, a block of predefined matching tokens (Token0 match would return 0, Token1 would return 1, etc.) and use STRFIND.

So from your Stage Program, you would have a CALL to your StrLookup subroutine.  Then after the CALL, look at the returning index (say in D100) then do your JMPI.

jcottrill

  • Full Member
  • ***
  • Posts: 43
Re: Jump on STRFIND
« Reply #6 on: January 12, 2018, 01:41:49 PM »
Yep, just making sure I wasn't missing something.  Thanks again for the info.