Andy Purdey
18th July 2016, 13:20
Hi Guys,

Please take a quick look at the code below -

type = whinh.dll0000.convert.oorg.to.tord(temp)

if type = whltc.tord.production then

select whltc510.serl
from whltc510
where whltc510._index3 = {:type,
:whinr110.orno,
:whinr110.pono,
:whinr110.item}
selectdo
whinr110.qstk = 1
serial = tcyesno.yes
record = strip$(whltc510.serl)
exist = pos(record,record.hold)
if exist = 0 then
if addr.q = tcyesno.no then
rprt_send()
else
write.output.file()
endif
endif
if exist = 0 then
record.hold = concat$("|",record,record.hold)
endif
selectempty
whltc510.serl = ""
serial = tcyesno.no
if addr.q = tcyesno.no then
rprt_send()
else
write.output.file()
endif
endselect
endif

It is my "exist" statement that is causing me a headache, I am looking for a serial (held in "record") that might be present in "record.hold". But when I run this program, the value being returned by "pos" is always 0. even though I can see the value of "record" is present in "record.hold".

so for example
record = "1C3A4XY"
record.hold = "1C3A4XY|ABC1234"

I would expect my statement to return 1, as the string is present. But this is not the case, it is returning 0.

Would really appreciate some assistance.
Thanks
Andy

mark_h
18th July 2016, 15:38
The first thing I would do is change from exist to something that does not sound like a keyword - exist.in.record or maybe findit, whatever you like.. Did you initialize record.hold to "" or something like that. Put it in debug and step thru it. Make sure record.hold is being created correctly.

andreas.toepper
18th July 2016, 15:42
Could you please try swaping the parameters?
exist = pos(record.hold, record)

From the programmers guide:
Syntax:
function long pos (string source, string part [, long offset])

Description

This returns the start position of a specified substring ( part) in a specified string ( source).

Andy Purdey
18th July 2016, 16:04
Mark, thanks for your suggestion. I did rename the variables to make them more friendly.
Andreas, thanks for your comments, this has done the trick. I had not understood the help in the Baan programmers notes.

Cheers
to both of you.
Andy

Andy Purdey
18th July 2016, 16:17
Thanks Andreas,

This solved the issue :-)

Andy