QBasic and QB64 Discussion Board

[QB Forum Archives (1999-2009)/ ] [QB FAQ] [QB Links and Downloads] [Subforums and Chat Room] [Search]

QB64.Net Homepage   QB/QB64 Keywords   QB Graphics Forum   Homework Policy



Graphics Demo

by asdf (no login)

SCREEN 12

DIM z(0 TO 7)

FOR i = 0 TO 7
READ z(i)
NEXT

DATA 9,2,13,4,5,12,1,10

FOR Y = 0 TO 6
FOR X = 0 TO 8
a = 81 * X - 4: b = 81 * Y - 3
c = 2 * ((X + Y) MOD 2) - 1: r = 56.57
FOR t = 0 TO 3.14 STEP .075
xx = r * COS(t * c + .7854)
yy = r * SIN(t * c + .7854)
r = .91 * r
PSET (a + xx + dxc, b + yy + dyc)
COLOR (z(c + 1)): LINE STEP(0, 0)-(a - yy + dxc, b + xx + dyc)
COLOR (z(c + 2)): LINE STEP(0, 0)-(a - xx + dxc, b - yy + dyc)
COLOR (z(c + 5)): LINE STEP(0, 0)-(a + yy + dxc, b - xx + dyc)
COLOR (z(c + 6)): LINE STEP(0, 0)-(a + xx + dxc, b + yy + dyc)
NEXT
NEXT
NEXT

Posted on Aug 27, 2014, 3:14 PM

Respond to this message   

Return to Index


*Wow, that's gorgeous--nice job!

by TheBOB (Login qb432l)
R

*

Posted on Aug 27, 2014, 5:36 PM

Respond to this message   

Return to Index


Calculation

by Afolorunshor (no login)

Wrie a prog. To calc a daily sales of a shop??? Pls its urgent

Posted on Aug 19, 2014, 8:53 AM

Respond to this message   

Return to Index


Insane?

by JT (no login)

in·san·i·ty
inˈsanitē/Submit
noun
the state of being seriously mentally ill; madness.
"he suffered from bouts of insanity"
synonyms: mental illness, madness, dementia; More
extreme foolishness or irrationality.
plural noun: insanities
"it might be pure insanity to take this loan"
synonyms: folly, foolishness, madness, idiocy, stupidity, lunacy, silliness; informalcraziness
"it would be insanity to take this loan"

Posted on Aug 19, 2014, 1:35 PM

Respond to this message   

Return to Index


Are you commissioning someone to write a program for you?

by Solitaire (Login Solitaire1)
S

Are you running a business? If so, the going rate is $500 an hour.

Are you a student with a homework problem? If so DO YOUR OWN WORK, and see the link above for the homework policy.

Is it urgent because you were too lazy to start the assignment earlier? Does your grade depend on it? You must show that you are making an effort. You get what you deserve.

Are you completely clueless? Just try writing the program yourself, and post the part of the code that you couldn't get to work. Then maybe someone will be able to help you.

Posted on Aug 19, 2014, 2:36 PM

Respond to this message   

Return to Index


Re: Calculation

by Michael Calkins (Login MCalkins)
Moderator

Assuming that you need business software:

I'd suggest trying to find or buy pre-existing software, before commissioning new software.

If you really do need custom software:

You might try websites like freelancer.com or possibly craigslist.

You will need to be a lot more detailed and specific about what you need the software to do.

I think most of the programmers that hang out here are hobbyists. There's a chance that you might find someone here willing to work in a hurry for money, but your chances are probably better on something like freelancer.com.

Regards,
Michael

Posted on Aug 21, 2014, 5:58 AM

Respond to this message   

Return to Index


Wrie a prog? Homework? Try praying * * *

by Clippy (Login burger2227)
R

Can't even type WRITE A PROGRAM? What's the hurry?

[linked image]

Posted on Aug 21, 2014, 8:42 AM

Respond to this message   

Return to Index


Attention all seasoned QBasic programmers

by AlGoreIthm (no login)


let's spice up this discussion board and see who wants to play ...

As a seasoned QBasic programmer, what type of program might really impress you,
considering it was written in QBasic??

Should be interesting ...

Posted on Aug 14, 2014, 6:15 PM

Respond to this message   

Return to Index


This TYPE of program

by SeasonedQBASICprogrammer (no login)

http://www.pcworld.com/article/2033318/black-annex-is-the-best-qbasic-game-youve-ever-seen.html

Posted on Aug 14, 2014, 7:32 PM

Respond to this message   

Return to Index


cant get speechmark character to work!

by Julian (no login)

I am using a macbook pro late 2011
QB64 working ok but just cant get this character to work (all others do)

Posted on Aug 5, 2014, 6:28 AM

Respond to this message   

Return to Index


Re: cant get speechmark character to work!

by Michael Calkins (Login MCalkins)
Moderator

A google search for speechmark character suggests quotation mark.

If you mean a quotation mark, try:

PRINT CHR$(&H22)

Regards,
Michael

