18/01/97 08:23, Tim Hutzler escrib¡a a All:
Hola Tim!
TH> I get the following error when I try to compile the following test
TH> program. I tried several different combinations, but I either get
TH> this error, or some other relating to indavid variable types.
You have several errors. Look at this...
TH> DECLARE FUNCTION HexOut(Dbyte) AS STRING
Here you declare that HexOut will receive a DByte UNION, but:
TH> PRINT D4.Ds, D4.Dd, HexOut(D4.B.b1); HexOut(D4.B.b2); _
here you pass a byte. Looking at the function I think you must declare the
function to receive a byte instead a DByte.
TH> UNION bw
TH> b1 AS BYTE
TH> b2 AS BYTE
TH> b3 AS BYTE
TH> b4 AS BYTE
TH> END UNION
Here you are confused with the TYPE and UNION mean. A Dword number has 4
bytes, not 4 different names for the same byte. This piece of code must be:
Type BW
b1 As Byte
b2 As Byte
b3 As Byte
b4 As Byte
End Type
TH> UNION Dbyte
TH> B AS bw 'so I can look at individual bytes
TH> Dd AS DWORD 'this is the numeric
TH> Ds AS STRING * 4 'this will be the string representation
TH> END UNION
This portion is fine...
TH> FOR x = 1 TO 2^32-1
TH> LOCATE 1,1
TH> D4.Dd = x
TH> PRINT D4.Ds, D4.Dd, HexOut(D4.B.b1); HexOut(D4.B.b2); _
TH> HexOut(D4.B.b3); HexOut(D4.B.b4)
TH> NEXT
Here you are printing the HEX format in reverse order.
TH> SLEEP 129 'look at results
TH> FUNCTION HexOut (h AS Dbyte) AS STRING 'here's the problem
Function HexOut (h As Byte) As String
TH> FUNCTION = RIGHT$("0"+HEX$(h),2)
TH> END FUNCTION
With this changes your code may work fine.
Saludotes,
,,, JOS (2:348/102)
`0-0' jmejuto@pobox.com
/-(_)-\ SysOp de ÄÍEDIÍBBSÍÄ
http://www.pobox.com/~jmejuto
---
---------------
* Origin: When I Need Data Output Without Speed 3.1 (2:348/102.99)
|