--------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00196 Date: 04/20/98 From: PETER DALTON Time: 08:45am \/To: DAVID WILLIAMS (Read 3 times) Subj: using RND On (18 Apr 98) David Williams wrote to All... Hi David, DW> I've noticed a lot of code posted here recently that doesn't look too DW> great to me. In particular, a lot of people seem to use loops that DW> generate RNDs over and over again until some criterion is satisfied. DW> This is (almost) *never* necessary! far be it from me to even hint at the possibility of a criticism... but... DW> 130 DIM A%(49) doesn't this set all elements of the array to zero? DW> 180 ' start of shuffling loop erm, doesn't this use a 'loop' of some kind :-) DW> 200 ' shuffle random 6 numbers into first 6 positions um, what for? DW> 210 FOR X% = 1 TO 6 DW> 220 Y% = INT((48) * RND) + 1 ok, how about using your loop as modified above then IF A%(Y%) <> 0 then 220 A%(Y%)=1 NEXT the numbers will be different and there's no need to sort them as you simply read each element of the array from 1 upwards and if the element value is non-zero you print the element number. Success Peter --- PPoint 1.88 * Origin: Peter Points at last! (2:254/60.26) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00197 Date: 04/21/98 From: RICK PEDLEY Time: 12:58pm \/To: MIKE WYNNE (Read 3 times) Subj: Help needed (geometry code) -=> Quoting Rick Pedley to Mike Wynne <=- Two corrections: RP> The fastest way I can think of is to drop a perpendicular from (x2,y2) RP> to the line between (x3,y3) and (x1,y1). Now you have a right-angled RP> triangle formed by (x2,y2), (x1,y1), and (x4,y4). RP> RP> RP> (x2,y2) RP> /\ RP> /| \ RP> / | \ RP> / | \ RP> / | \ RP> / | \ RP> / | \ RP> /______|_______\ RP> (x3,y3) (x4,y4) (x1,y1) RP> RP> Find the length of the perpendicular (y2 - y4). Find the length of the RP> hypotenuse -> SQR((x1 - x2)^2 + (y2 - y1)^2). Should read.. (y2 - y4)^2) but doesn't really matter because they're the same value. RP> The length of the perpendicular divided by the length of the RP> hypotenuse gives the sine of the angle at (x1,y1), which we'll call z. RP> The arcsin of z in radians is found by: RP> RP> ATN(z / SQR(-x * x + 1 + 1E-37)) The x's should be z's. --- Blue Wave/DOS v2.20 * Origin: ...the vented spleen - kingston on (613) 544-9332 (1:249/139) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00198 Date: 04/18/98 From: RICK PEDLEY Time: 09:10pm \/To: JOHN MCGRATH (Read 3 times) Subj: bottom lines? -=> Quoting John McGrath to All <=- JM> Hello All! JM> Im using VBDOS std v1 and would like to know if it is possible to JM> print at the bottom of the screen without the rest of the of the JM> screen scrolling up. I have done this before using TheDraw and JM> bsaving the bottom bit but this time I want to use all the screen if JM> possible. Put a semi-colon at the end of your PRINT statement: LOCATE 24,80: PRINT "*"; --- Blue Wave/DOS v2.20 * Origin: ...the vented spleen - kingston on (613) 544-9332 (1:249/139) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00199 Date: 04/20/98 From: RICK PEDLEY Time: 09:15am \/To: MIKE WYNNE (Read 3 times) Subj: Help needed (geometry code) -=> Quoting Mike Wynne to All <=- MW> I need QB code to do the following: MW> Calculate the angle (radians) subtended at a point by two lines MW> joining from 2 other points, given the x & y coordinates of all 3 MW> points. MW> ie: the internal angle at the apex of a triangle, errrr if you get my MW> meaning :) MW> I have written some code to do this but I feel that a totally MW> different approach might be more tidy and faster. Speed is the key MW> here really. Say you want to find the value of the angle at (x1, y1) in this triangle: (x2,y2) /\ / \ / \ / \ / \ / \ / \ /______________\ (x3,y3) (x1,y1) The fastest way I can think of is to drop a perpendicular from (x2,y2) to the line between (x3,y3) and (x1,y1). Now you have a right-angled triangle formed by (x2,y2), (x1,y1), and (x4,y4). (x2,y2) /\ /| \ / | \ / | \ / | \ / | \ / | \ /______|_______\ (x3,y3) (x4,y4) (x1,y1) Find the length of the perpendicular (y2 - y4). Find the length of the hypotenuse -> SQR((x1 - x2)^2 + (y2 - y1)^2). The length of the perpendicular divided by the length of the hypotenuse gives the sine of the angle at (x1,y1), which we'll call z. The arcsin of z in radians is found by: ATN(z / SQR(-x * x + 1 + 1E-37)) The 1E-37 seems mysterious but all it does is add a tiny number to the result to avoid division by zero errors. Seems like a lot of code but at least we don't need to find the lengths of the other two sides of the triangle. --- Blue Wave/DOS v2.20 * Origin: ...the vented spleen - kingston on (613) 544-9332 (1:249/139) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00200 Date: 04/14/98 From: CHRIS GUNN Time: 11:23pm \/To: TERRY RETT (Read 3 times) Subj: Re: random letters TR> does any one know how to get qbasic to generate random letters , like TR> you would use to make a program which would generate random pass words TR> ,(txt) or .bas source, i can get it to generate random numbers just TR> not letters ??? Howdy Terry, Try using K$=CHR$(X%) with X% random between 65 and 90 for all Caps letters and between 48 and 57 for the numbers. I suggest printing out the ASII table in QuickBasic's help as one of your table top references for many programming tasks. Chris --- FMail 0.96 * Origin: BIZynet - Worldwide Business via the E-Ways (1:15/55.1) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00201 Date: 04/16/98 From: RYAN POTETZ Time: 12:24pm \/To: NIGEL TRAVES (Read 3 times) Subj: Screen Saver I downloaded a QBasic 1.0 program that allows you to write TSRs in BASIC or Qbasic. It might be useful if you wanted to try it out. --- TriToss (tm) Professional 11.0 - #42 * Origin: SkyWatch - Your Astronomy Connection (1:140/118.0) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00202 Date: 04/14/98 From: TYS ARMSTRONG Time: 02:53pm \/To: CHRIS GUNN (Read 3 times) Subj: Re: Multiple eofs -=> Quoting Chris Gunn to David Williams <=- CG> It sure might make a good story. Picture a room full of chimpanzies CG> at Microsoft making random changes to code until maybe it works right. CG> The keys will all have little icons instead of letters. {grin} Tell me if I'm wrong, but isn't that how it already is? hehehehe stupid ms Regards, Tyson ... If only women came with pull-down menus and on-line help. ___ Blue Wave/QWK v2.12 # PDQWK 2.1 #3 --- * Origin: NetComm BBS 303-730-7045 (1:104/603.0) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00203 Date: 04/17/98 From: BRUCE BECK Time: 11:47am \/To: DAVID WILLIAMS (Read 3 times) Subj: Re: random letters -=> Quoting David Williams to Bruce Beck <=- DW> RANDOMIZE TIMER DW> PW$ = "" DW> FOR Count% = 1 TO 6 DW> PW$ = PW$ + CHR$(65 + INT(26 * RND)) DW> NEXT DW> PRINT "The password is "; PW$ DW> Easier, no? Faster, too! Yes, but with my setup, the user has more room to customs if he/she wants to. :> TTYL, Bruce Beck - Sysop of the Adult NiteClub - bwbba@juno.com ... In more ways then one!!!!!!!! --- FastEcho 1.46 [Registered] * Origin: ={T.A.N.C}= (1:2630/139) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00204 Date: 04/17/98 From: DAVID WILLIAMS Time: 02:26pm \/To: BRUCE CORBETT (Read 3 times) Subj: random letters -> RandomNum: -> RANDOMIZE TIMER .... a lot deleted for brevity ... -> IF LEN(Password$) < 5 THEN GOTO RandomNum Bad idea! That means you're executing RANDOMIZE TIMER over and over again, which not only wastes time but can actually make the RNDs *less* like real random numbers! RANDOMIZE TIMER should be executed just once, near the beginning of the program, before any RNDs are generated. It should *never* be put inside any loops, which would cause it to be executed repeatedly. dow --- PCBoard (R) v15.3 (OS/2) 5 * Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710) --------------- FIDO MESSAGE AREA==> TOPIC: 125 QUICK BASIC Ref: F5G00205 Date: 04/18/98 From: MARKUS TREINEN Time: 03:01am \/To: TERRY RETT (Read 3 times) Subj: random letters ---- *Terry Rett* mute am 14.04.98 zum Thema ---- *"random letters"* folgendes blubbern: ;) TR> does any one know how to get qbasic to generate random letters , like you TR> would TR> use to make a program which would generate random pass words ,(txt) or TR> .bas source, i can get it to generate random numbers just not letters ??? Hmm try this: RandomLetter$ = CHR$(INT((RND * 26) + 65))) That would return a Letter of the range A..Z For Lowercase Letters user this: RandomLetter$ = CHR$(INT((RND * 26) + 97))) Ciao, *Hoshy Markus!!!* eMail -> Tawerner@gmx.net Homepage -> http://cyberjunkie.com/Tawerner --- Hasta-la-vista 0.91 * Origin: Warp 5 - Der Umwelt zuliebe! (2:2452/455.8)