Posted on Aug 6, 2014, 8:36 PM

Respond to this message   

Return to Index


Quotation characters denote the ends of strings so use CHR$(34)

by Clippy (Login burger2227)
R

Add it to a string or use semicolons if other parts are quoted string values.

PRINT CHR$(34); "Hello world"; CHR$(34)

[linked image]

Posted on Aug 9, 2014, 2:05 PM

Respond to this message   

Return to Index


help

by new basic (no login)

what i am doing wrong in my program?

Posted on Aug 1, 2014, 1:52 PM

Respond to this message   

Return to Index


* What program? Please continue posting to the thread you started.

by Solitaire (Login Solitaire1)
S

Posted on Aug 1, 2014, 5:14 PM

Respond to this message   

Return to Index


calculation

by basicstudent (no login)

can someone please help me about my program

Posted on Aug 1, 2014, 11:39 AM

Respond to this message   

Return to Index


Please do not start a new thread about the same problem.

by Solitaire (Login Solitaire1)
S

Just respond to the last post in the relevant thread.

Posted on Aug 1, 2014, 5:13 PM

Respond to this message   

Return to Index


single dimension arrays

by new basic (no login)

The following is a list of salaries of the six employees in a certain company:

Name Salary
T. Angel $43,000
F. Smith $31,000
K. Johnston $22,000
P. Miner $18,000
C. Altman $27,000
A. Lu $19,000

Read a single dimension array for name and another array for Salary. Calculate and output the average salary for the company as well as the names of all people whose salaries exceed the average.


would this be how to write the program,

DIM EmployeeNam(1 TO 16), Salary(1 TO 6)

GOSUB InitializeVariables
GOSUB LoadTables
CLS
GOSUB PrintDetail
GOSUB PrintSubtotals
GOSUB PrintTotals
END

InitializeVariables:
LET PageCt = 0
LET Salary = 0
LET T1$ = " Salary for employees ##"
LET H1$ = ""
LET H2$ = " Name Salary "
LET D1$ = " / $###.## "
LET ST$ = " SUBTOTAL #"
LET TL$ = " TOTAL #"
LET MaxLines = 30
RETURN

'******************************
' Read numbers into the array
' *****************************


LoadTables:
FOR N = 1 TO 6
READ EmployeeNam(N), Salary(N)
LET AvgSalary = Salary + Salary(N)
NEXT N


DATA T. Angel, 43,000
DATA F. Smith, 31,000
DATA K. Johnston,22,000
DATA P. Miner, 18,000
DATA C. Altman, 27,000
DATA A. Lu, 19,000
DATA 0,0,0
DATA END
RETURN


PrintDetail:
PRINT H2$
FOR N = 1 TO 14
PRINT USING D1$; EmployeeNam(N); Salary(N); 'Print details
NEXT N
RETURN

PrintSubtotals:
LET AvgIncome = Salary / 6 'Calc average income
RETURN

PrintTotals:
PRINT USING "$##,###.## "; AvgSalary; "is the average Salary"
GOSUB PrintAboveAverage
RETURN

PrintAboveAverage:
PRINT H2$
FOR N = 1 TO 6
IF Salary(N) > AvgSalary THEN
PRINT USING D1$; EmployeeNam(N); Salary(N)
END IF
NEXT N
RETURN

Posted on Aug 1, 2014, 11:05 AM

Respond to this message   

Return to Index


Some hints

by Solitaire (Login Solitaire1)
S

Dim each array separately. They should both be the same size, since the array index of the name is related to the array index of the salary. The name array should be a string. Each name in the DATA list should be enclosed within quotation marks, since they are strings. Also, do not use commas inside of a number.

DIM EmployeeNam$(1 TO 6)
DIM Salary(1 TO 6)

DATA "T. Angel", 43000
etc.

To get the average salary, use a FOR loop from 1 to 6 and accumulate the salary array values assigned to a variable for the total. Then divide the total by 6 to get the average.


Posted on Aug 1, 2014, 5:30 PM

Respond to this message   

Return to Index


* a C++ example (URL)

by Michael Calkins (Login MCalkins)
Moderator

http://www.network54.com/Forum/613583/message/1406976159/example

Posted on Aug 2, 2014, 4:49 AM

Respond to this message   

Return to Index


DATA keyword delimiters

by JT (no login)

You are using READ and DATA keywords.
You should know that the data after a data statement has some value after it with COMMAS
between the items. So what if a comma is PART of the data? Like this

DATA T. Angel, 43,000

Without some kind of way to tell the interpreter, it wont know you meant "43,000" was the whole data item and not "43" and then "000"

Code your data statements without commas in the data if you can.

One way to fix what you have is to remove the commas from the numbers. Computers don't know what something like 43,000 is anyway, it likes 43000. Also, for the names I'd use "s to show where the data starts and ends. Try this.

DATA "T. Angel", 43000

Your program wont work the way its written there.

JT

Posted on Aug 4, 2014, 12:08 PM

Respond to this message   

Return to Index


Issues with DIM, DATA

