News:

  • October 18, 2026, 07:26:23 PM

Login with username, password and session length

Author Topic: STRFIND failing  (Read 6699 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3628
  • Darth Ladder
STRFIND failing
« on: February 26, 2021, 04:42:25 PM »
I am seeing STRFIND fail to find a substring that I know is present.   Here is an example:

Code: [Select]
STRFIND SL[V230] 0xC D1051 C71 ST1023 """@"""
It's in a task with a 3000 us time slice on continuous execution every 5 seconds.   The task has adequate time to complete on each invocation, because the .RunCounter member increments at the correct rate.   

It's processing multiple strings in a loop, and works at times, so the fact that its in a task with a time slice is the only thing I can figure that could have anything to do with it.   I'll try it in a program.

Also, what's with the triple quotes around the search string?   In the string entry box, I only see one set.

Update:  Moved the code (iterating through the indexes to the strings in a FOR-NEXT loop) to an unyielding program and it acts the same, so the yielding/slicing issue isn't the problem.  Almost always gets the first string right, but then STRFIND fails on some or all additional iterations even though I know the sought string is present.






« Last Edit: February 26, 2021, 07:04:36 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3628
  • Darth Ladder
Re: STRFIND failing
« Reply #1 on: February 26, 2021, 07:15:01 PM »
Here's the entire loops (2 nested loops):

Code: [Select]
STR ST1
STRCLEAR EmailAddrList0 16

FOR V230 10 10 1

STR ST1
STRTRIM SL[V230] 0x3

STR ST1
MATH D1050 "SL[V230].Length"
STRFIND SL[V230] 0xC D1051 C71 ST1023 """@"""
STRFIND SL[V230] 0xE D1052 C72 ST1023 """."""
MATH DST511 "(MHR[9110 + V230] & 15) | IF(C71 & C72 & (D1051 > 2) & (D1052 > (D1051 + 2)) & (D1050 > (D1052 + 2)), 1 << 15, 0)" "MHR[9110 + V230]"
MATH V231 "9110 + V230"

FOR V234 0 4 1

MATH MHR9150:0 "(MHR[V231] && (1 << V234)) > 0"

STR MHR9150:0
AND MHR[V231]:15
STRPRINT EmailAddrList[V234] 0x6 "SL[V230] ""; """

NEXT

NEXT

After posting this, I just noticed something very interesting -- the MATH box that cuts and pastes beginning with the result going to DST511, the result in DMD shows as  MHR[9110 + V230].   Is that the way DM looks at that destination internally or is it a glitch?

I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3628
  • Darth Ladder
Re: STRFIND failing
« Reply #2 on: March 01, 2021, 08:57:31 PM »
SOLVED:   The problem was that I was reusing the same box to evaluate multiple strings in a FOR loop without reinitializing between iterations.    The found index from the previous iteration became the search starting point for the current iteration.    Then once one fails, the 'found' index is set to -1, so the following evaluation works as expected.

Moral:   read the help on the instruction!!    ;D
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.