---------------- / / h o m a s --- CrossPoint v3.11 R * Origin: PBSOUND, PBFILES (32MB), PBFAQ, PBRULES, PBHIVGA at: 2:2410/330.1) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: ED100000 Date: 08/30/97 From: RONALD SCHLEGEL Time: 11:31am \/To: ALL (Read 1 times) Subj: Odd-Ball code...:) Hi All... Here is some more of my odd-ball stuff . Feel free to use/modify/suggest/etc. I use this little snippet for 1 of 2 things...<1> If I want to show a "twirly" animation while scanning a *.DAT file, <2> If I want to show a percentage of the file that has been scanned for various criteria. (I even have a situation where I needed BOTH.) The key is to use your imagination. If anyone wants/needs a sample program or 2 to show how _I_ FULLY use these, just ask...I'll be happy to post something for you...:) --------------------- 'LOOK4ME.BAS - PUBLIC DOMAIN by Ronald Schlegel DEFINT A-Z X% = FREEFILE OPEN "MYDATA.DAT" FOR RANDOM AS #X% LEN = LEN(MyData) NumRecs = LOF(X%)/LEN(MyData) FOR C = 1 TO NumRecs GET #X%, , MyData Twirley = Twirley + 1 'Assigns a value to Twirley IF Twirley = 5 THEN 'We only need 4, so if its 5...reset it Twirley = 1 'to 1 before we continue. END IF SELECT CASE Twirley 'Which one do we draw... CASE 1 Twir$ = CHR$(179) '| CASE 2 Twir$ = CHR$(47) '/ CASE 3 Twir$ = CHR$(196) '- CASE 4 Twir$ = CHR$(92) '\ END SELECT LOCATE ROW, 43: COLOR 13, 0: PRINT Twir$ 'This routine allows me to return a percentage status of where I am 'in the data file. RecsRead = C Percent = (RecsRead * 100)/NumRecs PCent = INT(Percent) LOCATE 24, 4: COLOR 12, 0: PRINT STR$(PCent);: COLOR 9, 0: PRINT " % Scanned for : ";: COLOR 10,0: PRINT Tsrch$ NEXT ------------------------------------ -Ron * RM 1.31 3129 * Junk is stuff we throw away. Stuff is junk we keep. --- TriToss (tm) Professional 11.0 - #229 * Origin: * Dynasty BBS * The Home of Crazy Nights Software * (1:110/1065.0) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: ED300000 Date: 09/02/97 From: FRANK COX Time: 12:10am \/To: RONALD SCHLEGEL (Read 1 times) Subj: Odd-Ball code...:) > Here is some more of my odd-ball stuff . Feel free to > use/modify/suggest/etc. > Twirley = Twirley + 1 'Assigns a value to Twirley INCR TWIRLEY ' would be slightly faster --- Msgedsq 2.2e * Origin: THE BIG ELECTRIC CAT Melville Sask *SDS* *PDN* (1:140/53) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: ED500000 Date: 09/04/97 From: RONALD SCHLEGEL Time: 03:36pm \/To: FRANK COX (Read 1 times) Subj: Odd-Ball code...:) Frank, FC> > Twirley = Twirley + 1 'Assigns a value to Twirley FC> INCR TWIRLEY ' would be slightly faster Ya know, I never thoght of that & you're right. I'll revise the code & repost it...:) -Ron * RM 1.31 3129 * Just wanted to get my official stamp on a few taglines --- TriToss (tm) Professional 11.0 - #229 * Origin: * Dynasty BBS * The Home of Crazy Nights Software * (1:110/1065.0) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: EDA00000 Date: 09/04/97 From: ROWAN_CROWE Time: 03:25pm \/To: FRANK COX (Read 1 times) Subj: Odd-Ball code...:) * Frank Cox writes to Ronald Schlegel, on Tuesday September 02 1997 at 00:10: >> Here is some more of my odd-ball stuff . Feel free to >> use/modify/suggest/etc. >> Twirley = Twirley + 1 'Assigns a value to Twirley FC> INCR TWIRLEY ' would be slightly faster If Powerbasic is reasonably "smart", both lines would probably generate identical machine code (assuming it's an integer). Cheers. ... rowan@sensation.net.au | http://www.rowan.sensation.net.au/ --- * Origin: Sensation: Melbourne AUSTRALIA. (3:635/728.1) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: EDF00000 Date: 09/10/97 From: DAVID WILLIAMS Time: 06:57pm \/To: RONALD SCHLEGEL (Read 1 times) Subj: Scramble -> Got a question for ya. Anyone know of a routine that will randomly -> scramble a string? -> -> Example: -> -> A$ = "test" -> -> B$ = (scramble routine) -> -> PRINT B$ -> -> ..and the output would be something like: -> -> estt Well... L% = LEN(A$) DIM L$(L%) FOR X% = 1 TO L% L$(X%) = MID$(A$,X%,1) NEXT RANDOMIZE TIMER FOR X% = 1 TO L%-1 SWAP L$(X%), L$(X% + INT(RND * (L% + 1 - X%))) NEXT B$ = "" FOR X% = 1 TO L% B$ = B$ + L$(X%) NEXT PRINT B$ The lines just after the RANDOMIZE TIMER are a general way to "shuffle" any array into a random order, just like shuffling a deck of cards. dow --- PCBoard (R) v15.3 (OS/2) 5 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: EDF00001 Date: 09/10/97 From: DAVID WILLIAMS Time: 07:03pm \/To: ROBERT FORTUNE (Read 1 times) Subj: Scramble -> SUB Scramble (Word$) -> LOS% = LEN(Word$) ' the Length Of String passed -> FOR I% = 1 TO LOS% -> DO SP% = INT(RND * LOS%) + 1 ' swap pointer (into the Word$ string) -> LOOP UNTIL SP% <> I% ' no sense swapping character with self -> Temp$ = MID$(Word$, I%, 1) ' store this character temporarily -> MID$(Word$, I%, 1) = MID$(Word$, SP%, 1) ' and do the swap -> MID$(Word$, SP%, 1) = Temp$ ' reassign char from stored temp -> character NEXT I% -> END SUB Nope. This does, indeed, scramble the word, but *not* into a strictly random order. If you do it a large number of times, you will find that some output orders come up more often than others. I just posted a message with a "proper" way to do it. dow --- PCBoard (R) v15.3 (OS/2) 5 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: EDF00002 Date: 09/10/97 From: DAVID WILLIAMS Time: 07:05pm \/To: MARVIN STAHL (Read 1 times) Subj: Re: Scramble -> SUB Scramble (Text$) -> IF LEN(Text$)>1 THEN ' string must be at least 2 chars -> L=LEN(Text$) ' number of chars in string -> FOR I=1 TO L+L ' exchange 2 times len of text -> X=1+INT(RND*L) ' pick a random char -> Y=1+INT(RND*L) ' pick a second random char -> C$=MID$(Text$,X,1) ' save original char 1 (X) -> MID$(Text$,X,1)=MID$(Text$,Y,1)' exchange char 1 with char 2 (Y) -> MID$(Text$,Y,1)=C$ ' put char 1 at position of char -> 2 -> NEXT I ' till 25 (or more...) times -> END IF END SUB ' done - exit subroutine I doubt very much whether this will produce truly random results, either. dow --- PCBoard (R) v15.3 (OS/2) 5 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)