by JT (no login)

I see more issues with your code.

Your DIM statement:
DIM EmployeeNam(1 TO 16), Salary(1 TO 6)

This wont work in QB64. You have not declared the type of data in the array. I don't think you can put a comma between them like that either.

In QB64 type DIM and position the cursor over it and press F1 to see the syntax QB64 uses.

I would code it like this.

DIM SHARED emp.name(1 TO 6) AS STRING
DIM SHARED emp.salary(1 TO 6) AS LONG

Long is a data type that is bigger than INTEGER. It has a range that should work well for this.

"Qbasic LONG Integer values can be from -2147483648 to 2147483647"

Also, in your loadtables sub, you seem to use trailer data in the data statements that you don't even use.

If you use a for loop with READ in it that loops six times it will only look at the first six data statements. Nothing wrong with that, but that method doesn't require any trailer data.

If you want to use trailer data, you have to follow the format of data as it is stored.

You have the form of string, long, string, etc so the trailer data should look like

DATA "*end of data*", 0

and then use a do loop with a test of until emp.name = "*end of data*" in it.

This looks like someones homework assignment (??) but if you intend to use this all the time you know hard coding the number of employees to six is not practical. And putting the data into a seperate data file seems more logical as well. (I realize the focus here was on learning single demention arrays) Maybe you just wanted to focus on the learning how arrays work aspect. If so ,then ignore this paragraph.

Good luck.

JT

Posted on Aug 4, 2014, 12:27 PM

Respond to this message   

Return to Index


calculation

by basicstudent (no login)

Salespeople at XYZ Company are paid a base salary of $10,000. This salary may
be augmented by commissions, which are equal to 10 percent of gross sales, and by a bonus of $500. The bonus is awarded only to salespeople with more than $80,000 in gross sales. Compute and output the amounts earned by each of these salespeople:

I have to create a program for this... I cannot figure out a proper formula to get this to work.

'****************************************************************************
'* THIS PROGRAM IS TO CALCULATE EACH SALES PERSON'S EARNINGS *
'****************************************************************************
' VARIABLES USED:
' T1$, H1$, D1$, TL$ Print Images
' NAM$ Name
' GROSS SALES Gross Sales Earned
' TOTAL SALES Total Sales Earned
' TOTSALARY Total Salary Combined

'*************************** PROGRAM VARIABLES *****************************
CLS
GOSUB InitializeVariables
GOSUB PrintHeadings
GOSUB ProcessDetail
GOSUB CalculateAnswer
GOSUB PrintTotals
END
'***************************** INITIALIZE VARIABLES *************************

InitializeVariables:
LET T1$ = " EARNED SALARIES "
LET H1$ = " SALES REP GROSS SALES TOTAL SALARY "
LET D1$ = " ###,###.## ###,###.## "
LET TL$ = " TOTAL ###,###.## ###,###.## "
'**************************** PRINT HEADINGS ********************************
PrintHeadings:
PRINT
PRINT
PRINT T1$ 'PRINT TITLE LINE
PRINT
PRINT H1$ 'HEADING LINE
PRINT
PRINT
RETURN
'*************************** PROCESS DETAIL *********************************
ProcessDetail:
GOSUB ReadData
DO UNTIL UCASE$(NAM$) = "END"
GOSUB CalculateAnswer
GOSUB PrintDetail
GOSUB ReadData
LOOP
RETURN
'******************************* READ DATA ***********************************
ReadData:
READ NAM$, GrossSales, TotalSalary
DATA Carlos Ortiz,90000,00
DATA Jill Johnson,70000,00
DATA Don Williams,20000,00
DATA Dee Jones,95000,00
DATA Al Ennis,40000,00
DATA End,0,0
RETURN
'******************************* CALCULATE ANSWER ****************************
CalculateAnswer:
IF GrossSales > 80000 THEN
LET TotSalary = (GrossSales * .01) + 500
ELSE
LET TotSalary = (GrossSales * .01) + 10000
END IF
'******************************* PRINT DETAIL ********************************
PrintDetail:
PRINT USING D1$; NAM$, GrossSales, TotalSales
RETURN
'******************************* PRINT TOTALS *********************************
PrintTotals:
PRINT
PRINT USING TL$; GrossSales
PRINT
PRINT
RETURN
'****************************** END OF PROGRAM ***********************************

Posted on Aug 1, 2014, 9:58 AM

Respond to this message   

Return to Index


Re: calculation

by Pete (Login The-Universe)
Admin

CalculateAnswer:
IF GrossSales > 80000 THEN
LET TotSalary = (GrossSales * .01) + 500
ELSE
LET TotSalary = (GrossSales * .01) + 10000
END IF

.01 is one-percent, not ten-percent. 10-percent is represented as .1

(GrossSales * .1) gives a 10% bonus, but you still have to add back in the gross sales: GrossSales + (GrossSales * .1)

That 10000 needs to go.

