Setting a Variable equal to a field(Code) 
Author Message
 Setting a Variable equal to a field(Code)

I have ran into a problem with trying to pull out inaccurate data the
end users have entered. We are trying to look at  84 fields that are
numeric from a table and pull out the records from those fields that
have a length less then 3. I have created a lookup table that consists
of the field names that are in question along with each having a unique
ID number. The code we are trying to write would go down the lookup
table and get the name of the field*vfield*  and then call up another
table that has that field name which is contained in that variable and
go thru all the records for that field name looking for a length of <4
then placing it into a "bad data" table. Then cycling thru the lookup
table to get all the fields without having to run this code 84 times.
Below is the code we have currently written for this procedure, any
help in solving this problem would be greatly appreciated.

TIA for any advice on this problem
Dale

OPEN DATABASE run_temp shared

USE lookup IN 0 shared
use combine in 0 shared
use bad_data in 0 shared

select combine
go top
select lookup
go top
counter = 1

do while counter<>85
        select lookup
        locate for id = counter
        vfield=lookup.names

        select combine
        do while !EOF()
        if len(vfield) <4
          vdispatch=combine.dispatcher
          vrun=combine.runnum
          select bad_data
          insert into bad_data (run_number, names, dispatcher);
          values (vrun, vfield, vdispatch)
        endif
        select combine
        skip 1
        loop
         Enddo
         select combine
         go top
         counter=counter+1
loop
enddo

Sent via Deja.com
http://www.*-*-*.com/



Sun, 15 Jun 2003 04:27:56 GMT  
 Setting a Variable equal to a field(Code)


Quote:
> I have ran into a problem with trying to pull out inaccurate data the
> end users have entered. We are trying to look at  84 fields that are
> numeric from a table and pull out the records from those fields that
> have a length less then 3. I have created a lookup table that consists
> of the field names that are in question along with each having a
unique
> ID number. The code we are trying to write would go down the lookup
> table and get the name of the field*vfield*  and then call up another
> table that has that field name which is contained in that variable and
> go thru all the records for that field name looking for a length of <4
> then placing it into a "bad data" table. Then cycling thru the lookup
> table to get all the fields without having to run this code 84 times.
> Below is the code we have currently written for this procedure, any
> help in solving this problem would be greatly appreciated.

> TIA for any advice on this problem
> Dale

> OPEN DATABASE run_temp shared

> USE lookup IN 0 shared
> use combine in 0 shared
> use bad_data in 0 shared

> select combine
> go top
> select lookup
> go top
> counter = 1

> do while counter<>85
>    select lookup
>    locate for id = counter
>    vfield=lookup.names

>    select combine
>    do while !EOF()
>    if len(vfield) <4
>      vdispatch=combine.dispatcher
>      vrun=combine.runnum
>      select bad_data
>      insert into bad_data (run_number, names, dispatcher);
>      values (vrun, vfield, vdispatch)
>    endif
>    select combine
>    skip 1
>    loop
>     Enddo
>     select combine
>     go top
>     counter=counter+1
> loop
> enddo

Dale,

Change the line that reads

if len(vfield) < 4

to

if len(&vfield.) < 4

- Keith

Sent via Deja.com
http://www.deja.com/



Sun, 15 Jun 2003 04:34:35 GMT  
 Setting a Variable equal to a field(Code)

Quote:



> > I have ran into a problem with trying to pull out inaccurate data
the
> > end users have entered. We are trying to look at  84 fields that are
> > numeric from a table and pull out the records from those fields that
> > have a length less then 3. I have created a lookup table that
consists
> > of the field names that are in question along with each having a
> unique
> > ID number. The code we are trying to write would go down the lookup
> > table and get the name of the field*vfield*  and then call up
another
> > table that has that field name which is contained in that variable
and
> > go thru all the records for that field name looking for a length of
<4
> > then placing it into a "bad data" table. Then cycling thru the
lookup
> > table to get all the fields without having to run this code 84
times.
> > Below is the code we have currently written for this procedure, any
> > help in solving this problem would be greatly appreciated.

> > TIA for any advice on this problem
> > Dale

> > OPEN DATABASE run_temp shared

> > USE lookup IN 0 shared
> > use combine in 0 shared
> > use bad_data in 0 shared

> > select combine
> > go top
> > select lookup
> > go top
> > counter = 1

