[futurebasic] Re: [FB] random strings

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 1998 : Group Archive : Group : All Groups

From: jonathan <jonathan@...>
Date: Mar, 27 Oct 98 19:07:43 +0100
>If I create a local var and then neglect to assign it a value, whether by
>accident or by design (I _meant_ for it to be +/-32767, honest I did), it
>comes out with a random value. 

Not exactly. The valus is not a true random. It comes out with whatever
value was in there before that space was divided up to (possibly)
contain your var. It could be zero, but it could be anything.

Think about it. You launch surfWriter, then you quit and launch your app.
When you quit SurfWriter, the Mac didn't waste time putting all those 
spaces
in memory to zero like when you erase a file on disk, the mac, just kills
the reference in it's catalog, but the info is still there on the disk
waiting to be overwritten. When you launch the next app, it grabs the 
space
that possibly was previously occupied by SurfWriter, and you appear to
get 'random' data in your decalred but not zeroed variables.

>Similarly with a string var. But in the latter
>case... what, exactly, is happening in the variable? Is each individual byte
>in the string being set to a random 0-255 character? What about the length
>byte (assuming I didn't DIM it with a specified length)?

Because of the special case of a string, ie the first byte is the length
the result that appears will depend on this, and whether the bytes in
memory are displayable or not. For the rest, see above.

>Related and even more straightforward question: I'm told that
>IF LEN(given$)
>is much faster than
>IF given$ <> ""
>Is this because, in the first case, the app just takes a quick look at the
>length byte, while in the second case it sets up two strings, given$ and "",
>and compares them? If their respective length bytes are different, does it
>stop right there, or does it do 255 successive comparisons?

Sincerely the only to really find out is to jump into MacsBug and look.
As for IF LEN( given$) - i think you're right.
As for IF( given$ <> "") - i think there is a toolbox call that does the
comparing, not necessarily char by char, 'cos there exists ways to quicken
things, but at the basics, you're probably right again.

>>>  Not looking the gift horse in the mouth, just deciding which end I'd
>rather be facing when I do get on it.  :) <<
[snip]
>> the _side_ is the preferred
>access route. Except, possibly, in Texas.

This post is taking a curious turn... Why possibly in Texas?

HTH
jonathan


-------------------------------------------------------------
! "format utile"  studio de graphisme/graphic design studio !
!      32 bd de Menilmontant, 75020 Paris, France           !
!    phone +33 1 43 49 02 04 +++ fax +33 1 43 49 16 51      !
-------------------------------------------------------------
           *** coming soon to a browser near you ***
           <http://www.cybercities.com/formatutile>
-------------------------------------------------------------