Weekly Qbasic and Qb64 Lesson Topics
August 16, 2018, 02:19:01 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
   Home   Help Search Arcade Links Staff List Login Register  

Pages: [1] 2 3 ... 10
 1 
 on: June 18, 2018, 08:05:58 am 
Started by parsec - Last post by parsec
Hi,
I have a problem rounding numbers: why

PRINT CLNG(90.7755 * 1000) / 1000 = 90.776

and instead

PRINT CLNG(90.7754 * 1000) / 1000 = 90.77500000000001?

I'm becoming crazy!
Thanks a lot!!

fabio


 2 
 on: June 17, 2018, 10:55:59 am 
Started by parsec - Last post by parsec
Hello!
I live in the wonderful Italy and my English is very terrible, but now I can use the web to have assistance, not like when I started using basic program, when dinosaurs wandered around... Sad
If someone want to correct my English texts is welcome! ...In exchange I could teach how to cook a very tasty spaghetti!! Cheesy Cheesy
So, I came in this forum to have some answer about this program since I didn't used it since dozens years ago...

Fabio

 3 
 on: January 12, 2018, 06:42:18 am 
Started by PhilAJ - Last post by PhilAJ
Hope someone can help me - I have a little QB64 program that loads a website - passing details from the command line. This works fine - BUT - it leaves the command window open.

Anybody know how I can close this automatically once the web page loaded.

My code is; (actual webpage changed)

SHELL "http://www.bbc.co.uk"

I have tried using _HIDE and _SHELLHIDE but don't seem to work.

ANy help appreciated.

Phil

 4 
 on: January 03, 2018, 11:29:36 am 
