0

I am having problems with long, longlong, integers, dec, and decimal datatypes in PowerBuilder 12.5 Classic...
I did something like this and is giving me problems of datatypes;

// set variables for item price and the cash given by the customer

double price, cash

price=double(trim(sle_price.text))
cash=double(trim(sle_cash.text))



if cash="" then
    messagebox("","CASH")
    sle_cash.setfocus()
    return
end if

if  fare="" then
    messagebox("","SET FARE")
    sle_amount.setfocus()
    return
end if
double balance

balance=cash -price


 messagebox("",balance)

INSERT INTO cash_table  
         ( items.price   

  VALUES ( :price );
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Wepex
  • 163
  • 4
  • 13
  • 32
  • 1
    What problem are you experiencing? – Terry Jul 20 '12 at 17:50
  • 1
    Why you try to compare `double` with `string`? – Maximus Jul 20 '12 at 23:32
  • it gives: Error c0011 incompatible types in expression: double, string – Wepex Jul 21 '12 at 08:02
  • And, in general, telling us which line is throwing the error would help too (the error display shows the line number, and double-clicking on it jumps you to that line too), but Maximus already spotted it. Comparing the double variable cash to the string constant "" will throw this error (if cash="" then). – Terry Jul 22 '12 at 03:03
  • @Maximus IMHO you deserve the win; you called it before the problem description was complete!! Why not post an answer (instead of just a comment) so we can give credit where credit is due. – Terry Jul 27 '12 at 15:36

2 Answers2

3

From my comment

Why you try to compare double with string?

Comparing different types are illegal. Correct example

if trim(sle_cash.text) = "" then
Maximus
  • 10,751
  • 8
  • 47
  • 65
0

I think you are comparing double cash and double fare variables with "" (empty string) to find out if input fields are empty or not. Instead of that way, you can do something like this:

if trim(sle_cash.text)="" then
    messagebox("","CASH")
    sle_cash.setfocus()
    return
end if

if  trim(sle_fare.text)="" then
    messagebox("","SET FARE")
    sle_amount.setfocus()
    return
end if
Snow Blind
  • 1,164
  • 7
  • 12