> > do while counter<>85
> >       select lookup
> >       locate for id = counter
> >       vfield=lookup.names

> >       select combine
> >       do while !EOF()
> >       if len(vfield) <4
> >         vdispatch=combine.dispatcher
> >         vrun=combine.runnum
> >         select bad_data
> >         insert into bad_data (run_number, names, dispatcher);
> >         values (vrun, vfield, vdispatch)
> >       endif
> >       select combine
> >       skip 1
> >       loop
> >        Enddo
> >        select combine
> >        go top
> >        counter=counter+1
> > loop
> > enddo

> Dale,

> Change the line that reads

> if len(vfield) < 4

> to

> if len(&vfield.) < 4

> - Keith

Keith,

Thanks for the quick reply. I tried your suggestion. The problem,which
I might not have stated clearly is, the variable vfield has the name of
the field that I am looking for. But I need to reference the value of
that field,which is in another table. Example of when I run the code:

vfield has the value of "field1" in it. But I need to find a way to get
the value of what is in "field1" which is in another table and pull out
that value if it is less then 4.

Does this make things a little clearer or am I not stating the problem
clear enough?

Again, thanks for the quick reply

Dale

Sent via Deja.com
http://www.deja.com/



Sun, 15 Jun 2003 04:54:43 GMT  
 Setting a Variable equal to a field(Code)


Quote:
> Keith,

> Thanks for the quick reply. I tried your suggestion. The problem,which
> I might not have stated clearly is, the variable vfield has the name
of
> the field that I am looking for. But I need to reference the value of
> that field,which is in another table. Example of when I run the code:

> vfield has the value of "field1" in it. But I need to find a way to
get
> the value of what is in "field1" which is in another table and pull
out
> that value if it is less then 4.

> Does this make things a little clearer or am I not stating the problem
> clear enough?

> Again, thanks for the quick reply

> Dale

If you are looking for a value < 4, do not use the len() function:

if &vField. < 4

- Keith

Sent via Deja.com
http://www.deja.com/



Sun, 15 Jun 2003 06:34:45 GMT  
 Setting a Variable equal to a field(Code)

Quote:
> > Dale

> If you are looking for a value < 4, do not use the len() function:

> if &vField. < 4

> - Keith

> Sent via Deja.com
> http://www.deja.com/

Keith,

my mistake, I mistyped the previous post. That should of been i am
looking for a length <4. What some end-users are entering is a time of
112 which needs to be typed in as 0112 for a length of 4. I am putting
in the colon seperator via a input mask on the forms and have just the
numbers in the table. I need to be able to pull out all the "times"
that are not 4 digits in length and put those into a seperate table so
the end-users can go back and reenter those times. Hope this helps
clear up a little more of what I am trying to accomplish.

Again thanks for the quick reply and good advice :)

Dale

Sent via Deja.com
http://www.deja.com/



Sun, 15 Jun 2003 06:56:14 GMT  
 Setting a Variable equal to a field(Code)
Dale,

You will need to ALLTRIM() your field to pick out records with only 3
characters in a C(4) field.

While your approach will work, I'd like to show the code using SCAN. Also,
since LOOKUP is a reserved word, I've aliased the table as LookupTable.

OPEN DATABASE Run_temp SHARED

USE LOOKUP IN 0 SHARED ALIAS LookupTable
USE Combine IN 0 SHARED
USE Bad_data IN 0 SHARED

SELECT LookupTable
SCAN    && FOR Counter <> 85 - include if there records you don't want
    SELECT Combine
    SCAN FOR LEN(ALLTRIM(&vField)) < 4
        INSERT INTO Bad_data (Run_number, Names, Dispatcher);
            VALUES (Combine.Runnum, LookupTable.Names, Combine.Dispatcher)
    ENDSCAN
ENDSCAN

Also, if you could guarantee that all of the 3 digit values have the same
problem, and programmers are allowed to touch data, you could just do:

*!* Recommend to test thoroughly on a copy of the data!
*!* Open tables
SELECT LookupTable
SCAN    && FOR Counter <> 85 - include if there records you don't want
    REPLACE Combine.&vField WITH PADL(Combine.&vField, 4) ;
        FOR LEN(ALLTRIM(Combine.&vField)) < 4 ;
        IN Combine
ENDSCAN

--

Cindy Winegarden

Microsoft Certified Professional, Visual FoxPro
Microsoft Visual FoxPro MVP



