Hi,
I'm using the attached Delphi Record to get data from a DLL written in 'C'. For some reason I get incorrect values returned (eg. I get a value of 49 when I'm expecting a value of 999).
Has anyone had any experience with this?
Thanks very much.
unit optsrecord;
interface
type
ITEM = Record //this record is only used inside the INFO record
plu_number: Packed Array[0..13] of Char; //Char is one byte in both Delphi and 'C'
description: Packed Array[0..11] of Char;
dept_number: SmallInt; //defined as 'sint' in 'C' (4 bytes)
flags: Word; //defined as 'uint' in 'C' (4 bytes)
first_pu: Char; //defined as 'char' in 'C' (1 byte)
second_pu: Char;
third_pu: Char;
second_conv_factor: Single; //defined as 'float' in 'C' (4 bytes)
third_conv_factor: Single;
reg_price: Single;
sale_price: Single;
shelf_price: Single;
promo_code: Packed Array [0..8] of Char;
upc_pkg_1: Char;
upc_pkg_2: Char;
upc_pkg_3: Char;
item_prefix: Packed Array [0..4] of Char;
qnt_sold: Single;
qnt_return: Single;
total_sales_amt: Single;
report_no: Word;
contract_price: Packed Array[0..5] of Single; //defined as 'array of float' in 'C' (4 bytes)
end;
TCashier_Table = Record //this record is only used inside the TCashier record
term_num, begin_tran_num, last_tran_num, status_flag: Word;
end;
TCashier = Record
sign_in: Word; // defined as 'uint' in 'C' (2 bytes)
dly_sale_ctr: SmallInt; // defined as 'sint' in 'C' (2 bytes)
dly_sale_dollar: Single; // defined as 'foat' in 'C' (4 bytes)
dly_pymt_ctr: SmallInt;
dly_pymt_dollar: Single;
dly_nsf_ctr: SmallInt;
dly_nsf_dollar: Single;
dly_prepaid_ctr: SmallInt;
dly_prepaid_dollar: Single;
dly_cod_coll_ctr: SmallInt;
dly_cod_coll_dollar: Single;
dly_charge_ctr: SmallInt;
dly_charge_dollar: Single;
dly_new_charge_ctr: SmallInt;
dly_new_charge_dollar: Single;
dly_cash_card_ctr: SmallInt;
dly_cash_card_dollar: Single;
dly_proc_card_ctr: SmallInt;
dly_proc_card_dollar: Single;
dly_empl_ctr: SmallInt;
dly_empl_dollar: Single;
dly_gift_cert_sold_ctr: SmallInt;
dly_gift_cert_sold_dollar:Single;
rtn_sale_ctr: SmallInt;
rtn_sale_dollar: Single;
rtn_charge_ctr: SmallInt;
rtn_charge_dollar: Single;
rtn_new_charge_ctr: SmallInt;
rtn_new_harge_dollar: Single;
rtn_cash_card_ctr: SmallInt;
rtn_cash_card_dollar: Single;
rtn_proc_card_ctr: SmallInt;
rtn_proc_card_dollar: Single;
rtn_empl_ctr: SmallInt;
rtn_empl_dollar: Single;
dly_cash: Single;
dly_debit_card: Single;
dly_ret_debit_card: Single;
dly_cheque: Single;
dly_gift_cert: Single;
dly_visa: Single;
dly_ret_visa: Single;
dly_mc: Single;
dly_ret_mc: Single;
dly_amex: Single;
dly_ret_amex: Single;
dly_dc_enroute: Single;
dly_ret_dc_enroute: Single;
dly_smart_card: Single;
dly_ret_smart_card: Single;
dly_coupon: Single;
dly_us: Single;
dly_donat_gift: Single;
interm_dep_cash: Single;
interm_dep_us_cash: Single;
interm_dep_cash_cnv: Single;
interm_dep_cheque: Single;
dly_tax: Single;
discount_amt: Single;
name: Packed Array[0..20] of Char;
active: Char; //defined as 'uchar' in 'C'
teller_num: Word;
in_training: SmallInt;
login_code: Word;
items_sold: SmallInt;
total_sold: Single;
c_table: packed Array[0..7] of TCASHIER_TABLE;
end;
INFO = Record {gets Logo info, Store Number and Register Number}
max_discount: Smallint; //defined as 'sint' or signed integer in 'C'
gen_options: Word; //defined as 'uint' or unsigned integer in 'C'
idle_message: Packed Array[0..1,0..20] of Char;
round_message: String[160];
logo: Packed Array[0..7,0..40]of Char;
flogo: String[7];
endorse: Packed Array[0..7,0..40]of Char;
fendorse: String[8];
store_num: Word; //defined as 'uint' or unsigned integer in 'C'
reg_num: Word;
super_key_reqd: Word;
taxrng,taxpcr: Packed Array[0..1,0..9]of Single; //defined as FLOAT in 'C'
tbl1,tbl2: Packed Array[0..20]of Char; //defined as 'char'in 'C'
nrungs: SmallInt; //defined as 'sint' or signed integer in 'C'
max_refund: Single;
layw_deposit: SmallInt;
Item1: ITEM;
baud_rate: LongWord; //defined as 'long' in 'C'
employee_discount_pcr: Word; //defined as 'uint' or unsigned integer in 'C'
c_port: SmallInt; //defined as 'sint' or signed integer in 'C'
s_port: SmallInt;
r_port: SmallInt;
x_port: SmallInt;
printer_config: Word; //defined as 'uint' or unsigned integer in 'C'
max_login_attempts: Word;
form_feed_line: Word;
kbd_type: Word;
layway_xtra_rcpt: Word;
ccp_num: Word;
spc_acc_num: LongWord; //defined as 'long' in 'C'
us_exch_rate: Single; //defined as FLOAT in 'C'
tax_options: Char; //defined as 'uchar' in 'C'
extra_ptr: SmallInt;
trickle_interval_idle: LongWord;
trickle_interval_login: LongWord;
cqp_pcr: Word;
upcharge_pcr: Word;
rsn_cde_msg: Packed Array [0..9,0..4] of Char;
pricing_type: Word;
spec_discount: Word;
begin_batch_num: LongWord;
end_batch_num: LongWord;
next_batch_num: LongWord;
ret_batch_num: LongWord;
ret_end_batch_num: LongWord;
ret_next_batch_num: LongWord;
gst_reg_number: Packed Array [0..23] of Char;
super_password: LongWord;
term_id_in: Packed Array [0..8] of Char;
end;
implementation
end.
I'm using the attached Delphi Record to get data from a DLL written in 'C'. For some reason I get incorrect values returned (eg. I get a value of 49 when I'm expecting a value of 999).
Has anyone had any experience with this?
Thanks very much.
unit optsrecord;
interface
type
ITEM = Record //this record is only used inside the INFO record
plu_number: Packed Array[0..13] of Char; //Char is one byte in both Delphi and 'C'
description: Packed Array[0..11] of Char;
dept_number: SmallInt; //defined as 'sint' in 'C' (4 bytes)
flags: Word; //defined as 'uint' in 'C' (4 bytes)
first_pu: Char; //defined as 'char' in 'C' (1 byte)
second_pu: Char;
third_pu: Char;
second_conv_factor: Single; //defined as 'float' in 'C' (4 bytes)
third_conv_factor: Single;
reg_price: Single;
sale_price: Single;
shelf_price: Single;
promo_code: Packed Array [0..8] of Char;
upc_pkg_1: Char;
upc_pkg_2: Char;
upc_pkg_3: Char;
item_prefix: Packed Array [0..4] of Char;
qnt_sold: Single;
qnt_return: Single;
total_sales_amt: Single;
report_no: Word;
contract_price: Packed Array[0..5] of Single; //defined as 'array of float' in 'C' (4 bytes)
end;
TCashier_Table = Record //this record is only used inside the TCashier record
term_num, begin_tran_num, last_tran_num, status_flag: Word;
end;
TCashier = Record
sign_in: Word; // defined as 'uint' in 'C' (2 bytes)
dly_sale_ctr: SmallInt; // defined as 'sint' in 'C' (2 bytes)
dly_sale_dollar: Single; // defined as 'foat' in 'C' (4 bytes)
dly_pymt_ctr: SmallInt;
dly_pymt_dollar: Single;
dly_nsf_ctr: SmallInt;
dly_nsf_dollar: Single;
dly_prepaid_ctr: SmallInt;
dly_prepaid_dollar: Single;
dly_cod_coll_ctr: SmallInt;
dly_cod_coll_dollar: Single;
dly_charge_ctr: SmallInt;
dly_charge_dollar: Single;
dly_new_charge_ctr: SmallInt;
dly_new_charge_dollar: Single;
dly_cash_card_ctr: SmallInt;
dly_cash_card_dollar: Single;
dly_proc_card_ctr: SmallInt;
dly_proc_card_dollar: Single;
dly_empl_ctr: SmallInt;
dly_empl_dollar: Single;
dly_gift_cert_sold_ctr: SmallInt;
dly_gift_cert_sold_dollar:Single;
rtn_sale_ctr: SmallInt;
rtn_sale_dollar: Single;
rtn_charge_ctr: SmallInt;
rtn_charge_dollar: Single;
rtn_new_charge_ctr: SmallInt;
rtn_new_harge_dollar: Single;
rtn_cash_card_ctr: SmallInt;
rtn_cash_card_dollar: Single;
rtn_proc_card_ctr: SmallInt;
rtn_proc_card_dollar: Single;
rtn_empl_ctr: SmallInt;
rtn_empl_dollar: Single;
dly_cash: Single;
dly_debit_card: Single;
dly_ret_debit_card: Single;
dly_cheque: Single;
dly_gift_cert: Single;
dly_visa: Single;
dly_ret_visa: Single;
dly_mc: Single;
dly_ret_mc: Single;
dly_amex: Single;
dly_ret_amex: Single;
dly_dc_enroute: Single;
dly_ret_dc_enroute: Single;
dly_smart_card: Single;
dly_ret_smart_card: Single;
dly_coupon: Single;
dly_us: Single;
dly_donat_gift: Single;
interm_dep_cash: Single;
interm_dep_us_cash: Single;
interm_dep_cash_cnv: Single;
interm_dep_cheque: Single;
dly_tax: Single;
discount_amt: Single;
name: Packed Array[0..20] of Char;
active: Char; //defined as 'uchar' in 'C'
teller_num: Word;
in_training: SmallInt;
login_code: Word;
items_sold: SmallInt;
total_sold: Single;
c_table: packed Array[0..7] of TCASHIER_TABLE;
end;
INFO = Record {gets Logo info, Store Number and Register Number}
max_discount: Smallint; //defined as 'sint' or signed integer in 'C'
gen_options: Word; //defined as 'uint' or unsigned integer in 'C'
idle_message: Packed Array[0..1,0..20] of Char;
round_message: String[160];
logo: Packed Array[0..7,0..40]of Char;
flogo: String[7];
endorse: Packed Array[0..7,0..40]of Char;
fendorse: String[8];
store_num: Word; //defined as 'uint' or unsigned integer in 'C'
reg_num: Word;
super_key_reqd: Word;
taxrng,taxpcr: Packed Array[0..1,0..9]of Single; //defined as FLOAT in 'C'
tbl1,tbl2: Packed Array[0..20]of Char; //defined as 'char'in 'C'
nrungs: SmallInt; //defined as 'sint' or signed integer in 'C'
max_refund: Single;
layw_deposit: SmallInt;
Item1: ITEM;
baud_rate: LongWord; //defined as 'long' in 'C'
employee_discount_pcr: Word; //defined as 'uint' or unsigned integer in 'C'
c_port: SmallInt; //defined as 'sint' or signed integer in 'C'
s_port: SmallInt;
r_port: SmallInt;
x_port: SmallInt;
printer_config: Word; //defined as 'uint' or unsigned integer in 'C'
max_login_attempts: Word;
form_feed_line: Word;
kbd_type: Word;
layway_xtra_rcpt: Word;
ccp_num: Word;
spc_acc_num: LongWord; //defined as 'long' in 'C'
us_exch_rate: Single; //defined as FLOAT in 'C'
tax_options: Char; //defined as 'uchar' in 'C'
extra_ptr: SmallInt;
trickle_interval_idle: LongWord;
trickle_interval_login: LongWord;
cqp_pcr: Word;
upcharge_pcr: Word;
rsn_cde_msg: Packed Array [0..9,0..4] of Char;
pricing_type: Word;
spec_discount: Word;
begin_batch_num: LongWord;
end_batch_num: LongWord;
next_batch_num: LongWord;
ret_batch_num: LongWord;
ret_end_batch_num: LongWord;
ret_next_batch_num: LongWord;
gst_reg_number: Packed Array [0..23] of Char;
super_password: LongWord;
term_id_in: Packed Array [0..8] of Char;
end;
implementation
end.