Think of is as you make 100 in gross sales. 10% of that is $10, so you get $110 check. That's gross sales + (gross sales * .1) to get that total. If you got a bonus of $5 for making over $90, you simply add that $5 amount to the above equation. The IF/THEN statement you made will do that, with that + 500 in it, but you still have to add back in that GrossSales variable, not just calculate the 10% bonus.

Pete

Posted on Aug 1, 2014, 1:06 PM

Respond to this message   

Return to Index


Will not calculate

by Bware (no login)

I have written 2 programs, 1 to create a sequential data file and the second program is to read the data and calculate the commissions. It looks like everything is going well except that the commissions are being calculated. Please help!

My Programs-

Prog #1:

REM*****THIS PROGRAM IS DESIGNED TO CREATE A SEQUENTIAL DATA FILE******

REM*******************PROGRAM VARIABLES****************
REM SPERSONNUM$ SALES PERSON'S NUMBER
REM NAM$ NAME
REM COMMR$ COMMISSION RATE
REM SALAMT$ AMOUNT OFSALARIES

REM *******************MAIN MODULE*********************

GOSUB OpenFile
GOSUB CreateFile
GOSUB CloseFile
PRINT
PRINT " END OF PROGRAM "
END

REM ********************OPEN FILE***********************
OpenFile:
OPEN "SALEDATA.DAT" FOR OUTPUT AS #1
RETURN
REM *******************CREATE FILE**********************
CreateFile:
GOSUB InputSalesmanNum
DO UNTIL SPERSONNUM = 0
GOSUB InputSalesData
GOSUB PrintReport
GOSUB WriteRecord
GOSUB InputSalesmanNum
LOOP
RETURN
REM *********INPUT SALESMAN NUMBER*********************
InputSalesmanNum:
CLS
LOCATE 9, 14
PRINT "ENTER SALESMAN NUMBER";
INPUT "(ENTER 0 TO END)", SPERSONNUM
RETURN
REM *************SALES DATA******************************
InputSalesData:
LOCATE 11, 14
INPUT " SALESMAN NAME ", NAM$
LOCATE 13, 14
INPUT "ENTER SALE AMOUNT ", SALAMT
LOCATE 15, 14
INPUT "ENTER COMMISSION RATE ", COMMR
RETURN

' ************ Print The Report ***************

PrintReport:
DO UNTIL SalesNum = 0
Comm = SALEAMT * (COMMRT / 100)
INPUT #1, SalesNum, NAM$, SaleAmt, CommRt
PRINT #1, USING D$; SalesNum; NAM$; SaleAmt; CommRt; Comm
LOOP
RETURN

REM *****************WRITE RECORD TO DISK****************
WriteRecord:
WRITE #1, SPERSONNUM, NAM$, SALAMT, COMMR
RETURN
REM *****************CLOSE FILE***********************
CloseFile:
CLOSE #1
RETURN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Prog #2:

REM*****THIS PROGRAM IS DESIGNED TO READ file and calculate commissions******

REM*******************PROGRAM VARIABLES****************
REM SPERSONNUM$ SALES PERSON'S NUMBER
REM NAM$ NAME
REM COMMR$ COMMISSION RATE
REM SALAMT$ AMOUNT OFSALARIES
REM COMM$ COMMISSION
REM *******************MAIN MODULE*********************
CLS
GOSUB OpenFile
GOSUB PrintReport
GOSUB CloseFile
END

'********************OPEN FILE***********************
OpenFile:
OPEN "SALEDATA.DAT" FOR INPUT AS #1
RETURN

'*****Read Data ********
PrintReport:
INPUT #1, SalesNum, NAM$, SaleAmt, CommRt
DO UNTIL EOF(1)
PRINT SalesNum; NAM$; SaleAmt; CommRt, Comm
INPUT #1, SalesNum, NAM$, SaleAmt, CommRt
LOOP
RETURN

'*****************CLOSE FILE***********************
CloseFile:
CLOSE #1
RETURN
'************* End of Program**********************

Posted on Jul 31, 2014, 9:46 PM

Respond to this message   

Return to Index


Your variable is mistyped

by JT (no login)

The first program, the sub called write record

WriteRecord:
WRITE #1, SPERSONNUM, NAM$, SALAMT, COMMR
RETURN

The last variable called COMMR, there is no var called that.

In your sub printreport:

PrintReport:
DO UNTIL SalesNum = 0
Comm = SALEAMT * (COMMRT / 100)
INPUT #1, SalesNum, NAM$, SaleAmt, CommRt
PRINT #1, USING D$; SalesNum; NAM$; SaleAmt; CommRt; Comm
LOOP
RETURN

One is called Comm. Looks like a typo. Fix the name and it should be ok.

Posted on Aug 1, 2014, 7:31 AM

Respond to this message   

Return to Index


I goofed

by JT (no login)

Sorry, I see now that you did have a variable named COMMR

You said the problem was
"It looks like everything is going well except that the commissions are being calculated."

OK? That is not too clear.