Started by Luke - Last post by Luke
I discovered a QB64 work around for the Fundamental Problem. just above the Z$=input (LOC(2),#2) statement i added line ON ERROR GOTO EHandler. Then at the end of the program I put
EHandler: 
errfile$ = _INCLERRORFILE$
RESUME NEXT

I used LOC for length of input record b/c LOF always =0. The EOF=-1 always generates an INPUT PAST END OF FILE error. This way the program steps over the error and continues.
It may not be the best way but it works for me.
As for the every other letter read. I jury rigged the output message of the A/D with spaces to output the characters in the position captured by the input command. Weird but it works and I am continuing with my project not really understanding why it's that way.

 5 
 on: December 18, 2017, 03:06:58 pm 
Started by Luke - Last post by Luke
When one opens a com port to read a serial data buffer the open command automatically sets the EOF, LOC, and LOF to no message state.
I.E. the statement OPEN "COM3: 9600,n,8,1" for INPUT AS #1 will set EOF=-1. When attempt is made to obtain data from the com buffer with the INPUT statement you get an INPUT PAST END error because EOF=-1.
When you open the com port with the FOR RANDOM option then an attempt to obtain data with a GET statement you get a BAD RECORD LENGTH error due to LOF=0.
I have yet to find a way around this problem.

I have an A/D converter connected to a 1.2 V battery that has placed the message:   Voltage = 1.2* in the buffer. If I open FOR INPUT and upon the INPUT PAST END OF FILE error a DO YOU WANT TO CONTINUE dialog box appears. IF I select YES I get Vlae=12. That is every other character in the buffer. I altered the A/D output spacing to shift things by one space at the beginning and I get otg.2* . I.E the missing letters. Although not correct by any means it gives me confidence that the correct message is sitting in the buffer. I just can't read it because of the above defined problem.
Has anyone else encountered this problem? Is it due to my particular version compiler? Is there a "work around?"

I discovered a QB64 work around for the Fundamental Problem. just above the Z$=input (LOC(2),#2) statement i added line ON ERROR GOTO EHandler. Then at the end of the program I put
EHandler: 
errfile$ = _INCLERRORFILE$
RESUME NEXT

I used LOC for length of input record b/c LOF always =0. The EOF=-1 always generates an INPUT PAST END OF FILE error. This way the program steps over the error and continues.
It may not be the best way but it works for me.








 6 
 on: December 13, 2017, 06:26:41 pm 
Started by Luke - Last post by Luke
I am getting "bad record length" error at the GET #1, ,m$ statement in the following QB64 code. I can't seem to find exactly how I should go about reading the message posted in the com port buffer by Arduino when all I asked for is A/D voltage on analog pin 4.
Any Ideas?
OPEN "Com3:9600,n,8,1,ds0,cs0,rs" FOR RANDOM AS #1
_DELAY .5 '                                       Delay to let Com Port settle
FIELD #1, 50 AS m$

t1 = TIMER '                                     Start time for getdata

getdata:
bytes% = LOC(1) '                             Check receive buffer for data
IF bytes% = 0 THEN GOTO getdata '         After thousands of getdata cycles it continues
PRINT "Bytes="; bytes '                            Bytes remain at 0
DO UNTIL EOF(1)
    GET #1, , m$ '                             BAD RECORD LENGTH ERROR
    PRINT "LEN(m$)= "; LEN(m$) '               Length of m$ = 10
    IF INSTR(m$, "*") > 0 THEN GOTO duh '    Never finds End of Message (*)
LOOP

IF bytes% = 0 THEN GOTO getdata
t2 = TIMER '                                         End time, Have data
DeltaT = t2 - t1 '                                   How long did it take?
GOTO stepover

duh:
PRINT "DUH instr= "; INSTR(m$, "*") '               Never hits this line
stepover:

tmp$ = "DeltaT= #.### Seconds Until LOC(1) > 0" '    Various times arround 0.66 Sec
PRINT USING tmp$; DeltaT
PRINT "m$ Received= "; m$ + "&" '                 Prints 10 spaces No Data
PRINT "endofdata= "; endofdata '                  endofdata=0, Never got "*"
PRINT "ctr= "; ctr, CHR$(13) '            Show number of times you pressed continue
CLOSE #1

Arduino Code sending info is the following:

 if ( cmd == 2)//getanalog
   {
        int sensorValue = analogRead(pin);//
        delay(10);
        float voltage= sensorValue*(5.0/1023.0);
        Serial.print("Voltage =");
        Serial.print(voltage);
        Serial.print(",");
        Serial.print("*");

The asterisk should be in the buffer indicating the end of my message.
 

 7 
 on: August 30, 2017, 10:22:34 am 
Started by QB513 - Last post by Dimster
I am new to this website, please consider this reply as me just exploring the site and trying out things to do. I'm sure QB513 has figured out this problem or abandoned coding altogether by now. If QB513 is familiar with Arrays and the Dim function, one way the problem could be solved is to dimension an array to hold each day's pay - so Dim Pay(30). You would then create a for/next loop . for P = 1 to 30. Within the loop you will need a line of code to do the math, ie take a the last day's pay and double it. Then store that value in Pay(P). (Note:Whatever variable you are using for the "last day's pay" should be made equal to "0" before the for/next loop. After the looping has ended you will need another for/next loop to calculate the total of all the values stored in Pay(30). As for the Printed Report, Yash has given a very good hint. The "?" is a shorter way to code the command word "Print" and the use of "Locate" for your columns and rows is the way to go. You simple need to print what you have stored in your Arrays and the Variable you have storing the total amount paid.

Seems there is quite a bid of room for these replies. The Preview shows only one line at a time but that's cool, it does pick up the Bolding and Italic and color.

 8 
 on: August 29, 2017, 03:08:33 pm 
Started by Dimster - Last post by Dimster
Trying to code a drop down menu in QB64. I am new to QB64 and understand the concept of drawing a line/box, erase and redraw I'm lost on coordinating the color fill of the box with the menu items that i want to appear in the various drop down boxes. Are there some sample codes in some of the QB64 commands that i could read up on and play with or some site/book that may give me some ideas on Drop Down Menu's. Thanks

 9 
 on: July 31, 2017, 12:03:04 pm 
Started by Mal-2 - Last post by Mal-2
I am having a problem with mouse input. Clicks go through and get processed correctly, but if the mouse is moved even one pixel while the button is down, then it registers as a second click. If the motion goes even further than one pixel, it fires off a new click for every pixel moved! How can I make QB64 ignore mouse drags and treat them as merely a click at the initial position? [Answer: run a loop that polls mouse info until the button is released. Place it after whatever loop was waiting for the original click. Very hacky, but apparently necessary.]

Also, is there a way to make sound files play in stereo? They get downmixed to mono now. [Confirmed to be a qb64 bug introduced when the underlying codebase was moved from SDL to GL. Version 0.954 does not have the problem but sticking with an old, unsupported build is not a viable option.]

 10 
 on: March 11, 2017, 04:43:12 pm 
Started by WB Brown - Last post by WB Brown
10 REM PRIME/FACTORS
20 REM William B. Brown
30 REM 223 Harper Ridge Place
40 REM Antioch, TN 37013-3722
50 REM (573) 552-6822
60 REM COPYRIGHT July 1996, March 2017 by William B. Brown.
63 REM This program CANNOT be sold for any purpose without the
64 REM express written purpose of the author.
70 S$ = "ONLY WHOLE NUMBERS GREATER THAN ZERO"
80 E$ = "END NUMBER MUST BE EQUAL TO OR GREATER THAN THE START NUMBER"
90 CLS: PRINT: PRINT: PRINT "                               PRIMES AND FACTORS":
91 PRINT: PRINT "              COPYRIGHT July 1996, March 2017 by William B. Brown.":
92 PRINT "        This program CANNOT be sold for any purpose without the EXPRESS";
93 PRINT "                       written permission of the author.";
94 PRINT "                              All rights reserved.":
95 REM MAIN MENU
100 PRINT: PRINT "  (1) FIND THE PRIME FACTORS OF ONE NUMBER"
120 PRINT: PRINT "  (2) FIND THE PRIME FACTORS OF A RANGE OF NUMBERS"
140 PRINT: PRINT "  (3) TEST ONE NUMBER FOR PRIME"
150 PRINT: PRINT "  (4) FIND THE PRIMES IN A RANGE OF NUMBERS"
170 PRINT: PRINT "  (5) QUIT THE PROGRAM"
180 PRINT: PRINT: INPUT "TYPE THE NUMBER OF YOUR SELECTION"; Q
190 ON Q GOTO 810, 210, 960, 360, 1150
200 GOTO 90
205 REM FACTORS OF A RANGE OF NUMBERS
210 CLS: PRINT: PRINT: PRINT: PRINT "FIND THE FACTORS OF A RANGE OF NUMBERS"
220 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN  P  FOR PRINTER "; T$
230 IF T$ = "S" OR T$ = "s" THEN PS = 0: GOTO 260
240 IF T$ = "P" OR T$ = "p" THEN PS = 1: GOTO 310
250 GOTO 210
260 GOSUB 550
270 CLS: PRINT: PRINT: PRINT: PRINT "FINDING ALL FACTORS OF THE NUMBERS BETWEEN"; SN; "AND"; EN; ".": PRINT: PRINT
290 GOSUB 610
300 PRINT "FINISHED": GOTO 770
310 GOSUB 550
330 LPRINT "FACTORS OF THE NUMBERS BETWEEN "; SN; " AND "; EN: LPRINT
335 PRINT "FACTORS OF THE NUMBERS BETWEEN "; SN; " AND "; EN: PRINT
340 GOSUB 1300
350 LPRINT: LPRINT "FINISHED": PRINT: PRINT "FINISHED": GOTO 770
355 REM TEST A RANGE OF NUMBERS FOR PRIMES
360 CLS: PRINT: PRINT: PRINT: PRINT "FIND THE PRIMES IN A RANGE OF NUMBERS"
370 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN  P FOR PRINTER "; T$
380 IF T$ = "S" OR T$ = "s" THEN SP = 0: GOTO 410
390 IF T$ = "P" OR T$ = "p" THEN SP = 1: GOTO 460
400 GOTO 360
410 GOSUB 550
420 CLS: PRINT: PRINT: PRINT: PRINT "FINDING ALL PRIME NUMBERS BETWEEN"; SN; "AND"; EN; ".": PRINT: PRINT
440 GOSUB 700
450 PRINT: GOTO 770
460 GOSUB 550
480 LPRINT "ALL THE PRIME NUMBERS BETWEEN "; SN; " AND "; EN: LPRINT
485 PRINT "ALL THE PRIME NUMBERS BETWEEN "; SN; " AND "; EN: PRINT
490 GOSUB 700
500 LPRINT: LPRINT: LPRINT "FINISHED": PRINT: PRINT: PRINT "FINISHED": GOTO 770
510 IF FP <> 2 THEN PRINT FP; "*";: N = N / FP: RETURN
520 N = N / FP: IF N / FP = INT(N / FP) THEN PRINT FP; "*";: RETURN
530 IF N <> FP AND N <> 1 THEN PRINT FP; "*";: RETURN
540 PRINT FP;: RETURN
545 REM RANGE OF NUMBERS ENTRY
550 PRINT: PRINT: PRINT: INPUT "ENTER START NUMBER"; SN: N1 = SN
560 IF SN < 1 OR INT(SN) <> SN THEN PRINT: PRINT S$: GOTO 550
570 PRINT: PRINT: PRINT: INPUT "ENTER ENDING NUMBER (< 10,000,000)"; EN
580 IF EN < 1 OR INT(EN) <> EN THEN PRINT: PRINT S$: GOTO 570
590 IF EN < SN THEN: PRINT: PRINT E$: GOTO 550
600 R = SN: RETURN
605 REM FACTOR FINDER-SCREEN
610 N = R: N1 = N: Z = 0
620 FOR FP = 2 TO SQR(N)
    630 IF N / FP = INT(N / FP) THEN GOSUB 510: Z = 1: GOTO 620
650 NEXT: IF N <> 1 THEN PRINT N; "="; N1: GOTO 670
660 PRINT N; "="; N1
670 R = R + 1: IF R > EN THEN RETURN
680 GOTO 610
695 REM PRIME FINDER
700 N = R: N1 = N: IF N = 2 THEN GOTO 740
705 IF N = 1 THEN X = 1: NN = 1: GOTO 740
710 FOR FP = 2 TO SQR(N)
    720 IF N / FP = INT(N / FP) THEN X = 1: GOTO 750
730 NEXT
740 IF N <> 1 THEN GOSUB 1200: GOTO 750
750 R = R + 1: IF R > EN THEN RETURN
760 GOTO 700
765 REM END OF OPTION SELECT
770 PRINT: PRINT: INPUT "TYPE Q TO QUIT OR M TO RETURN TO THE MAIN MENU"; Y$
780 IF Y$ = "Q" OR Y$ = "q" THEN 1150
790 IF Y$ = "M" OR Y$ = "m" THEN 90
800 Y$ = "": PRINT: GOTO 770
805 REM FACTORS OF ONE NUMBER
810 CLS: PRINT: PRINT: PRINT "FIND THE FACTORS OF A NUMBER"
820 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN OR P FOR PRINTER"; T$
830 IF T$ = "S" OR T$ = "s" THEN GOTO 860
840 IF T$ = "P" OR T$ = "p" THEN GOTO 910
850 GOTO 810
860 GOSUB 1120
870 CLS: PRINT: PRINT: PRINT: PRINT "FINDING THE FACTORS OF THE NUMBER"
880 PRINT NN
890 GOSUB 610
900 PRINT: PRINT "FINISHED": GOTO 770
910 GOSUB 1120
920 LPRINT "FACTORS OF THE NUMBER"; NN: LPRINT
925 PRINT "FACTORS OF THE NUMBER"; NN: PRINT
940 GOSUB 1300
950 LPRINT: LPRINT "FINISHED": PRINT: PRINT "FINISHED": GOTO 770
960 CLS: PRINT: PRINT: PRINT: PRINT "TEST A NUMBER FOR PRIME": X = 0
970 PRINT: PRINT: PRINT: INPUT "TYPE S FOR SCREEN OR P FOR PRINTER"; T$
980 IF T$ = "S" OR T$ = "s" THEN GOTO 1010
990 IF T$ = "P" OR T$ = "p" THEN GOTO 1060
1000 GOTO 960
1010 GOSUB 1120
1020 CLS: PRINT: PRINT: PRINT "TESTING THE NUMBER"; NN; "FOR PRIME": PRINT: PRINT
1030 GOSUB 700: IF X <> 0 THEN PRINT NN; "NOT PRIME": GOTO 1050
1040 PRINT "IS PRIME"
1050 PRINT: R = NN: GOSUB 610: GOTO 770
1060 GOSUB 1120
1070 LPRINT "TESTING NUMBER"; NN; "FOR PRIME": LPRINT
1075 PRINT "TESTING NUMBER"; NN; "FOR PRIME": PRINT
1090 GOSUB 700: IF X <> 0 THEN LPRINT NN; "NOT PRIME": IF X <> 0 THEN PRINT NN; "NOT PRIME": GOTO 1110
1100 LPRINT NN; "IS PRIME": PRINT NN; "IS PRIME"
1110 LPRINT: LPRINT: LPRINT "FINISHED": PRINT: PRINT: PRINT "FINISHED": GOTO 770
1115 REM SINGLE NUMBER ENTRY
1120 PRINT: PRINT: PRINT: INPUT "ENTER NUMBER (< 10,000,000)"; NN: N1 = NN
1130 IF NN < 1 OR INT(NN) <> NN THEN PRINT: PRINT S$: GOTO 1120
1140 R = NN: EN = NN: RETURN
1150 CLS: PRINT: PRINT: PRINT: PRINT "THANK YOU FOR USING FACTOR/PRIME FINDER":
1151 PRINT: PRINT " (C) JULY 1996, MARCH 2017 By William B. Brown":
1152 PRINT " WBBROWN11@GMAIL.COM":
1154 PRINT "        This program CANNOT be sold for any purpose without the EXPRESS";
1155 PRINT "                       written permission of the author.";
1156 PRINT "                              All rights reserved.": END
1200 IF SP = 0 THEN PRINT N; " ";: RETURN
1210 LPRINT N; " ";: PRINT N; " ";: RETURN
1295 REM FACTOR FINDER-PRINTER
1300 N = R: N1 = N: Z = 0
1320 FOR FP = 2 TO SQR(N)
    1330 IF N / FP = INT(N / FP) THEN GOSUB 1510: Z = 1: GOTO 1320
1350 NEXT: IF N <> 1 THEN LPRINT N; "="; N1: PRINT N; "="; N1: GOTO 1370
1360 LPRINT N; "="; N1: PRINT N; "="; N1
1370 R = R + 1: IF R > EN THEN RETURN
1380 GOTO 1300
1510 IF FP <> 2 THEN LPRINT FP; "*";: IF FP <> 2 THEN PRINT FP; "*";: N = N / FP: RETURN
1520 N = N / FP: IF N / FP = INT(N / FP) THEN LPRINT FP; "*";: IF N / FP = INT(N / FP) THEN PRINT FP; "*";: RETURN
1530 IF N <> FP AND N <> 1 THEN LPRINT FP; "*";: IF N <> FP AND N <> 1 THEN PRINT FP; "*";: RETURN
1540 LPRINT FP;: PRINT FP;: RETURN















Pages: [1] 2 3 ... 10
Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy