LOCATE question

4 views
Skip to first unread message

eppick77

unread,
Dec 18, 2009, 1:59:48 PM12/18/09
to OpenQM


1= IT="A"
2= LOCATE "" IN IT<1> SETTING POS ELSE
3= IT<1,POS>=1
4= PRINT IT
5= END


This results in A}1

However, if IT="" the program does not generate anything.

I cannot remember if this was the case on Universe and D3 or not. I
know at one site on Universe, this was a pretty common technique for
finding the end of the record.

Thanks

Ashley Chapman

unread,
Dec 18, 2009, 3:24:50 PM12/18/09
to ope...@googlegroups.com

Considering that there are the len() and dcount() functions that can
give you information about the end of the string, how is the above
technique beneficial?

Ashley Chapman

eppick77

unread,
Dec 18, 2009, 3:41:24 PM12/18/09
to OpenQM
It is not so much being useful as I was just remembering a technique
that I came across at a site and I did an experiment on qm to see if
works the same way.

I just can not remember if it worked differently on other systems if
the record was null. I am still trying to find out differences
between qm and other systems.

Eugene

Brian Speirs

unread,
Dec 18, 2009, 4:36:25 PM12/18/09
to OpenQM
Watch your mode settings when using LOCATE. I would suggest that you
use $MODE UV.LOCATE to get the LOCATE statement to operate in a
similar fashion to UniVerse, UniData, mvBASE (and I assume D3). In
this case, I don't think it will make a difference because you've only
got one value in the dynamic array.

Having said that, your results are what I would expect without trying
the code. In the first instance, it doesn't find the test value in the
dynamic array and executes the ELSE clause. In the second, the test
value ("") is found in the dynamic array and so nothing happens (but
if you had a THEN clause, this would execute.

Cheers,

Brian

Kevin Powick

unread,
Dec 18, 2009, 4:44:01 PM12/18/09
to OpenQM

On Dec 18, 1:59 pm, eppick77 <eppic...@yahoo.com> wrote:
>  1=      IT="A"
>  2=      LOCATE "" IN IT<1> SETTING POS ELSE
>  3=         IT<1,POS>=1
>  4=         PRINT IT
>  5=      END
>
> This results in A}1
>
> However, if IT="" the program does not generate anything.

Works the same as above in D3 7.5.3

If you try IT = "A":@VM , you'll get the same as with IT = "". The
result is true, so ELSE not executed.

I think the behaviour is logical and would not want to see it changed.

--
Kevin Powick

Martin Phillips

unread,
Dec 18, 2009, 2:09:03 PM12/18/09
to ope...@googlegroups.com
Hi Eugene,

I will check this and let you knowvwhat I find. I am out of the office
today.

Martin Phillips

> --
>
> You received this message because you are subscribed to the Google
> Groups "OpenQM" group.
> To post to this group, send an email to ope...@googlegroups.com.
> To unsubscribe from this group, send email to openqm+un...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/openqm?hl=en-GB
> .
>
>

Martin Phillips

unread,
Dec 21, 2009, 5:41:53 AM12/21/09
to ope...@googlegroups.com
Hi all,

I have checked this and the behaviour is the same as UniVerse in both Ideal
and Pick modes. Furthermore, the UV documentation references this as a
specific example of what happens.


Martin

eppick77

unread,
Dec 21, 2009, 8:54:43 AM12/21/09
to OpenQM
That is good to hear. My goal was to make sure that QM was working
the same as other versions.

Thank you.

On Dec 21, 5:41 am, "Martin Phillips" <martinphill...@ladybridge.com>
wrote:

Reply all
Reply to author
Forward
0 new messages