Any program issue can be solved the same way it is written. A little at a time.
You have many subroutines that seem to be short and concise. Look each one over one at a time and ask yourself if each one is working then go to the next. Use stop/end/pause statements and some temporary print statements to see the status of each part. You'll find the issue that way. It just takes time.

JT

Posted on Aug 4, 2014, 11:59 AM

Respond to this message   

Return to Index


Can't Complete

by BWare (no login)

I wrote a program that works well up until I get to the last two steps. This is what I'm trying to accomplish, Use read data to read an array of ten numbers. Then do the following each in a separate subroutine:

1. Print all the numbers you just read.

2. Print the numbers in reverse order

3. Add the first and the last number

4. Do the total of all the numbers.

My Program:

gosub readdata
gosub printlist
gosub printlistreversed
gosub addnumbers
gosub totalnumbers

'****** read data file ******
readdata:
FOR INDEX = 1 TO 10
READ NUM(Index)
NEXT INDEX
DATA 10,12,34,45,43,56,67,87,65,90
RETURN

'****** Print number list ******
printlist:
FOR INDEX = 1 TO 10
PRINT NUM(INDEX)
NEXT INDEX
RETURN

'****** Print Reversed List ******
printlistreversed:
FOR INDEX = 10 TO 1 STEP -1
PRINT NUM(INDEX)
NEXT INDEX
RETURN

'****** Add first and last numbers ******
addnumbers:
FOR INDEX = 1 TO 10
ans = ans + 10
PRINT ans(INDEX)
NEXT INDEX

'****** Total numbers ******
totalnumbers:
FOR INDEX = 1 TO 10
Total = Total + NUM(INDEX)
NEXT INDEX
RETURN

Thanks,
BWare

Posted on Jul 28, 2014, 8:23 PM

Respond to this message   

Return to Index


Re: Can't Complete

by a (no login)

The sum of the FIRST and the LAST number is just num(1) + num(10)

You forgot to print Total after you calculated it. Put PRINT total between NEXT and RETURN.

Posted on Jul 28, 2014, 11:21 PM

Respond to this message   

Return to Index


Create sequential data file

by basicstudent (no login)

I am not sure why my program is not running correctly. This is the question: Write two programs: one to create a sequential data file, and the second to read the file and calculate commission amounts.

Input: Input from the keyboard the salesperson's number, name, commission rate, and amount of sales.

Output: Create a sequential file that contains all input data.

Program 2

Input: Theinput data will be the sequential file created in the first program. Input fields are the salesperson's number, name, commission rate, and amount of sales.
Output: Print a report with a title and column headings. One detail line will be printed for each salesperson (each input record). The fields on the detail line are to be the salesperson's number, name, sales amount, commission rate, and amount of sales.


Output: Print a report with a title and column headings. One detail line will be printed for each salesperson (each input record). The fields on the detail line are to be the salesperson's number, name, sales amount, commission rate, and commission amount.

Calculations: Compute the commission amount as the sales amount multiplied by the commission rate.

REM*****THIS PROGRAM IS DESIGNED TO CERATE A SEQUENTIAL DATA FILE******

REM*******************PROGRAM VARIABLES****************
REM SPERSONNUM$ SALES PERSON'S NUMBER
REM NAM$ NAME
REM COMMR$ COMMISSION RATE
REM SALAMT$ AMOUNT OFSALARIES

REM *******************MAIN MODULE*********************

GOSUB OpenFile
GOSUB CreateFile
GOSUB CloseFile
PRINT
PRINT " END OF PROGRAM "
END

REM ********************OPEN FILE***********************
OpenFile:
OPEN "SALEDATA.DAT" FOR OUTPUT AS #1
RETURN
REM *******************CREATE FILE**********************
CreateFile:
GOSUB InputSalesmanNum
DO UNTIL SPERSONNUM = 0
GOSUB InputSalesData
GOSUB WriteRecord
GOSUB InputSalesmanNum
LOOP
RETURN
REM *********INPUT SALESMAN NUMBER*********************
InputSalesmanNum:
CLS
LOCATE 9, 14
PRINT "ENTER SALESMAN NUMBER";
INPUT "(ENTER 0 TO END)", SPERSONNUM
RETURN
REM *************SALES DATA******************************
InputSalesData:
LOCATE 11, 14
INPUT " SALESMAN NAME ", NAM$
LOCATE 13, 14
INPUT "ENTER SALE AMOUNT ", SALAMT
LOCATE 15, 14
INPUT "ENTER COMMISSION RATE ", COMMR
RETURN

' ************ Print The Report ***************

PrintReport:
DO UNTIL SalesNum = 0
LET Comm = SaleAmt * (CommRt / 100)
PRINT #1, USING D$; SalesNum; NAM$; SaleAmt; CommRt; Comm
INPUT #1, SalesNum, NAM$, SaleAmt, CommRt
LOOP
RETURN

RETURN
REM *****************WRITE RECORD TO DISK****************
WriteRecord:
WRITE #1, SPERSONNUM, NAM$, SALAMT, COMMR
RETURN
REM *****************CLOSE FILE***********************
CloseFile:
CLOSE #1
RETURN