| I have ran into a problem with trying to pull out inaccurate data the
| end users have entered. We are trying to look at  84 fields that are
| numeric from a table and pull out the records from those fields that
| have a length less then 3. I have created a lookup table that consists
| of the field names that are in question along with each having a unique
| ID number. The code we are trying to write would go down the lookup
| table and get the name of the field*vfield*  and then call up another
| table that has that field name which is contained in that variable and
| go thru all the records for that field name looking for a length of <4
| then placing it into a "bad data" table. Then cycling thru the lookup
| table to get all the fields without having to run this code 84 times.
| Below is the code we have currently written for this procedure, any
| help in solving this problem would be greatly appreciated.
|
| TIA for any advice on this problem
| Dale
|
|
| OPEN DATABASE run_temp shared
|
| USE lookup IN 0 shared
| use combine in 0 shared
| use bad_data in 0 shared
|
| select combine
| go top
| select lookup
| go top
| counter = 1
|
| do while counter<>85
| select lookup
| locate for id = counter
| vfield=lookup.names
|
| select combine
| do while !EOF()
| if len(vfield) <4
|   vdispatch=combine.dispatcher
|   vrun=combine.runnum
|   select bad_data
|   insert into bad_data (run_number, names, dispatcher);
|   values (vrun, vfield, vdispatch)
| endif
| select combine
| skip 1
| loop
| Enddo
| select combine
| go top
| counter=counter+1
| loop
| enddo
|
|
| Sent via Deja.com
| http://www.deja.com/



Sun, 15 Jun 2003 07:32:35 GMT  
 Setting a Variable equal to a field(Code)
Dale
How about this, assuming the 84-column table is called test:
create cursor Normalized (fieldname c(10), nvalue n(5))
select Tests
for i = 1 to fcount('tests')
 scan for len(tran(eval(field(i,'tests')))) < 3
 n = eval(field(i, 'tests'))
 insert into Normalized values (field(i,'tests'), m.n)
 endscan
next

However, if only some of the 84 columns come into question then an indexed
lookup table of these can be used:

for i = 1 to fcount('tests')
 If Seek(field(i,'tests'), 'lookuptable', 'indextag')
 scan for len(tran(eval(field(i,'tests')))) < 3
 n = eval(field(i, 'tests'))
 insert into Normalized values (field(i,'tests'), m.n)
 EndScan
 Endif
next

-Anders


Quote:
> I have ran into a problem with trying to pull out inaccurate data the
> end users have entered. We are trying to look at  84 fields that are
> numeric from a table and pull out the records from those fields that
> have a length less then 3. I have created a lookup table that consists
> of the field names that are in question along with each having a unique
> ID number. The code we are trying to write would go down the lookup
> table and get the name of the field*vfield*  and then call up another
> table that has that field name which is contained in that variable and
> go thru all the records for that field name looking for a length of <4
> then placing it into a "bad data" table. Then cycling thru the lookup
> table to get all the fields without having to run this code 84 times.
> Below is the code we have currently written for this procedure, any
> help in solving this problem would be greatly appreciated.

> TIA for any advice on this problem
> Dale

> OPEN DATABASE run_temp shared

> USE lookup IN 0 shared
> use combine in 0 shared
> use bad_data in 0 shared

> select combine
> go top
> select lookup
> go top
> counter = 1

> do while counter<>85
> select lookup
> locate for id = counter
> vfield=lookup.names

> select combine
> do while !EOF()
> if len(vfield) <4
>   vdispatch=combine.dispatcher
>   vrun=combine.runnum
>   select bad_data
>   insert into bad_data (run_number, names, dispatcher);
>   values (vrun, vfield, vdispatch)
> endif
> select combine
> skip 1
> loop
> Enddo
> select combine
> go top
> counter=counter+1
> loop
> enddo

> Sent via Deja.com
> http://www.deja.com/



Sun, 15 Jun 2003 07:42:31 GMT  
 Setting a Variable equal to a field(Code)


Quote:
> Dale
> How about this, assuming the 84-column table is called test:
> create cursor Normalized (fieldname c(10), nvalue n(5))
> select Tests
> for i = 1 to fcount('tests')
>  scan for len(tran(eval(field(i,'tests')))) < 3
>  n = eval(field(i, 'tests'))
>  insert into Normalized values (field(i,'tests'), m.n)
>  endscan
> next

