TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: TIM HUTZLER
date: 1996-06-26 11:14:00
subject: Using fixed strings in s

Hi;
I have defined a TYPE that has fixed length strings like the
following:
TYPE Crec
    ...
    CName AS STRING * 20
    ...
END TYPE
DIM rec(100) AS SHARED Crec
However, when I attempt to access 'CName' in a sub like the
following...
SUB MySub (x??)
    ...
    foo$ = rec.CName(x??)
    ...
END SUB
I get compile error 421 (String operand expected)
Well, rec.CName *is* a string - so what's the problem?
I think I encountered this problem before, but I can't remember what
it took to correct it. It seems that the SUB assumes that rec.CName()
is a numeric. How can I get the sub to know better.
Any comments would be appreciated.
tnx
 
--- Maximus/2 3.01
---------------
** A related thread FOLLOWS this message.

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: DAYI0491 Date: 06/29/96
From: KURT KUZBA                                            Time: 02:08pm
\/To: TIM HUTZLER                                         (Read 6 times)
Subj: R: Using fixed strings in s

TH>   I have defined a TYPE that has fixed length strings
TH>   like the following:
TH>   TYPE Crec
TH>     ...
TH>     CName AS STRING * 20
TH>     ...
TH>   END TYPE
TH>   DIM rec(100) AS SHARED Crec
TH>   However, when I attempt to access 'CName' in a sub
TH>   like the following...
TH>   SUB MySub (x??)
TH>     ...
TH>     foo$ = rec.CName(x??)
TH>     ...
TH>   END SUB
TH>   I get compile error 421 (String operand expected)
TH>   Well, rec.CName *is* a string - so what's the problem?
th>.........................................................
   Pass the entire structure to the SUB. You must also define the
TYPE prior to the DECLARE for the SUB, which must state the type
of variable you want passed. Power Basic does NOT automatically
create a DECLARE statement as does Quick Basic. Test this once:
type txtstruct
   length as integer
   t as string * 40
end type
declare sub txtprint(t as txtstruct)
dim text as txtstruct
text.t = "hello": text.length = len(rtrim$(text.t))
txtprint text
print text.length; text.t
end
sub txtprint(t as txtstruct)
   print t.length; t.t
   t.t = "goodbye": t.length = len(rtrim$(t.t))
end sub

---
> ] Let he among you without sin cast the first... OW! HEY!!....

---------------
>>>>>>>>>>>>>>>>>>>>>> LAST Message In Thread <<<<<<<<<<<<<<<<<<<<<<

FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC   Ref: DAW00007 Date: 06/25/96
From: LAWRENCE GORDON                                       Time: 09:39pm
\/To: STEVE MCCRYSTAL (Rcvd)                              (Read 6 times)
Subj: errorlevel in pb3.x

On 23 Jun 96, Steve McCrystal wrote to Lawrence Gordon:
 LG> You can set an errorlevel by using the END statement, e.g.:
 SM>Apparently I didn't RTFM well enough! :^)
The wisdom of the compiler gods imbues every page. Keep studying it,
my son. :)
 SM>Thanks for the hint as well.  FWIW my comment about a 'superior compiler 
 SM>like PB' was *not* in jest - everything seems simpler in PB than in 
 SM>QB/PDS (except the much discussed switching to SUB windows).  The 
 SM>errorlevel thing sure is! :^)
I like the ARRAY SORT statement, too.
--- FMail 1.02
---------------
* Origin: Madman BBS * Chico, California * 916-893-8079 * (1:119/88)
* Origin: Toast House Remote (1:100/560.1)

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