Posted on Jul 26, 2014, 9:34 PM

Respond to this message   

Return to Index


Re: Create sequential data file

by Pete (Login The-Universe)
Admin

You need to include the PrintReport as part of your main program. Right now, it isn't being called at all.

I switched your order in the PrintReport. You have to INPUT first, then print, Also, you are printing to the screen, not the file again, which wouldn't work anyway, as the file is open for input, not read and write, and it is sequential, not binary.


PrintReport:
DO UNTIL SalesNum = 0
LET Comm = SaleAmt * (CommRt / 100)
INPUT #1, SalesNum, NAM$, SaleAmt, CommRt
PRINT USING D$; SalesNum; NAM$; SaleAmt; CommRt; Comm
LOOP
RETURN

-----------------------

Anyway, just some casual observations, I did not try to run the code.

Pete

Posted on Jul 27, 2014, 12:17 AM

Respond to this message   

Return to Index


Create sequential data file

by basicstudent (no login)

Hi,

I made some changes, buy still having issues. If you can please give me tips on what to improve.


REM*****THIS PROGRAM IS DESIGNED TO CERATE A SEQUENTIAL DATA FILE******

REM*******************PROGRAM VARIABLES****************
REM SPERSONNUM$ SALES PERSON'S NUMBER
REM NAM$ NAME
REM COMMR$ COMMISSION RATE
REM SALAMT$ AMOUNT OFSALARIES

REM *******************MAIN MODULE*********************

GOSUB OpenFile
GOSUB CreateFile
GOSUB CloseFile
PRINT
PRINT " END OF PROGRAM "
END

REM ********************OPEN FILE***********************
OpenFile:
OPEN "SALEDATA.DAT" FOR OUTPUT AS #1
RETURN
REM *******************CREATE FILE**********************
CreateFile:
GOSUB InputSalesmanNum
DO UNTIL SPERSONNUM = 0
GOSUB InputSalesData
GOSUB WriteRecord
GOSUB InputSalesmanNum
LOOP
RETURN
REM *********INPUT SALESMAN NUMBER*********************
InputSalesmanNum:
CLS
LOCATE 9, 14
PRINT "ENTER SALESMAN NUMBER";
INPUT "(ENTER 0 TO END)", SPERSONNUM
RETURN
REM *************SALES DATA******************************
InputSalesData:
LOCATE 11, 14
INPUT " SALESMAN NAME ", NAM$
LOCATE 13, 14
INPUT "ENTER SALE AMOUNT ", SALAMT
LOCATE 15, 14
INPUT "ENTER COMMISSION RATE ", COMMR
RETURN

' ************ Print The Report ***************

PrintReport:

DO UNTIL SalesNum = 0
LET Comm = SaleAmt * (CommRt / 100)
INPUT #1, SalesNum, NAM$, SaleAmt, CommRt
PRINT USING D$; SalesNum; NAM$; SaleAmt; CommRt; Comm
LOOP
RETURN

RETURN
REM *****************WRITE RECORD TO DISK****************
WriteRecord:
WRITE #1, SPERSONNUM, NAM$, SALAMT, COMMR
RETURN
REM *****************CLOSE FILE***********************
CloseFile:
CLOSE #1
RETURN

Posted on Jul 31, 2014, 9:46 PM

Respond to this message   

Return to Index


read data single dimension arrays

by best (no login)

Write a program using single dimension arrays to analyze and income survey. The Statistics for each home include an identification code, the number of members in the household, and the yearly income. I want to make sure I did this right

DIM IDNum(1 TO 14), AnIncome(1 TO 14), NumPersons(1 TO 14), PovertyLevel(1 TO 14), BelowPov(1 TO 14)

GOSUB InitializeVariables
GOSUB LoadTables
CLS
GOSUB PrintDetail
GOSUB PrintSubtotals
GOSUB PrintTotals
END

InitializeVariables:
LET PageCt = 0
LET IDNum = 0
LET NumPersons = 0
LET T1$ = " Income Survey PAGE ##"
LET H1$ = ""
LET H2$ = " ID Number ANNUAL INCOME NUMBER OF PERSONS "
LET D1$ = " #### $##,###.## #"
LET ST$ = " SUBTOTAL #"
LET TL$ = " TOTAL #"
LET MaxLines = 30
RETURN

'******************************
' Read numbers into the array
' *****************************


LoadTables:
FOR N = 1 TO 14
READ IDNum(N), AnIncome(N), NumPersons(N)
GOSUB CalcPoverty
LET TotIncome = TotIncome + AnIncome(N)
NEXT N

DATA 2497,12500,2
DATA 3323,1300,5
DATA 4521,18210,4
DATA 6789,8000,2
DATA 5476,6000,1
DATA 4423,16400,3
DATA 6587,25000,4
DATA 3221,10500,4
DATA 5555,15000,2
DATA 0085,19700,3
DATA 3097,20000,8
DATA 4480,23400,5
DATA 0265,19700,2
DATA 8901,13000,3
DATA 0,0,0
DATA END
RETURN

