[comp.databases] FOXCODE / FOXGEN Problems

alexis@panix.UUCP (Alexis Rosen) (11/13/89)

Well, neither of Tim's bugs are familiar to me, and I have no idea about the
second case.

As for the first one, I can't quite tell what the code is doing, but it
looks like it's doing a bunch of variable declarations and suchlike. I have
had no problems with the following code fragment, which seems to me to be a
slightly better algorithm anyway:

l:=""
Select [whatever you want]
Forall fieldobj
  If l=""
    l:="Public "
  Else
    l:=l+", "
  Endif
  i := At(">",fldnam)
  If i<>0     /* then this is a database field
    l:=l+Left(Stuff("_v"+fldnam,2,i,""),10)+", "+Left(Stuff("_o"+fldnam,2,i,""),10)
  Else        /* it's a variable, and doesn't need a "_v" var
    l:=l+Left(Stuff("_o"+fldnam,2,i,""),10)
  Endif
  If Len(l)>70
    Genln(l)
    l := ""
  Endif
Endfor
If l<>""
  Genln(l)
  l := ""
Endif



Note that this was for some code that needed two sets of variables for each
DB field. If it weren't you could toss out the ugly If i<>0 block. Also, the
Stuff() starting-character index is off by one due to a bug in MacFoxCode. I
suspect the same bug exists in Dos Fox 2.1 and in FoxPro, but I could be wrong.


Alexis Rosen
alexis@panix.uucp (but mail here isn't too good this week)
alexis@rascal.ics.utexas.edu

timk@xenitec.on.ca (Tim Kuehn) (11/14/89)

In article <376@panix.UUCP> you write:
>
>Well, neither of Tim's bugs are familiar to me, and I have no idea about the
>second case.

The first bug wasn't familiar to me until the declerations stopped appearing
in the generated code like they were supposed to. 

The second one, well that showed up out of the blue, and the odd thing is that
it only happens in some places. Of course, having wasted about 1.5 days 
tracking down and solving the problem, I don't use the <= or >= constructs
any more... oh well.

>As for the first one, I can't quite tell what the code is doing, but it
>looks like it's doing a bunch of variable declarations and suchlike. 

It was. 

>I have
>had no problems with the following code fragment, which seems to me to be a
>slightly better algorithm anyway:
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Quite possibly. I wrote that code off the top of my head for that specific
entry and wasn't too concerned about generality. (If it works, makes sense,
that's all that counts sort of thing.) Looking at your algorithim, 
does it accept *anything* as the object type to do a declaration for? In 
particular the one thing I've not run into is the prescence of the ">" in 
field names. Is there a switch for that (ie you get fields names in a 
"dbf_name->field_name" format)?

>l:=""
>Select [whatever you want]
>Forall fieldobj
>  If l=""
>    l:="Public "
>  Else
>    l:=l+", "
>  Endif
>  i := At(">",fldnam)

   ^^^^^^^^^^^^^^^^^^^
is ">" part of database field names?

>  If i<>0     /* then this is a database field
>    l:=l+Left(Stuff("_v"+fldnam,2,i,""),10)+", "+
					Left(Stuff("_o"+fldnam,2,i,""),10)
>  Else        /* it's a variable, and doesn't need a "_v" var
>    l:=l+Left(Stuff("_o"+fldnam,2,i,""),10)
>  Endif
>  If Len(l)>70
>    Genln(l)
>    l := ""
>  Endif
>Endfor
>If l<>""
>  Genln(l)
>  l := ""
>Endif
>
>Note that this was for some code that needed two sets of variables for each
>DB field. If it weren't you could toss out the ugly If i<>0 block. Also, the
>Stuff() starting-character index is off by one due to a bug in MacFoxCode. I
>suspect the same bug exists in Dos Fox 2.1 and in FoxPro,but I could be wrong.

I'll have to check my copy of foxcode/foxgen to see what happens there.

+-----------------------------------------------------------------------------+
|Timothy D. Kuehn	       			       timk@xenitec.on.ca     |
|TDK Consulting Services			       !watmath!xenitec!timk  |
|871 Victoria St. North, Suite 217A					      |
|Kitchener, Ontario, Canada N2B 3S4 		       (519)-741-3623 	      |
|DOS/Xenix - SW/HW. uC, uP, DBMS. 		       Satisfaction Guaranteed|
+-----------------------------------------------------------------------------+