TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: TIM HUTZLER
from: ANTON MONROE
date: 1996-06-14 12:15:00
subject: Passing a field

TH> AM> You need to tell the sub what kind of string to expect. Try
TH>   > changing it to
TH> AM> SUB pout (x%, x$, t as string * 15)
TH> That does not work.
TH> I also tried (t as xs) as 'xs' is a user defined type.
It works here.  And PowerBasic does not have an error that says 'does
not work'.
In the example you gave, t is a 15-byte fixed-length string, so why
in the world would you tell the SUB it is a user-defined type?  The SUB
statement is where you tell the subroutine what kind of variable you
will pass it.  The error 481 you got is telling you that you are trying
to pass a different kind of variable than you said you would.
You gave two variations, A and B.  in B, you tell the sub to expect a
variable-length string but try to pass it a fixed-length string.  That
causes an error 481/parameter mismatch.  In A, you convert the
fixed-length string to a variable-length string, call the sub, and
convert the value it returns back to fixed length.  That, naturally,
works.  (And if you want to use that subroutine for strings with a
length of other than 15 bytes, might be a better way to do it anyway).
BTW, your example has two different variables called t.  One is of a
user-defined type in the main level, the other is a variable-length
string in the subroutine.  Don't confuse them.
 * RM 1.31 1209 * Anton Monroe   70304.3663@compuserve.com
--- FidoPCB v1.4 [ff013/c]
---------------
* Origin: Sound Advice - 24 Nodes (816)436-4516 (1:280/333)

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™.