CalcPoverty:
IF NumPersons(N) <= 2 THEN
PovertyLevel(N) = 8000
ELSEIF NumPersons(N) > 2 THEN
PovertyLevel(N) = 8000 + (2000 * (NumPersons(N) - 2))
END IF
IF AnIncome(N) < PovertyLevel(N) THEN
LET TotBelowPov = TotBelowPov + 1
END IF
RETURN

PrintDetail:
PRINT H2$
FOR N = 1 TO 14
PRINT USING D1$; IDNum(N); AnIncome(N); NumPersons(N) 'Print details
NEXT N
RETURN

PrintSubtotals:
LET AvgIncome = TotIncome / 14 'Calc average income
LET PercentBelowPov = TotBelowPov / 14 * 100 'Calc % below pov
RETURN

PrintTotals:
PRINT USING "$##,###.## "; AvgIncome; "is the average income"
GOSUB PrintAboveAverage
PRINT USING "##.#% "; PercentBelowPov; "of households are below the poverty line"
RETURN

PrintAboveAverage:
PRINT H2$
FOR N = 1 TO 14
IF AnIncome(N) > AvgIncome THEN
PRINT USING D1$; IDNum(N); AnIncome(N); NumPersons(N)
END IF
NEXT N
RETURN





Posted on Jul 26, 2014, 9:22 PM

Respond to this message   

Return to Index


For/next loop

by newbie (no login)

For this homework, I have to use a FOR/NEXT loop to total numbers from 1 through 100. Print the numbers on the screen.
This is what I did. Is this correct?
REM ***** USING FOR-NEXT*********
CLS
FOR A = 1 TO 100
PRINT A
NEXT A

Posted on Jul 26, 2014, 7:52 PM

Respond to this message   

Return to Index


Re: For/next loop

by SMcNeill (no login)

Half there. You've printed the numbers, but where's the total of them? You still need to keep a running total and display it as you go.

Posted on Jul 26, 2014, 8:26 PM

Respond to this message   

Return to Index


Total not shown

by Solitaire (Login Solitaire1)
S

You printed the numbers, but haven't totaled them.
Use an accumulator variable for the total. Initialize it to 0 before starting the loop. Inside the loop, assign the previous total to itself and add on the current number. Then print the value of the accumulator.

Posted on Jul 27, 2014, 9:46 AM

Respond to this message   

Return to Index


QBasic on Android

by Pete (Login The-Universe)
Admin

For those who don't mind running their QB apps in DOSBox, it is worth noting that there is an aDOSBox version out, that will run your QB programs on an Android device.

I anticipate experimenting with some mobile apps, soon, and converting some to an appropriate language for Android, but it will be nice to make an install of aDOSBox to test what I rewrite against what already will run on an emulator.

Pete

Posted on Jul 24, 2014, 6:43 AM

Respond to this message   

Return to Index


Re: QBasic on Android

by Jim (no login)

Do you think QBasic on Android is worth it? An android mobile computer seems quite different from a IBM personal computer of sort. Perhaps a sewing machine for a glass sculpture.

Posted on Jul 24, 2014, 9:36 PM

Respond to this message   

Return to Index


Re: QBasic on Android

by SMcNeill (Login SMcNeill)
R

I've been thinking on this as well. Exactly how well would most QBasic programs port over to a mobile device?

How does QB handle device rotation?
How about a 2 finger pinch to zoom?
Or a 3 finger swipe to switch apps?
Will font sizes be readable? If you write a program for a tablet, will the fonts remain readable for a phone?
Will input on the device be worthwhile? A lot of QB programs deal with text, and text entry is a PITA for most tablets.
And most importantly, is there an existing app that was created already under a different platform that would be able to do what you need, and do it better?

Personally, I don't see what the big deal is with wanting to use QBasic to make mobile apps. It seems to me that any project completed would look and feel half-assed no matter what, and wouldn't be suitable for any commercial products. And if I don't need an app for a commercial product, I find that writing it for my PC and then simply using my tablet to remote desktop connect and run it is more than sufficient for my needs.

I hope someone out there can prove me wrong and show us a working example of something amazing that was written in BASIC and ran on a mobile device, but I really think just about anything wrote in QBasic-type languages is going to be a hackjob at best.

Posted on Jul 25, 2014, 3:41 AM

Respond to this message   

Return to Index


Sure it will be if you do it! *

by Clippy (Login burger2227)
R

Posted on Jul 25, 2014, 8:03 AM

Respond to this message   

Return to Index


Valid points Steve, however...

by TheBOB (Login qb432l)
R

...since when has QBasic programming ever been valued for its practical or commercial potential? I'm thinking that Pete probably wants to write simple programs that keep track of his son's progress in golf and the like. Plus, it would be just plain fun.

-Bob

Posted on Jul 25, 2014, 9:10 AM

Respond to this message   

Return to Index


Bob nailed it. QB64'ers are also getting it bassackwards.

by Pete (Login The-Universe)
Admin

