I am using the following code to to interface to a DLL that was designed for using a VB user defined type structure.
PROCEDURE GetAgLeaderCardConfig
LPARAMETERS tnCardNumber, taCardConfig
DECLARE LONG get_al_config IN "aglead32.dll" ;
LONG CardNumber, ;
STRING @ ALCardConfig
*!* # Type AL_CONFIG Bytes
*!* 1 version As Integer 1 2
*!* 2 serial_no As Long 5 6 7 8
*!* 3 num_grains As Integer 9 10
*!* 4 num_loads As Integer 11 12
*!* 5 num_fields As Integer 13 14
*!* 6 records As Long 17 18 19 20
*!* 7 log_dev As Integer 21 22
*!* 8 gps_type As Integer 23 24
*!* 9 expand_flag As Integer 25 26
*!* 10,11,12 gs_pulses(0 To 2) As Integer 27 28 29 30 31 32
*!* 13 temp_off As Integer 33 34
*!* 14 ad_voltage As Integer 35 36
*!* 15 ftime As Long 39 40 41 42
*!* spare(0 To 31) As Byte 43(0) - 72(31)
*!*End Type
LOCAL lcCardConfig, lnCardConfig
lcCardConfig = SPACE(72)
DECLARE taCardConfig[15]
taCardConfig = 0
lnCardConfig = get_al_config(tnCardNumber, @lcCardConfig)
taCardConfig[1] = Str2Int(SUBSTR(lcCardConfig, 1, 2))
taCardConfig[2] = Str2Long(SUBSTR(lcCardConfig, 5, 4))
taCardConfig[3] = Str2Int(SUBSTR(lcCardConfig, 9, 2))
taCardConfig[4] = Str2Int(SUBSTR(lcCardConfig, 11, 2))
taCardConfig[5] = Str2Int(SUBSTR(lcCardConfig, 13, 2))
taCardConfig[6] = Str2Long(SUBSTR(lcCardConfig, 17, 4))
taCardConfig[7] = Str2Int(SUBSTR(lcCardConfig, 21, 2))
taCardConfig[8] = Str2Int(SUBSTR(lcCardConfig, 23, 2))
taCardConfig[9] = Str2Int(SUBSTR(lcCardConfig, 25, 2))
taCardConfig[10] = Str2Int(SUBSTR(lcCardConfig, 27, 2))
taCardConfig[11] = Str2Int(SUBSTR(lcCardConfig, 29, 2))
taCardConfig[12] = Str2Int(SUBSTR(lcCardConfig, 31, 2))
taCardConfig[13] = Str2Int(SUBSTR(lcCardConfig, 33, 2))
taCardConfig[14] = Str2Int(SUBSTR(lcCardConfig, 35, 2))
taCardConfig[15] = Str2Long(SUBSTR(lcCardConfig, 39, 4))
RETURN lnCardConfig
FUNCTION Str2Int
LPARAMETERS tcIntStr
RETURN ASC(SUBSTR(tcIntStr, 2)) * 256 + ;
ASC(SUBSTR(tcIntStr, 1))
FUNCTION Str2Long
LPARAMETERS tcLongStr
RETURN ASC(SUBSTR(tcLongStr, 4)) * 4294967296 + ;
ASC(SUBSTR(tcLongStr, 3)) * 65536 + ;
ASC(SUBSTR(tcLongStr, 2)) * 256 + ;
ASC(SUBSTR(tcLongStr, 1))
Everything works fine except I do not know how to make Str2Int and Str2Long return negative values. Can anyone tell me how?
Thank You.
Dennis Lindeman