Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: mhw on September 05, 2013, 12:24:39 PM

Title: STRFIND
Post by: mhw 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


Title: Re: STRFIND
Post by: plcnut 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?
Title: Re: STRFIND
Post by: franji1 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
Title: Re: STRFIND
Post by: mhw 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
Title: Re: STRFIND
Post by: franji1 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)
Title: Re: STRFIND
Post by: plcnut 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.