> However, if only some of the 84 columns come into question then an
indexed
> lookup table of these can be used:

> for i = 1 to fcount('tests')
>  If Seek(field(i,'tests'), 'lookuptable', 'indextag')
>  scan for len(tran(eval(field(i,'tests')))) < 3
>  n = eval(field(i, 'tests'))
>  insert into Normalized values (field(i,'tests'), m.n)
>  EndScan
>  Endif
> next

> -Anders

Anders and Cindy,

Thank you for your suggestions. The only thing the Lookup table has in
it is field names that I know have bad data in them from the Combine
table. The Combine table has the same fields as the LookUp Table plus
additional fields, it also has data residing in that table for the
fields in question. Example:

THE LOOKUP TABLE HAS:
ID        Names
1         on_scene
2         Dispatch_time
3         Clear_scene

THE COMBINE TABLE HAS:
on_scene   Dispatch_time    Clear_scene  Some_other_fields
  0010        912              21           Some_other_data

As you can see from the original code the Vfield has the Names field
put into it from the lookup table. I then need to go to the Combine
table and get that field name that matches the value of Vfield and get
the associated value of that field in the Combine table..Example:

If Vfield = Dispatch_time.. then i need to go to the Combine table and
get the value 912. I want to be able to scroll all 8000 records for
each indivdual field name *there is 84 field names in the lookup table*
in the lookup table, then look for any values
that field name has that is less then 4 in length in the Combine Table
and put that into a Bad_data Table.

The problem seems to be that I am unable to associate the Value of
Vfield with the field name that is identical in the Combine table and
get the value for that field name from the Combine Table.

Does this make anymore sense or am I confusing everyone as much as I am
confusing myself with this problem? :)

Again, Thanks Anders and Cindy for your suggestions, I feel your
suggestions are real close to the solution that I am looking for.

Dale

Sent via Deja.com
http://www.deja.com/



Sun, 15 Jun 2003 11:27:54 GMT  
 Setting a Variable equal to a field(Code)

[snip]

Quote:
>Also, if you could guarantee that all of the 3 digit values have the same
>problem, and programmers are allowed to touch data, you could just do:

>*!* Recommend to test thoroughly on a copy of the data!
>*!* Open tables
>SELECT LookupTable
>SCAN    && FOR Counter <> 85 - include if there records you don't want
>    REPLACE Combine.&vField WITH PADL(Combine.&vField, 4) ;

                                  ^^^^^^^^^^^^^^^^^^^^^^^^
     Shouldn't that be
          padl(alltrim(combine.&vfield),4,"0")
?

Quote:
>        FOR LEN(ALLTRIM(Combine.&vField)) < 4 ;
>        IN Combine
>ENDSCAN

[snipped previous]

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
     I have preferences.
     You have biases.
     He/She has prejudices.



Sun, 15 Jun 2003 15:10:20 GMT  
 Setting a Variable equal to a field(Code)

