News:

  • September 22, 2026, 05:51:13 AM

Login with username, password and session length

Author Topic: STRFIND  (Read 13063 times)

mhw

  • Hero Member
  • *****
  • Posts: 250
STRFIND
« on: September 05, 2013, 12:24:39 PM »
I am trying to take a date (11/12/2013) from a string and place it into a UDT memory address. Following is some code to test the concept. The first time through it will move the one or two digits before the / and move them into UDT, and then delete those digits and the /. The second time it turns the not found bit on in the STRFIND instruction. The third time it will work as expected. Whatup??

Code: [Select]
SG $Main.S0

STR C10
STRFIND SS0 0x2 D2 C0 C1 """/"""
RST C10

STR C0
JMP $Main.S1
RST C0

SG $Main.S1

STRSUB SS0 0 0x0 D2 SS1
STR2INT SS1 10 UDT0.Month DST511
MATH D3 "D2 + 1"
STRDELETE SS0 0 D3
STRTRIM SS0 0x3
JMP $Main.S0

NOP



plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: STRFIND
« Reply #1 on: September 05, 2013, 12:41:30 PM »
Works fine for me.
Do you have the latest release of designer?
Have you updated the OS in the processor?
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: STRFIND
« Reply #2 on: September 05, 2013, 12:59:46 PM »
I think D2 must be reset back to 0 at the bottom of S1 since you are adjusting the string contents?

or at the top of S0 - that's probably better
« Last Edit: September 05, 2013, 01:01:20 PM by franji1 »

mhw

  • Hero Member
  • *****
  • Posts: 250
Re: STRFIND
« Reply #3 on: September 05, 2013, 01:03:46 PM »
Quote
I think D2 must be reset back to 0 at the bottom of S1 since you are adjusting the string contents?

That worked. Thanks

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: STRFIND
« Reply #4 on: September 05, 2013, 01:09:06 PM »
Did you see my edit - probably at the top of S0 instead of the bottom of S1 (i.e. you should always starting from 0 whenever you enter S0, the STRFIND stage).

Probably do a
MOVE 0 D2
in the same rung driving the STRFIND (i.e. whenever C10 is ON)

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: STRFIND
« Reply #5 on: September 05, 2013, 01:12:12 PM »
Sorry about that, It was stripping all but the 2013 and so I assumed it was fine...
Glad it's working for you.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com