For Programmers: Free Programming Magazines  


Home > Archive > Clipper > March 2005 > field_A entry based upon field_B entry in tbrowse









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author field_A entry based upon field_B entry in tbrowse
happy

2005-03-04, 8:55 pm

I am trying to enter a field_B a certain value based upon a function
called "registered" which tests value of other field_A
passed to it and then return the certain value which will be the value
of field_B . I have some troubles of the record number that the new
value is written to it .

FUNCTION PHCOLGET(OBROWSE,workarea)
..
regis:=space(15)
nrec:=0
nrec:=(workarea)->(recno())
regis:=registered((workarea)->PH_mobile)
select (workarea)
goto nrec
(workarea)->PH_regis:=regis
...
return

FUNCTION registered(t_regis)
*-------------------
temp_regis:=space(15)
select 4
use cona index cona
locate for alltrim(4->mobile)==alltrim(t_regis)
If(found(),temp_regis:="Registered",temp_regis:="Uregistered")
locate for alltrim(4->office)==alltrim(t_regis)
If(found(),temp_regis:="Registered",temp_regis:="Uregistered")
locate for alltrim(4->home)==alltrim(t_regis)
If(found(),temp_regis:="Registered",temp_regis:="Uregistered")
return (temp_regis)

Stephen Quinn

2005-03-05, 3:55 am

Ehab

Why are you doing the test on the first 2 fields when the 3rd test will
overwrite those results anyway.
All you need do is test for the 3rd (4->home) and you'll have the answer.

// This is redundant code
> locate for alltrim(4->mobile)==alltrim(t_regis)
> If(found(),temp_regis:="Registered",temp_regis:="Uregistered")


// This is redundant code
> locate for alltrim(4->office)==alltrim(t_regis)
> If(found(),temp_regis:="Registered",temp_regis:="Uregistered")


// This will always be the result no matter what went before
> locate for alltrim(4->home)==alltrim(t_regis)
> If(found(),temp_regis:="Registered",temp_regis:="Uregistered")


You should put the environment back the way it was when you entered it when you
leave a function
Eg
> FUNCTION PHCOLGET(OBROWSE,workarea)

local nArea := select()
select 4
// code
select nArea
return

--
HTH
Steve


Stephen Quinn

2005-03-08, 3:55 am

Ehab

Why are you doing the test on the first 2 fields when the 3rd test will
overwrite those results anyway.
All you need do is test for the 3rd (4->home) and you'll have the answer.

// This is redundant code
> locate for alltrim(4->mobile)==alltrim(t_regis)
> If(found(),temp_regis:="Registered",temp_regis:="Uregistered")


// This is redundant code
> locate for alltrim(4->office)==alltrim(t_regis)
> If(found(),temp_regis:="Registered",temp_regis:="Uregistered")


// This will always be the result no matter what went before
> locate for alltrim(4->home)==alltrim(t_regis)
> If(found(),temp_regis:="Registered",temp_regis:="Uregistered")


You should put the environment back the way it was when you entered it when you
leave a function
Eg
> FUNCTION PHCOLGET(OBROWSE,workarea)

local nArea := select()
select 4
// code
select nArea
return

--
HTH
Steve


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com