1 Replies - 974 Views - Last Post: 03 December 2013 - 04:07 AM Rate Topic: -----

#1 Random01   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 06-October 13

Object Pascal procedures

Posted 02 December 2013 - 11:07 AM

2 Immensly frustrating procedures...as they turn out to be.

So the Form data is
    Identifier = Order
    Identifier = Customer
    onchange = pFillFrom

The idea is to fill the adress fields from Order with that of the adress information from Customer, when a customer is selected by its number, in said form. This with one procedure.

procedure pFillFrom;
qry: TCQuery;
qry := CreateQry('select C.housenumber housenr, C.place place, C.areacode areacode, C.street street, O.customer, O.from_street fromStreet, O.from_houseNr fromHousenr, O.from_areacode fromAreacode, O.fromPlace fromPlace');
qry.SQL.add('from Customer C, Order O');
qry.SQL.add('where O.Customer = C.nr and O.Customer =: k');
qry.ParamByName('k').AsInteger := FieldByName('customer').AsInteger;
qry['housenr'].AsString := qry['fromHousenr'].AsString;
qry['place'].AsString := qry['fromPlace'].AsString;
qry['areacode'].AsString := qry['fromAreacode'].AsString;
qry['street'].AsString := qry['fromStreet'].AsString;

The error i receive is :
Unknown Identifier : FieldByName

But the procedure is to be executed in Order, which has a fieldname Customer ... so...
If i change it to Order.FieldByName('customer').AsInteger it says it doesn't recognize Order.

Im at a loss here, any help is appreciated.

The other procedure is a calculator:
Calculating the price of an order that is.
procedure pCalcPrice;
annuled: string;
if (annuled= 'Y') then
 qry := CreateQry('update Order set amount =  ');
 qry.SQL.add('select annul_cost from System S');
qry : = CreateQry('update Order set amount = ');
qry.SQL.add('select G.addedRate, G.weight, G.cost_per_kilo, S.start_cost from Order O, WeightGroup G, System S,  ');
qry.SQL.add('where G.nr = O.weightgroup');
qry.SQL.add('where nr = :nr');
qry.ParamByName('nr').AsInteger := FieldByName('nr').AsInteger;
qry.ParamByName('amount').AsFloat := Order.FieldByName('amount').AsFloat;

FieldByName('amount').AsFloat := qry.FieldByName('S.start_cost').AsFloat + qry.FieldByName('G.addedRate').AsFloat - (qry.FieldByName('G.weight').AsFloat * qry.FieldByName('G.cost_per_kilo').AsFloat);
 end ;

System S is a singleton.
The first error it gives is that it expects an identifier around the else statement. But i can't see where and what exactly.

This post has been edited by Random01: 02 December 2013 - 11:08 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Object Pascal procedures

#2 Random01   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 06-October 13

Re: Object Pascal procedures

Posted 03 December 2013 - 04:07 AM

No one , anything?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1