Groups > dBase > Getting Started with dBase > Re: Keyword Error




Re: Keyword Error

Re: Keyword Error
Wed, 16 Apr 2008 20:34:11 -070
"Bob McKinney" <bmckinney721@bellsouth.net> wrote in message 
news:qIDji6CoIHA.312@news-server...
> Using dB+2.6 w/XP/pro.   Using the following code for calculations.  I get

> an error msg 'Unallowable phrase/keyword in command'.  I don't understand 
> why.
> function EPRICE_onChange
>      local rs
>      rs = form.InvoicesDataModule1.Lineitem1.rowset
>      rs.fields["Extension"].value := ;
>          rs.fields["Quantity"].value * ;
>             if rs.fields["Length"].value <>0 // error here
>                rs.fields["Length"].value * ;
>             endif
>               rs.fields["Price"].value
>      rs.fields["ItemAmount"].value := ;
>         rs.fields["Extension"].value
>      return
> Perhaps soneone can see what I don't.  Thanks ...Bob

dBASE might let you use the word "length" but I see something else.

I don't believe you can combine a stand if statement into one line.

Try this:
      rs = form.InvoicesDataModule1.Lineitem1.rowset
      rs.fields["Extension"].value := ;
          iif(rs.fields["Quantity"].value * ;
              rs.fields["Length"].value <>0, ;
                rs.fields["Length"].value * ;
               rs.fields["Price"].value, ;
      rs.fields["ItemAmount"].value := ;
         rs.fields["Extension"].value )
      return

Untested but should get you on the right track.

HTH,
Greg Hill

Post Reply
Keyword Error
Wed, 16 Apr 2008 21:59:13 -040
Using dB+2.6 w/XP/pro.   Using the following code for calculations.  I get an
error msg 'Unallowable phrase/keyword in command'.  I don't understand why.
 function EPRICE_onChange
      local rs
      rs = form.InvoicesDataModule1.Lineitem1.rowset
      rs.fields["Extension"].value := ;
          rs.fields["Quantity"].value * ;
             if rs.fields["Length"].value <>0 // error here     
          
                rs.fields["Length"].value * ;
             endif
               rs.fields["Price"].value
      rs.fields["ItemAmount"].value := ;
         rs.fields["Extension"].value 
      return
Perhaps soneone can see what I don't.  Thanks ...Bob
Post Reply
Re: Keyword Error
Thu, 17 Apr 2008 01:07:37 -040
In article <qIDji6CoIHA.312@news-server>, bmckinney721@bellsouth.net 
says...
> Using dB+2.6 w/XP/pro.   Using the following code for calculations.  I get
an error msg 'Unallowable phrase/keyword in command'.  I don't understand why.
>  function EPRICE_onChange
>       local rs
>       rs = form.InvoicesDataModule1.Lineitem1.rowset
>       rs.fields["Extension"].value := ;
>           rs.fields["Quantity"].value * ;

The * above is a multiplication sign with nothing to multiply.

>              if rs.fields["Length"].value <>0 // error here
               
>                 rs.fields["Length"].value * ;

The * above is a multiplication sign with nothing to multiply.


>              endif
>                rs.fields["Price"].value
>       rs.fields["ItemAmount"].value := ;
>          rs.fields["Extension"].value 
>       return
> Perhaps soneone can see what I don't.  Thanks ...Bob


-- 
Geoff Wass [dBVIPS]
Montréal, Québec, Canada

.|.|.|        dBASE info at http://geocities.com/geoff_wass       |.|.|.
.|.|.| ---------------------------------------------------------- |.|.|.
Post Reply
Re: Keyword Error
Thu, 17 Apr 2008 05:26:01 -070
Bob McKinney wrote:
> Using dB+2.6 w/XP/pro.   Using the following code for calculations.  I get
an error msg 'Unallowable phrase/keyword in command'.  I don't understand why.
>  function EPRICE_onChange
>       local rs
>       rs = form.InvoicesDataModule1.Lineitem1.rowset
>       rs.fields["Extension"].value := ;
>           rs.fields["Quantity"].value * ;

I'm sure others will tell you the same thing -- it's the * at the end of 
this line, with the IF on the next line -- if you want to include an IF 
inside a formula, you need to use the IIF() function. You can't insert a 
standard IF/ELSE/ENDIF structure inside of a calculation like this.

>              if rs.fields["Length"].value <>0 // error here
               
>                 rs.fields["Length"].value * ;
>              endif
>                rs.fields["Price"].value
>       rs.fields["ItemAmount"].value := ;
>          rs.fields["Extension"].value 
>       return
> Perhaps soneone can see what I don't.  Thanks ...Bob
> 


-- 
/(Opinions expressed are purely my own, not those of dataBased
Intelligence, Inc.)/

*Ken Mayer* [dBVIPS]
/Golden Stag Productions/
dBASE at goldenstag dot net
http://www.goldenstag.net/GSP
http://www.goldenstag.net/dbase/dBASEBooks.htm
Post Reply
Re: Keyword Error
Thu, 17 Apr 2008 08:24:32 -040
use the inline iif() function:
r = rs.fields
r["extension"].value := r["quantity"].value *
iif(r["length"].value <> 
0,r["length"].value,1) * r["price"].value
"Bob McKinney" <bmckinney721@bellsouth.net> wrote in message 
news:qIDji6CoIHA.312@news-server...
> Using dB+2.6 w/XP/pro.   Using the following code for calculations.  I get

> an error msg 'Unallowable phrase/keyword in command'.  I don't understand 
> why.
> function EPRICE_onChange
>      local rs
>      rs = form.InvoicesDataModule1.Lineitem1.rowset
>      rs.fields["Extension"].value := ;
>          rs.fields["Quantity"].value * ;
>             if rs.fields["Length"].value <>0 // error here
>                rs.fields["Length"].value * ;
>             endif
>               rs.fields["Price"].value
>      rs.fields["ItemAmount"].value := ;
>         rs.fields["Extension"].value
>      return
> Perhaps soneone can see what I don't.  Thanks ...Bob
> 

Post Reply
<< Previous 1 2 Next >>
( Page 1 of 2 )
about | contact