Bob BASICally has what I'm getting at figured out.

You guys are too worried about the project being a "toy" language. I successfully used that toy language to run a profession. So know you want to make it a professional language, and for what? To make toys!

Take a lesson from PowerBasic. They made a version for DOS that is very QBasic compatible, but then designed something pretty foreign to QB, called PowerBasic for Windows. Port some OOP up that version, and people like me won't care. They also have two discussion forums, so people who don't want to do the Windows version can still be expert helpers in the DOS version.

In the time it would take QB64 to be what I see posted its futures list, I could learn Python, and already have everything I want running. There is no innovation here. You are now at the point of creating a bloated translator, that doesn't accomplish anything new, and by the time it is near ready, will probably be lagging behind whatever else develops over the next 5 years. That is not professional, that's called a hobby, still.

Now if yo do get other developers on board, you can make a clear cut path forward, and keep everybody on that path to completion, you actually do stand a chance of this working out as a community project, and good for you if that becomes the new reality. If not, you are following someone's personal project. Unfortunately, I believe to get others involved will take cleaning up and organizing the source code a ton, and that will take a fair amount of time, too.

Pete

Posted on Jul 25, 2014, 9:36 AM

Respond to this message   

Return to Index


* Well at least your Android journey has not gone too far away...

by Clippy (Login burger2227)
R

[linked image]

Posted on Jul 25, 2014, 10:57 AM

Respond to this message   

Return to Index


come on man

by Jim (no login)

Programmers regularly learn new languages in a week's time - it's part of the skill. How long can it take?

Posted on Jul 29, 2014, 3:53 AM

Respond to this message   

Return to Index


* Forever if you never need to!

by Clippy (Login burger2227)
R

Posted on Jul 30, 2014, 11:17 AM

Respond to this message   

Return to Index


Read Data Statement is not working

by Benjamin (no login)

I wrote a program to list the best colleges for a particular major where the user must select a particular are of study and a list of colleges must appear. I have to use Data statements to show the list's of colleges, but for some reason its not working out. Please help.

My Program:

CLS
'********** Program to find Best Colleges **********
' Variables
' Choice, Selection
' Nam$ Names of colleges

'**********Program Mainline **********

DO
GOSUB DisplayMainMenu
PRINT
PRINT
PRINT TAB(16); "Enter Choice";
INPUT Choice

SELECT CASE Choice
CASE 1
GOSUB FirstItem
CASE 2
GOSUB SecondItem
CASE 3
GOSUB ThirdItem
CASE 4
GOSUB FourthItem
END SELECT
LOOP UNTIL Choice = 5 '5 is ending value
PRINT "End of Program"
END


'********** Display Main Menu **********
DisplayMainMenu:
PRINT
PRINT
PRINT
PRINT TAB(25); "Best colleges for majors in"
PRINT
PRINT
PRINT TAB(20); "1. Computer Information Systems"
PRINT TAB(20); "2. Computer programming"
PRINT TAB(20); "3. Business Economics"
PRINT TAB(20); "4. Photography"
PRINT TAB(20); "5. Quit"
PRINT
RETURN

'********** Initialize Choices **********
FirstItem:
READ NAM$
DATA 1. COMPUTER INFORMATION SYSTEMS
DATA a. College of Technology
DATA b. Computer Tech College
DATA c. Technical College of Illinois
DATA d. Marshall University
DATA End
INPUT "Enter to continue", E$
RETURN

SecondItem:
READ NAM$
DATA 2. COMPUTER PROGRAMMING
DATA a. Technical College of Dupage
DATA b. IT Tech College
DATA c. University of Illinois
DATA d. Kalgon University
DATA End
INPUT "Enter to continue", E$
RETURN

ThirdItem:
READ NAM$
DATA 3. BUSINESS ECONOMICS
DATA a. College of Dupage
DATA b. Berkshire College
DATA c. University of Illinois
DATA d. Kelvin University
DATA End
INPUT "Enter to continue", E$
RETURN

FourthItem:
READ NAM$
DATA 4. PHOTOGRAPHY
DATA a. Art Institute of Dupage
DATA b. Harrison College
DATA c. Art College of Illinois
DATA d. University of Akron
DATA End
INPUT "Enter to continue", E$
RETURN

Thanks

Posted on Jul 22, 2014, 8:19 PM

Respond to this message   

Return to Index


you need to call read in a loop

by qbguy (no login)

For firstitem:


firstitem:
RESTORE firstitem:
nam$ = ""
DO
PRINT nam$
READ nam$
LOOP WHILE nam$ <> "End"
DATA 1. COMPUTER INFORMATION SYSTEMS
DATA a. College of Technology
DATA b. Computer Tech College
DATA c. Technical College of Illinois
DATA d. Marshall University
DATA End
INPUT "Enter to continue", E$
RETURN

and the other items are similar

Posted on Jul 22, 2014, 9:06 PM

Respond to this message   

Return to Index

 Copyright © 1999-2014 Network54. All rights reserved.   Terms of Use   Privacy Statement