Hi Dale
Well you had me fooled when you said you have 84 numeric fields. If there
are values like '0123' they are Character fields not numeric. The number of
digits can then be checked with LEN(ALLTRIM(..)).
Change
scan for len(tran(eval(field(i,'tests')))) < 3
to
SCAN FOR LEN(ALLTRIM(EVAL(FIELD(i, 'Tests') < 4

The name of a column is returned by the FIELD(n,'alias') function. The value
can be returned with EVAL(FIELD(n,alias)). FIELD() returns the column name
in uppercase, Field(2,cAlias) is 'DISPATCH_TIME'. Eval(field(2,cAlias) is
912. Sometimes it may be necessary or safer to assign Eval(Field(n,..) to a
variable in order to be able to use it.
What I'd is is put  the names of the columns to check in UPPERcase in a a
LookupTable and index it.
The easiest way to do that is like this
AFIELDS(aa,'combine_table')
CREATE CURSOR Columnnames (columnname C(20))
INSERT INTO Columnnames FROM ARRAY aa
RELEASE aa
INDEX ON columnname TAG indextag
BROWSE
 scan the table and delete all the names you don't want to check.
Then
CREATE CURSOR BadData (fieldname c(10), recordnumber n(5), cValue C(5))
SELECT Combine_table
for i = 1 to fcount('Combine_table')
  If Seek(field(i,'Combine_table'), 'Columnnames', 'indextag')
  scan for len(ALLTRIM(eval(field(i,'Combine_table')))) < 4
  nRecord = RECNO('combine_table')
  cVal = eval(field(i, 'Combine_table'))
  cFiled = field(i,'Combine_table')
  insert into Baddata values (M.cField,M.nRecord, m.cVal)
  EndScan
  Endif
 next
SELECT Baddata
BROWSE

-Anders


Quote:


> > Dale
> > How about this, assuming the 84-column table is called test:
> > create cursor Normalized (fieldname c(10), nvalue n(5))
> > select Tests
> > for i = 1 to fcount('tests')
> >  scan for len(tran(eval(field(i,'tests')))) < 3
> >  n = eval(field(i, 'tests'))
> >  insert into Normalized values (field(i,'tests'), m.n)
> >  endscan
> > next

> > However, if only some of the 84 columns come into question then an
> indexed
> > lookup table of these can be used:

> > for i = 1 to fcount('tests')
> >  If Seek(field(i,'tests'), 'lookuptable', 'indextag')
> >  scan for len(tran(eval(field(i,'tests')))) < 3
> >  n = eval(field(i, 'tests'))
> >  insert into Normalized values (field(i,'tests'), m.n)
> >  EndScan
> >  Endif
> > next

> > -Anders
> Anders and Cindy,

> Thank you for your suggestions. The only thing the Lookup table has in
> it is field names that I know have bad data in them from the Combine
> table. The Combine table has the same fields as the LookUp Table plus
> additional fields, it also has data residing in that table for the
> fields in question. Example:

> THE LOOKUP TABLE HAS:
> ID        Names
> 1         on_scene
> 2         Dispatch_time
> 3         Clear_scene

> THE COMBINE TABLE HAS:
> on_scene   Dispatch_time    Clear_scene  Some_other_fields
>   0010        912              21           Some_other_data

> As you can see from the original code the Vfield has the Names field
> put into it from the lookup table. I then need to go to the Combine
> table and get that field name that matches the value of Vfield and get
> the associated value of that field in the Combine table..Example:

> If Vfield = Dispatch_time.. then i need to go to the Combine table and
> get the value 912. I want to be able to scroll all 8000 records for
> each indivdual field name *there is 84 field names in the lookup table*
> in the lookup table, then look for any values
> that field name has that is less then 4 in length in the Combine Table
> and put that into a Bad_data Table.

> The problem seems to be that I am unable to associate the Value of
> Vfield with the field name that is identical in the Combine table and
> get the value for that field name from the Combine Table.

> Does this make anymore sense or am I confusing everyone as much as I am
> confusing myself with this problem? :)

> Again, Thanks Anders and Cindy for your suggestions, I feel your
> suggestions are real close to the solution that I am looking for.

> Dale

> Sent via Deja.com
> http://www.deja.com/



Sun, 15 Jun 2003 21:13:15 GMT  
 Setting a Variable equal to a field(Code)
Yep! Thanks Gene.

--

Cindy Winegarden

Microsoft Certified Professional, Visual FoxPro
Microsoft Visual FoxPro MVP




|
| [snip]
|
| >Also, if you could guarantee that all of the 3 digit values have the same
| >problem, and programmers are allowed to touch data, you could just do:
| >
| >*!* Recommend to test thoroughly on a copy of the data!
| >*!* Open tables
| >SELECT LookupTable
| >SCAN    && FOR Counter <> 85 - include if there records you don't want
| >    REPLACE Combine.&vField WITH PADL(Combine.&vField, 4) ;
|                                   ^^^^^^^^^^^^^^^^^^^^^^^^
|      Shouldn't that be
|           padl(alltrim(combine.&vfield),4,"0")
| ?
|
| >        FOR LEN(ALLTRIM(Combine.&vField)) < 4 ;
| >        IN Combine
| >ENDSCAN
|
| [snipped previous]
|
| Sincerely,
|
| Gene Wirchenko
|
| Computerese Irregular Verb Conjugation:
|      I have preferences.
|      You have biases.
|      He/She has prejudices.



Sun, 15 Jun 2003 23:24:31 GMT  
 Setting a Variable equal to a field(Code)


Quote:

> Hi Dale
> Well you had me fooled when you said you have 84 numeric fields. If
there
> are values like '0123' they are Character fields not numeric. The
number of
> digits can then be checked with LEN(ALLTRIM(..)).
> Change
> scan for len(tran(eval(field(i,'tests')))) < 3
> to
> SCAN FOR LEN(ALLTRIM(EVAL(FIELD(i, 'Tests') < 4

> The name of a column is returned by the FIELD(n,'alias') function.
The value
> can be returned with EVAL(FIELD(n,alias)). FIELD() returns the column
name
> in uppercase, Field(2,cAlias) is 'DISPATCH_TIME'. Eval(field
(2,cAlias) is
> 912. Sometimes it may be necessary or safer to assign Eval(Field
(n,..) to a
> variable in order to be able to use it.
> What I'd is is put  the names of the columns to check in UPPERcase in
a a
> LookupTable and index it.
> The easiest way to do that is like this
> AFIELDS(aa,'combine_table')
> CREATE CURSOR Columnnames (columnname C(20))
> INSERT INTO Columnnames FROM ARRAY aa
> RELEASE aa
> INDEX ON columnname TAG indextag
> BROWSE
>  scan the table and delete all the names you don't want to check.
> Then
> CREATE CURSOR BadData (fieldname c(10), recordnumber n(5), cValue C
(5))
> SELECT Combine_table
> for i = 1 to fcount('Combine_table')
>   If Seek(field(i,'Combine_table'), 'Columnnames', 'indextag')
>   scan for len(ALLTRIM(eval(field(i,'Combine_table')))) < 4
>   nRecord = RECNO('combine_table')
>   cVal = eval(field(i, 'Combine_table'))
>   cFiled = field(i,'Combine_table')
>   insert into Baddata values (M.cField,M.nRecord, m.cVal)
>   EndScan
>   Endif
>  next
> SELECT Baddata
> BROWSE

> -Anders

Thanks all for the suggestions,

I am currently playing around with another thought. Could I do some
sort of SCAN command on the Combine table and not even use a LookUp
table? The Combine table has all the field names in question and
additional fields.

I was thinking of something like the following

Scan For LEN(alltrim(str(to_hospital1))),;
  LEN(alltrim(str(to_hospital2)),LEN(alltrim(str(to_hospital3))),;
*Doing this for all the 84 fields*
     while <4
     INSERT INTO Bad_data (Run_number,Dispatcher);
     VALUES (Combine.Runnum,Combine.Dispatcher)
  ENDSCAN

Would this yield the desiredd results, and if so how is this different
then a DO-While Loop? or nested IF statements?

Any further suggestions is appreciated.

Thanks,
Dale

Sent via Deja.com
http://www.deja.com/



Mon, 16 Jun 2003 04:24:41 GMT  
 Setting a Variable equal to a field(Code)
Dale,

Did you see the code I posted? (And Gene's correction.)

--

Cindy Winegarden

Microsoft Certified Professional, Visual FoxPro
Microsoft Visual FoxPro MVP





| Thanks all for the suggestions,
|
| I am currently playing around with another thought. Could I do some
| sort of SCAN command on the Combine table and not even use a LookUp
| table? The Combine table has all the field names in question and
| additional fields.
|
| I was thinking of something like the following
|
| Scan For LEN(alltrim(str(to_hospital1))),;
|   LEN(alltrim(str(to_hospital2)),LEN(alltrim(str(to_hospital3))),;
| *Doing this for all the 84 fields*
|      while <4
|      INSERT INTO Bad_data (Run_number,Dispatcher);
|      VALUES (Combine.Runnum,Combine.Dispatcher)
|   ENDSCAN
|
| Would this yield the desiredd results, and if so how is this different
| then a DO-While Loop? or nested IF statements?
|
| Any further suggestions is appreciated.
|
| Thanks,
| Dale
|
|
| Sent via Deja.com
| http://www.deja.com/



Mon, 16 Jun 2003 04:55:39 GMT  
 Setting a Variable equal to a field(Code)


Quote:
> Dale,

> Did you see the code I posted? (And Gene's correction.)

> --

> Cindy Winegarden

> Microsoft Certified Professional, Visual FoxPro
> Microsoft Visual FoxPro MVP



Cindy,

Yes I saw the previous post using the Scan command. However looking at
the code you presented to me was a little bit confusing. you made use
of the "counter" variable and the Vfield variable. I was unable from
the code presented, to see how the counter variable and the vfield
variable would work:

OPEN DATABASE Run_temp SHARED
USE LOOKUP IN 0 SHARED ALIAS LookupTable
USE Combine IN 0 SHARED
USE Bad_data IN 0 SHARED

SELECT LookupTable
SCAN && FOR Counter <> 85 - include if there records you don't want
SELECT Combine
    SCAN FOR LEN(ALLTRIM(&vField)) < 4
        INSERT INTO Bad_data (Run_number, Names, Dispatcher);
        VALUES (Combine.Runnum, LookupTable.Names, Combine.Dispatcher)
ENDSCAN
ENDSCAN

Given the above code...
1) How "or" is the counter being incremented or am I to assume this was
being done in the code and just not posted?
2) Where is the value of Vfield coming from since its not being set to
the names field in the lookup table or was that something that I was to
assume that was done and just not posted?
3)Would this actually scan all the fields within the Combine table,
that are also in the Lookup table?
Please keep in mind that I am *obviously* very new to the foxpro realm
and somethings that might seem obvious to the seasoned VFP programmer
sometimes escapes me :)

Thanks again for your time and patience while I am trying to figure out
this problem :)

Dale

Sent via Deja.com
http://www.deja.com/



Mon, 16 Jun 2003 05:51:38 GMT  
 Setting a Variable equal to a field(Code)
Dale,

Sounds like you have the following tables:

Combine has your data.
Some of the fields are 4 character representations of times, and some of
those have only 3 digits. Those are the records you want to identify and
copy to the Bad_data table.

Lookup has a list of the fields with the times.
It sounds like it has an ID field which is numeric, and a character field
"Names" which contains a field name.  Does it have any other names beyond
the 84 that you want to check in the Combine table?

Bad_data receives info about records that need to be looked at.

Can you send me your Counter table, your Combine table (send only a couple
of dozen records) and an empty Bad_data table to the address below? I'll
watch for it. There's probably something you're not describing that I may be
missing, or my guess is right and you need further explanation.

--

Cindy Winegarden

Microsoft Certified Professional, Visual FoxPro
Microsoft Visual FoxPro MVP





| > Dale,
| >
| > Did you see the code I posted? (And Gene's correction.)
| >
| > --
| >
| > Cindy Winegarden
| >
| > Microsoft Certified Professional, Visual FoxPro
| > Microsoft Visual FoxPro MVP
| >

| >
| Cindy,
|
| Yes I saw the previous post using the Scan command. However looking at
| the code you presented to me was a little bit confusing. you made use
| of the "counter" variable and the Vfield variable. I was unable from
| the code presented, to see how the counter variable and the vfield
| variable would work:
|
| OPEN DATABASE Run_temp SHARED
| USE LOOKUP IN 0 SHARED ALIAS LookupTable
| USE Combine IN 0 SHARED
| USE Bad_data IN 0 SHARED
|
| SELECT LookupTable
| SCAN && FOR Counter <> 85 - include if there records you don't want
| SELECT Combine
|     SCAN FOR LEN(ALLTRIM(&vField)) < 4
|         INSERT INTO Bad_data (Run_number, Names, Dispatcher);
|         VALUES (Combine.Runnum, LookupTable.Names, Combine.Dispatcher)
| ENDSCAN
| ENDSCAN
|
| Given the above code...
| 1) How "or" is the counter being incremented or am I to assume this was
| being done in the code and just not posted?
| 2) Where is the value of Vfield coming from since its not being set to
| the names field in the lookup table or was that something that I was to
| assume that was done and just not posted?
| 3)Would this actually scan all the fields within the Combine table,
| that are also in the Lookup table?
| Please keep in mind that I am *obviously* very new to the foxpro realm
| and somethings that might seem obvious to the seasoned VFP programmer
| sometimes escapes me :)
|
| Thanks again for your time and patience while I am trying to figure out
| this problem :)
|
| Dale
|
|
| Sent via Deja.com
| http://www.deja.com/



Mon, 16 Jun 2003 07:35:13 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. VFP6 Reports Non-Equal Values are Equal.

2. SQL, selection records where 2 agregated fields are not equal

3. Variable # of fields or variable lengths?

4. Add fields to a table using variables as Fields Names

5. Set alternate to variable - doesn't work?????

6. Setting DOS Variables

7. Variables in SET FILTER command

8. VFP 5.0 variable question w/SET Filter

9. 2 set of same variable?

10. Windows set of variable size in FPW26a

11. ? Setting Operating System Environment Variables ??

12. Setting view filter with variables.

 

 
Powered by phpBB® Forum Software