| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | passing user types to su |
Hi y'all;
I get the following error when I try to compile the following test
program. I tried several different combinations, but I either get
this error, or some other relating to indavid variable types.
Here's the most common error as listed by my homespun IDE.
(I hope the border chars don't muck things up)
=========
+------------------------------------------------+
| Error 481: Parameter mismatch |
+------------------------------------------------+
| The parameters passed to a procedure or |
| function are not of the same type that was |
| defined in the corresponding definition or |
| DECLARE statement. This error also occurs when |
| variable types in a SWAP statement are not the |
| same. |
+------------------------------------------------+
I am experimenting with an effient way of effiently converting
strings in numeric variables and back. By using the UNION statement,
I can obtain the desired conversion without the need for MKx and CVx
functions.
======== here's the test program
DECLARE FUNCTION HexOut(Dbyte) AS STRING
UNION bw
b1 AS BYTE
b2 AS BYTE
b3 AS BYTE
b4 AS BYTE
END UNION
UNION Dbyte
B AS bw 'so I can look at individual bytes
Dd AS DWORD 'this is the numeric
Ds AS STRING * 4 'this will be the string representation
END UNION
DIM D4 AS Dbyte
DIM x AS DWORD 'counter
CLS
FOR x = 1 TO 2^32-1
LOCATE 1,1
D4.Dd = x
PRINT D4.Ds, D4.Dd, HexOut(D4.B.b1); HexOut(D4.B.b2); _
HexOut(D4.B.b3); HexOut(D4.B.b4)
NEXT
SLEEP 129 'look at results
FUNCTION HexOut (h AS Dbyte) AS STRING 'here's the problem
FUNCTION = RIGHT$("0"+HEX$(h),2)
END FUNCTION
___ Blue Wave/QWK v2.12
--- Maximus/2 3.01
---------------
** A related thread FOLLOWS this message.
FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: E1SS3340 Date: 01/23/97
From: KURT KUZBA Time: 11:55pm
\/To: TIM HUTZLER (Read 3 times)
Subj: R: passing user types to su
TH> I get the following error..
TH> ..relating to indavid variable types.
TH> | Error 481: Parameter mismatch |
TH> ======== here's the test program
TH> DECLARE FUNCTION HexOut(Dbyte) AS STRING
TH> UNION bw
TH> b1 AS BYTE
TH> b2 AS BYTE
TH> b3 AS BYTE
TH> b4 AS BYTE
TH> END UNION
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
th>......
This is known as the SCOPE of a variable.
You have defined a data type, which you use in a FUNCTION as an
argument. However, at the time you DECLARE the FUNCTION, there
does not exist any variable of the type named as an argument.
The DECLARE is not within the SCOPE of your defined data type.
Since your function is declared, and appears prior to the
creation of the data type, and then your program passes an
object of the defined type, the two types do not match.
Simply move your TYPE statements to the top of your file to
ensure that all FUNCTIONs and SUBs will be within their SCOPE.
---
> ] * Origin: Madman BBS * Chico, California * 916-893-8079 * (1:119/88)* Origin: SHOCK Therapy BBS, Boynton Beach FL (561)731-4378 (1:3609/64) |
|
| SOURCE: echomail via exec-pc | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.