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



More Questions Regarding operators, data types indenting, etc...

by Negative (no login)

Thanks for the answers on the last post. After that I came across some more questions Google couldn't answer. =]

-Are AND/OR considered to be operators like +,-,*,/..?

-Is a Boolean a data type like strings, integers, etc.?

-Is an exponent/power (^) considered to be an arithmetic operator?

-In the below example everything inside the DO..LOOP is indented. Is there a certain name for commands that usually have things inside them indented? I know the indenting is not required, but usually the same commands like DO...LOOP, IF...ELSE, etc. get indented.
Example:
DO
PRINT "Hi"
PRINT "Hello"
LOOP

-Is there a way to input quotation marks inside strings (so they'll be shown on the output screen)?

-Arguments & Parameters: "Functions/Commands exchange information by means of parameters and arguments. A parameter refers to any declaration within the parentheses following the function name in a function declaration or definition; argument refers to any expression within the parentheses of a function call."
That quote is a little too hard to understand. What I got from it was: A parameter is anything in parenthesis (...) after a command; and an argument is any expression within parenthesis.
If my definition isn't right, what exactly is a parameter and argument, and what are their differences?

Posted on Sep 20, 2010, 3:10 PM

Respond to this message   

Return to Index


Some answers --

by Solitaire (Login Solitaire1)
S

There are several types of operators used in programming. The following are available in QBasic:

Math operators: +, -, *, /, \, Mod, ^

Relational operators: =, >, etc. (Note: This forum has trouble displaying the less-than symbol. There are 6 altogether.)

Logical operators: AND, OR, NOT, XOR, EQV, IMP

================================================================

QBasic does not have a separate Boolean type but Visual Basic does. The values of a Boolean type are either True or False. In QBasic, it's equivalent to the integer values of 0 (False) or -1 (True) or any non-zero number (True).

For example, if you run this code:
PRINT 4 > 5
The output will be 0.

PRINT 5 > 4
The output will be -1

=================================================================

A DO--LOOP is a structure block. Blocks use opening and closing statements and the contents inside the block are usually indented. In Visual Basic, the indentation of a structure block is automatic.

==================================================================

Quotation marks can be shown inside a string by using the ASCII value.
For example:

PRINT "He said, "; CHR$(34); "Hello."; CHR$(34)

====================================================================

An argument is an expression placed within parentheses following a call from the main program (or it could even be a call from a sub). The expression can be either a variable, a literal value, or a more complicated expression including an operator. A list of several arguments uses a comma separator. For example:

DIM first AS STRING, age AS INTEGER
first = "Joe"
age = 21
CALL mysub(first, age, age + 1)

A parameter is a variable name placed within parentheses in the sub that was called. It can use only variables and must include the variable type. A list of several parameters uses a comma separator. If an expression is used in the argument list, it must be replaced by a variable in the parameter list. For example:

SUB mysub (first AS STRING, age AS INTEGER, year AS INTEGER)
PRINT "Your name is "; first; " and your age is"; age
PRINT "Next year you will be"; year
END SUB

It is very important that the argument list and parameter list correspond in number, order, and type. The name of the variables in the parameter list is not important as long as they correspond. You can use different variable names in the parameter list and it will still work. For example:

SUB mysub (nom AS STRING, old AS INTEGER, year AS INTEGER)
PRINT "Your name is "; nom; " and your age is"; old
PRINT "Next year you will be"; year
END SUB

Note that the parameter list must include only variables, but the argument list may also include literal values or expressions.

Also note that as soon as you save a program with subs, the DECLARE statement automatically appears at the top of the main program. This statement includes the "signature," which is the complete parameter list. You never need to type in the declare statement manually.

=========================================================================

I hope this answers your questions.





    
This message has been edited by Solitaire1 on Sep 20, 2010 4:47 PM
This message has been edited by Solitaire1 on Sep 20, 2010 4:36 PM
This message has been edited by Solitaire1 on Sep 20, 2010 4:14 PM
This message has been edited by Solitaire1 on Sep 20, 2010 4:06 PM

Posted on Sep 20, 2010, 4:03 PM

Respond to this message   

Return to Index


Please Help Me :(

by (no login)

I am begginer with Qbasic,and I need to do this program(donno how) can you please help me :(


- Generate 20 random numbers(from 10-99)
- show odd and even numbers
- recommit odd and recommit even numbers
- show sum of odd and even number
- show then in file

Posted on Sep 20, 2010, 11:43 AM

Respond to this message   

Return to Index


Warning - Can not post this message. Please login and try again.

by (no login)

WTF ?

Posted on Sep 20, 2010, 12:04 PM

Respond to this message   

Return to Index


* READ the Homework Policy in the header! Post your code!

by Clippy (Login burger2227)
R

Posted on Sep 20, 2010, 1:39 PM

Respond to this message   

Return to Index


Draw a circle using only PSET and integers: no SIN/COS, no SQRT...

by angros47 (no login)

Here you are:

SCREEN 12

CONST R=100

DIM X AS INTEGER
DIM Y AS INTEGER
DIM Y2 AS INTEGER
DIM TMP AS INTEGER

FOR X=-R TO R
Y2=R*R-X*X
TMP=1 : Y=Y2
DO
TMP=(Y+TMP)/2
Y=Y2/TMP
LOOP UNTIL ABS(Y-TMP)<2
PSET (320+X,240+Y): PSET (320+X,240-Y):
NEXT
SLEEP

This program uses Pythagorean theorem (the radius of the circle is the hypotenuse, knowing it and X it calculates Y), and a trick to get square root, without using built-in functions.

It's completely useless, but writing it was fun.

Posted on Sep 19, 2010, 1:03 PM

Respond to this message   

Return to Index


Here's one from me

by Unseen Machine (no login)

SCREEN 12

FOR i = 1 TO 8
x = 0
FOR j = 1 TO 8
READ clr
IF clr = 1 THEN PSET (x, y), 15
x = x + 1
NEXT
y = y + 1
NEXT

DATA 0,0,0,0,0,0,0,0
DATA 0,0,1,1,1,1,0,0
DATA 0,1,0,0,0,0,1,0
DATA 0,1,0,0,0,0,1,0
DATA 0,1,0,0,0,0,1,0
DATA 0,1,0,0,0,0,1,0
DATA 0,0,1,1,1,1,0,0
DATA 0,0,0,0,0,0,0,0

Posted on Sep 19, 2010, 2:51 PM

Respond to this message   

Return to Index


Re: Draw a circle using only PSET and integers: no SIN/COS, no SQRT...

by Ben (no login)

x = 100 'radius
y = 0
d = -x

x1 = 100 'coordinates
y1 = 200

SCREEN 12
DO WHILE x > y
y = y + 1
d = d + y + y
IF d > 0 THEN
x = x - 1
d = d - x - x
END IF
PSET (x + x1, y + y1)
PSET (x + x1, -y + y1)
PSET (-x + x1, y + y1)
PSET (-x + x1, -y + y1)

PSET (y + x1, x + y1)
PSET (-y + x1, x + y1)
PSET (y + x1, -x + y1)
PSET (-y + x1, -x + y1)
LOOP

Posted on Sep 19, 2010, 2:51 PM

Respond to this message   

Return to Index


The Breshenham algorithm revisited

by David (no login)

Drawing a circle (or any other function) on the screen we are not trying for high accuracy analogue values. The trick is to determine which is the closest pixel to the function you want to represent so we can work with integers rather than floating point numbers.

All functions will at some point have gradients (grad<1) such that increasing x by one will cause y to either not change or also increase by one. All the algorithm has to do is to change the x value (in pset) by one and decide whether y should change (by one) or stay the same.

Note a circle also has high symmetry so that only one octant has to be calculated and the other octants and be generated by axes reflections.

Below is the challenge to draw 1000 (random sized filled) as quickly as possible without using "CIRCLE".



DEFINT A-S, U-Z
SCREEN 12
RANDOMIZE TIMER
tt = TIMER
m = 1
FOR jj = 1 TO 1000
xoff = INT(RND * 640): yoff = INT(RND * 480)
c = INT(RND * 16)
y = 2 + INT(RND * RND * RND * RND * 130)
d = 0
x = -1
WHILE x < y
x = x + m
d = d + x + x + m
IF d > 0 THEN d = d - y - y + m: y = y - m
FOR k = 0 TO 7
IF k AND 4 THEN a = -x ELSE a = x
IF k AND 2 THEN b = -y ELSE b = y
IF k AND 1 THEN SWAP a, b
q2 = a: q3 = 0
IF a < 0 THEN SWAP q2, q3
FOR q1 = q3 TO q2
PSET (q1 + xoff, b + yoff), c
PSET (640 - q1 - xoff, 480 - b - yoff), c
NEXT q1
NEXT k
WEND
NEXT jj
PRINT TIMER - tt

Posted on Sep 20, 2010, 4:40 AM

Respond to this message   

Return to Index


could you use LINE?

by Ben (no login)

Posted on Sep 20, 2010, 6:30 AM

Respond to this message   

Return to Index


Re: could you use LINE?

by Ben (no login)

RANDOMIZE TIMER
DEFINT A-Z

SCREEN 12

t! = TIMER
FOR i = 1 TO 1000
x = 2 + INT(RND * RND * RND * RND * 130) 'radius
y = -1
d = -x

x1 = INT(RND * 640) 'coordinates
y1 = INT(RND * 480)
COLOR INT(RND * 16)
DO WHILE x > y
y = y + 1
d = d + y + y

IF d > 0 THEN
x = x - 1
d = d - x - x
END IF
'PSET (x + x1, y + y1)
'PSET (x + x1, -y + y1)
'PSET (-x + x1, y + y1)
'PSET (-x + x1, -y + y1)
'PSET (y + x1, x + y1)
'PSET (-y + x1, x + y1)
'PSET (y + x1, -x + y1)
'PSET (-y + x1, -x + y1)
LINE (x + x1, -y + y1)-(-x + x1, -y + y1)
LINE (x + x1, y + y1)-(-x + x1, y + y1)
LINE (y + x1, x + y1)-(-y + x1, x + y1)
LINE (y + x1, -x + y1)-(-y + x1, -x + y1)
LOOP
NEXT
PRINT TIMER - t!


Posted on Sep 20, 2010, 8:53 AM

Respond to this message   

Return to Index


* What trick? There are no non-integer pixel positions!

by Clippy (Login burger2227)
R

Posted on Sep 20, 2010, 8:33 AM

Respond to this message   

Return to Index


More fun

by Lisztfr (no login)

DO
TMP=(Y+TMP)/2
Y=Y2/TMP
LOOP UNTIL ABS(Y-TMP)<2

This looks like it could be put in a recursive function...? (that call itself)






Posted on Sep 20, 2010, 11:43 AM

Respond to this message   

Return to Index


Another challenge

by Lisztfr (no login)

The knight challenge on a chess board. Make the knight go overe all the fieds once, and only once.

64 nested loops ?

Posted on Sep 15, 2010, 2:24 AM

Respond to this message   

Return to Index


*URL

by David (no login)

http://www.network54.com/Forum/202193/message/1206121178/Knight's+Tour

Posted on Sep 15, 2010, 4:09 AM

Respond to this message   

Return to Index


Heuristic in the knight tour

by Lisztfr (no login)

I'm affraid that in the knight's tour there isn't much heuristic, beside of that from the initial poster : The next step should offer the less moves.

Other variant : the 2nd next step should offer the less moves.

But for example, in 3 steps we should get far away from place 1, or, the board should remain center-weighted (each step = 1 unit weight) after 10 steps, or the surface of the 3-5 moves (draw on board) should be maximal, .. this all doesn't make sens.

Random search is silly, with backtracking is little better.

Posted on Sep 16, 2010, 1:45 AM

Respond to this message   

Return to Index


Using Warnsdorff's algorithm

by David (no login)

CLS
DIM q(-10 TO 18, -10 TO 18) AS INTEGER, z(65) AS INTEGER
DIM cx(9) AS INTEGER, cy(9) AS INTEGER, rx(9) AS INTEGER, ry(9) AS INTEGER
r = 4: c = 4 'starting point
q(r, c) = 1
FOR i = 1 TO 8
FOR k = 1 TO 8
LOCATE i, k * 2
PRINT CHR$(176) + CHR$(176);
NEXT k
NEXT i
LOCATE r, c * 2
PRINT CHR$(219) + CHR$(219);
num = 1
z(num) = r + (c - 1) * 8
q(r, c) = 1
WHILE num < 64
rx(1) = r - 1: cx(1) = c - 2
rx(2) = r + 1: cx(2) = c - 2
rx(3) = r - 1: cx(3) = c + 2
rx(4) = r + 1: cx(4) = c + 2
rx(5) = r - 2: cx(5) = c - 1
rx(6) = r + 2: cx(6) = c - 1
rx(7) = r - 2: cx(7) = c + 1
rx(8) = r + 2: cx(8) = c + 1
pmin = 20
FOR i = 1 TO 8
IF rx(i) > 0 AND rx(i) < 9 AND cx(i) > 0 AND cx(i) < 9 AND q(rx(i), cx(i)) = 0 THEN
ry(1) = rx(i) - 1: cy(1) = cx(i) - 2
ry(2) = rx(i) + 1: cy(2) = cx(i) - 2
ry(3) = rx(i) - 1: cy(3) = cx(i) + 2
ry(4) = rx(i) + 1: cy(4) = cx(i) + 2
ry(5) = rx(i) - 2: cy(5) = cx(i) - 1
ry(6) = rx(i) + 2: cy(6) = cx(i) - 1
ry(7) = rx(i) - 2: cy(7) = cx(i) + 1
ry(8) = rx(i) + 2: cy(8) = cx(i) + 1
'END IF
p = 0
FOR k = 1 TO 8
IF ry(k) > 0 AND ry(k) < 9 AND cy(k) > 0 AND cy(k) < 9 AND q(ry(k), cy(k)) = 0 THEN p = p + 1
NEXT k
IF p < pmin THEN pmin = p: imin = i
END IF
NEXT i
pmin = 20
num = num + 1
r = rx(imin): c = cx(imin)
z(num) = r + (c - 1) * 8
IF z(num) > 64 THEN PRINT "off the board": END
q(r, c) = 1
LOCATE r, c * 2
PRINT CHR$(219) + CHR$(219);
tt = TIMER
WHILE TIMER - tt < .2: WEND '*******DELAY*******
WEND
WHILE h$ = ""
h$ = INKEY$
WEND
LOCATE 10, 1
FOR i = 1 TO 64
PRINT USING "###"; z(i);
IF i MOD 8 = 0 THEN PRINT
NEXT i

Posted on Sep 16, 2010, 11:58 AM

Respond to this message   

Return to Index


Ok i will have to jump into that matter, soon i remember some qbasic stuff.

by Lisztfr (no login)

Something unexpected ?

28 11 1 18 3 9 26 41
58 43 33 50 60 54 64 47
32 15 5 20 10 25 35 52
62 56 39 24 7 22 37 27
17 2 12 6 16 31 48 63
53 59 49 34 44 61 46 29
14 8 23 38 21 4 19 13
30 40 55 45 51 36 42 57

"2" is next the 17

nice animation :=) (not reflecting this)

Posted on Sep 16, 2010, 3:31 PM

Respond to this message   

Return to Index


Wolfram has an article on this with example results

by Zom-B (Login Zom-B)
R



    
This message has been edited by Zom-B on Sep 19, 2010 4:39 AM

Posted on Sep 19, 2010, 4:37 AM

Respond to this message   

Return to Index


A challenge

by (no login)

A math problem my Dad told me today...

1, 2, 3, 4, 5, 6, 7, 8, 9

Between these numbers we can set 3 operators :

+, -, and nothing, then the combination is the 2 digit number.

Nothing means for example, 2 3 = 23

Also 123 is allowed, any combination. All numbers must be used one time, in the above order.

Example : 123 -4 + 56 -7 + 89

The result must be 100.

estimated possibilities :

3 ^ 9 : 19683


Posted on Sep 12, 2010, 11:55 AM

Respond to this message   

Return to Index


* WE DO have a CHALLENGE FORUM ya know....

by (Login burger2227)
R

LA Challenge Fooruum

Posted on Sep 12, 2010, 8:16 PM

Respond to this message   

Return to Index


* Dammit, N54 lost my name again!

by (Login burger2227)
R

Posted on Sep 12, 2010, 8:17 PM

Respond to this message   

Return to Index


* I bet Galleon wished he had a spiffy forum host like we do.

by (Login The-Universe)
Admin

Posted on Sep 12, 2010, 8:41 PM

Respond to this message   

Return to Index


Yes but who is looking at the challenge forum ... ?

by (no login)

Still not solved ? lol ...

Problem is to not omit some combination so, we need a scanning routine.

The sign in front of 1 is always "+", i forgot to tell.

So given the start position like all signs are "+".

Hum... this smells bad.

Feels like needing to build a tree. Or store some variable (hate that)

=================

The 2nd sign should take all 3 value, then again for the 3rd sing is taking all 3 values... How to keep that dam thing small ?





Posted on Sep 13, 2010, 3:47 AM

Respond to this message   

Return to Index


There are 3^8 combinations

by David (no login)

If I've done it correctly there are only 11 solutions

1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100
1 + 2 + 34 - 5 + 67 - 8 + 9 = 100
1 + 23 - 4 + 5 + 6 + 78 - 9 = 100
1 + 23 - 4 + 56 + 7 + 8 + 9 = 100
12 + 3 + 4 + 5 - 6 - 7 + 89 = 100
12 + 3 - 4 + 5 + 67 + 8 + 9 = 100
12 - 3 - 4 + 5 - 6 + 7 + 89 = 100
123 + 4 - 5 + 67 - 89 = 100
123 + 45 - 67 + 8 - 9 = 100
123 - 4 - 5 - 6 - 7 + 8 - 9 = 100
123 - 45 - 67 + 89 = 100

And yes we've had a similar challenge before (see October 2005).

Posted on Sep 13, 2010, 6:26 AM

Respond to this message   

Return to Index


This is correct

by Lisztfr (no login)

My Dad put the problem on CASTEM progam and also found only 11 solutions. CASTEM is a kind of language for ... yep ; Resistence of material. So this is evil as one can expext. It's like Qbasic with less possibilities, Qbasic less GOTO, mixed with... fortran's mind.

Posted on Sep 13, 2010, 6:53 AM

Respond to this message   

Return to Index


*Congratulations, David -- any chance of seeing your code?

by (Login qb432l)
R

*

Posted on Sep 13, 2010, 7:03 AM

Respond to this message   

Return to Index


The orginal challenge had / and * as well.

by David (no login)

DEFINT A-R, T-Z
DEFLNG S
DIM n(10) AS LONG
FOR i = 1 TO 9
nn(i) = i
NEXT i
FOR i1 = 1 TO 3
FOR i2 = 1 TO 3
FOR i3 = 1 TO 3
FOR i4 = 1 TO 3
FOR i5 = 1 TO 3
FOR i6 = 1 TO 3
FOR i7 = 1 TO 3
FOR i8 = 1 TO 3
z = z + 1
j(1) = i1: j(2) = i2: j(3) = i3: j(4) = i4
j(5) = i5: j(6) = i6: j(7) = i7: j(8) = i8
FOR k1 = 1 TO 9
n(k1) = nn(k1)
NEXT k1
m = 8
mm = m: k = 0
WHILE k < mm
k = k + 1
IF j(k) = 3 THEN
n(k) = n(k) * 10 + n(k + 1)
FOR k1 = k + 1 TO mm + 1
j(k1 - 1) = j(k1)
n(k1) = n(k1 + 1)
NEXT k1
m = m - 1
k = k - 1
END IF
WEND
sum = n(1)
FOR k = 1 TO m
IF j(k) = 1 THEN sum = sum + n(k + 1)
IF j(k) = 2 THEN sum = sum - n(k + 1)
NEXT k
IF sum = 100 THEN
FOR k3 = 1 TO m
IF n(k3) > 11 AND n(k3) < 100 THEN PRINT USING "##"; n(k3);
IF n(k3) < 11 THEN PRINT USING "#"; n(k3);
IF n(k3) > 100 THEN PRINT USING "###"; n(k3);
IF j(k3) = 1 THEN PRINT " + ";
IF j(k3) = 2 THEN PRINT " - ";
NEXT k3
PRINT n(k3); " = 100"
sum2 = sum2 + 1
END IF
NEXT i8
NEXT i7
NEXT i6
NEXT i5
NEXT i4
NEXT i3
NEXT i2
NEXT i1
PRINT : PRINT "number of solutions= "; sum2; " combinations= "; z

Posted on Sep 13, 2010, 8:16 AM

Respond to this message   

Return to Index


*Very nice! Thanks.

by (Login qb432l)
R

*

Posted on Sep 13, 2010, 1:33 PM

Respond to this message   

Return to Index


* Nice program, David. I think I actually remembered it from long ago.

by (Login The-Universe)
Admin

Posted on Sep 13, 2010, 12:00 PM

Respond to this message   

Return to Index


Very nice, foremost because there isn't a single comment !

by (no login)

1) Very good program.

2) I like nested loops.

Posted on Sep 13, 2010, 3:06 PM

Respond to this message   

Return to Index


* IF you had looked in the Challenge forum, you could have seen it!

by (Login burger2227)
R

Posted on Sep 13, 2010, 3:59 PM

Respond to this message   

Return to Index


Ok, but :

by Lisztfr (no login)

I will soon, promise

Is it possible to do it without nested loops, - i guess not.... So we are limited by the limitation of Qbasic. Imagine i would have complicated the prob with 100 numbers.

We need a Montecarlo algorithm, obviously.

Posted on Sep 14, 2010, 2:34 AM

Respond to this message   

Return to Index


without nested loops

by David (no login)

Hope you like the GOTO slipped in at the end to add to the confusion.
I think nested loops are better.


DEFINT A-R, T-Z
DEFLNG S
DIM n(10) AS LONG, j(10) AS INTEGER, jj(10) AS INTEGER, nn(10) AS INTEGER
FOR i = 1 TO 9
nn(i) = i
NEXT i
FOR i = 2 TO 8
j(i) = 1
NEXT i
20 j(1) = j(1) + 1
FOR i = 1 TO 8
IF j(i) = 4 THEN j(i) = 1: j(i + 1) = j(i + 1) + 1
jj(i) = j(i)
NEXT i
IF j(9) = 1 THEN 10
z = z + 1
FOR k1 = 1 TO 9
n(k1) = nn(k1)
NEXT k1
m = 8
mm = m: k = 0
WHILE k < mm
k = k + 1
IF jj(k) = 3 THEN
n(k) = n(k) * 10 + n(k + 1)
FOR k1 = k + 1 TO mm + 1
jj(k1 - 1) = jj(k1)
n(k1) = n(k1 + 1)
NEXT k1
m = m - 1
k = k - 1
END IF
WEND
sum = n(1)
FOR k = 1 TO m
IF jj(k) = 1 THEN sum = sum + n(k + 1)
IF jj(k) = 2 THEN sum = sum - n(k + 1)
NEXT k
IF sum = 100 THEN
FOR k3 = 1 TO m
IF n(k3) > 11 AND n(k3) < 100 THEN PRINT USING "##"; n(k3);
IF n(k3) < 11 THEN PRINT USING "#"; n(k3);
IF n(k3) > 100 THEN PRINT USING "###"; n(k3);
IF jj(k3) = 1 THEN PRINT " + ";
IF jj(k3) = 2 THEN PRINT " - ";
NEXT k3
PRINT n(k3); " = 100"
sum2 = sum2 + 1
END IF
GOTO 20
10 PRINT : PRINT "number of solutions= "; sum2; " combinations= "; z

Posted on Sep 14, 2010, 4:31 AM

Respond to this message   

Return to Index


Nested loop limit ?

by (no login)

Until 17 it's OK :

a& = 0

Z1 = TIMER

PRINT Z1

FOR i1 = 1 TO 3
FOR i2 = 1 TO 3
FOR i3 = 1 TO 3
FOR i4 = 1 TO 3
FOR i5 = 1 TO 3
FOR i6 = 1 TO 3
FOR i7 = 1 TO 3
FOR i8 = 1 TO 3
FOR i9 = 1 TO 3
FOR i10 = 1 TO 3
FOR i11 = 1 TO 3
FOR i12 = 1 TO 3
FOR i13 = 1 TO 3
FOR i14 = 1 TO 3
FOR i15 = 1 TO 3
FOR i16 = 1 TO 3
FOR i17 = 1 TO 3

a& = a& + 1

IF (a& MOD 1000) = 0 THEN PRINT a&


NEXT i17
NEXT i16
NEXT i15
NEXT i14
NEXT i13
NEXT i12
NEXT i11
NEXT i10
NEXT i9
NEXT i8
NEXT i7
NEXT i6
NEXT i5
NEXT i4
NEXT i3
NEXT i2
NEXT i1

PRINT a

Z2 = TIMER

PRINT Z1 - Z2


=======================================

Output, on my super fast 750 Mhz Pentium III, Dell's flagship (Latitude CPx with better cpu ):

129138000
129139000
129140000
0
-370.0313

Only about 6 mn 10 s

Posted on Sep 14, 2010, 5:40 AM

Respond to this message   

Return to Index


question about variable output...

by Sail (no login)

im just learning QB and i have an assignment due...

we have to write a program that figures out sales tax on a given item...
when it runs, if any amount that needs to be displayed ends in zero, ie 15.50 it will drop off the zero and display 15.5

i understand that the computer sees no reason to display the zero, and as it stands i will recieve full points for the assignment...but for asthetic reasons id like the zero to stay...any help would be appreciated

Posted on Sep 10, 2010, 10:12 PM

Respond to this message   

Return to Index


heres my code btw...

by Sail (no login)

'cis 115
'8 sep 10
'assignment 3

'the purpose of this program is to find the
'purchase price of an item with sales tax

CLS

PRINT " this is the Q Sales Tax Calculator"
PRINT "===================================="
PRINT ""
PRINT "cost of the item you are purchasing:"
PRINT ""
PRINT "what is the sales tax for your area:"
PRINT " please exclude the '%' sign"

LOCATE 4, 38
INPUT "", itemPrice
LOCATE 6, 38
INPUT "", salesTax

salesTax = salesTax * .01
total = itemPrice + (itemPrice * salesTax)
total = INT(total * 100 + .5) / 100

CLS
LOCATE 1, 1
PRINT "base cost of item:"
PRINT "sales tax in area:"
PRINT "sales tax on item:"
PRINT "item w/ sales tax:"

LOCATE 1, 19
PRINT INT(itemPrice * 100 + .5) / 100
LOCATE 2, 19
PRINT salesTax / .01; "%"
LOCATE 3, 19
PRINT INT((salesTax * itemPrice) * 100 + .5) / 100
LOCATE 4, 19
PRINT total

END

Posted on Sep 10, 2010, 10:28 PM

Respond to this message   

Return to Index


Re: question about variable output...

by codeguy (Login codeguy)
R

print using "###.##" will let you keep those aesthetic 0's

Posted on Sep 10, 2010, 11:30 PM

Respond to this message   

Return to Index


thanks...

by Sail (no login)

title says it all...

Posted on Sep 11, 2010, 3:55 AM

Respond to this message   

Return to Index


Couple Questions

by Negative (no login)

I'm learning QuickBasic, and I've ran into some questions:

1. How are bytes related to variables? Like an Integer and Single variable has 2 bytes. A Long Integer and Double Variable are 4 bytes. What difference does it make?

2. Strings and String variables have no spaces around them by default. However Expressions and number variables have spaces around them by default. Is there away to make numbers & expressions not have spaces?

3. Why was the LET command ever created if it’s not required or used at all?

4. How does the computer assume what the memory address location of a certain variable is going to be?

5. Why don't border Colors (COLOR 0, 1, 2) work in QuickBASIC (or do they?)?

6. Two Questions about the example code below.
1. Does everything have to be on one line after the PRINT command?
2. Is there any way to shorten the code in this example, as I feel it's too much code for a small paragraph?

CODE:
CLS
name1$ = “Bob”
name2$ = “Mike”
food1% = 2
food2% = 5
away% = 4
PRINT name1$; “ has“; food1%; “apples, and ”; name2$; “ has”; food2%; “apples. ”; name2$; “ gave ”; name1$; away%; “apples. Now”; name2%; “has“; food2% - away%; “apple, and ”; name1$; “ has”; food1% + away%; “apples.”

OUTPUT:
Bob has 2 apples, and Henry has 5 apples. Henry gave Bob 4 apples. Now Henry has 1 apple, and Bob has 6 apples.



Thanks For Reading..

Posted on Sep 9, 2010, 3:27 PM

Respond to this message   

Return to Index


Re: Couple Questions

by (Login burger2227)
R

ALL data takes up space in memory and inside of files. Strings take one byte per character.

INTEGER = 2 bytes
LONG = 4 bytes
SINGLE = 4 bytes
DOUBLE = 8 bytes

The LEN function can find the length of a variable type. It is commonly used with strings to find the number of characters are in the string.

LTRIM$ and RTRIM$ functions eliminate end spaces AFTER a number is converted to a string with STR$. STR$ eliminates the right undocumented PRINT space for you:

stringvalue$ = LTRIM$(STR$(number%))

Then you can print it. PRINT USING can also be used with ### for number digits to format a print.

LET just takes up SPACE. Some people like it.

It doesn't assume. It knows because it named it and put it there. Finding it is another story and is not something beginners need. VARSEG finds the segment address and VARPTR finds the pointer offset.

Borders don't work any more. They worked on EGA screens.

PRINT can only print the screen mode's width. You can use consecutive PRINT commands to skip rows. PRINT: PRINT

You can:

food1% = 2
food2% = 5
away% = 4
PRINT name1$; “ has“; food1%; “apples, and ”; name2$; “ has”; food2%; “apples. ”; name2$; “ gave ”; name1$; away%; “apples. Now”; name2%; “has“; food2% - away%; “apple, and ”; name1$; “ has”; food1% + away%; “apples.”

PRINT Bob has"; food1%; "apples, and Henry has"; food2%; apples. Henry gave Bob"; away%
PRINT "apples. Now Henry has"; food2% - away%; apples, and Bob has"; food1% + away%; "apples."

Semicolons or + can be used in PRINTs with strings only. Numbers require semicolon separators.



    
This message has been edited by burger2227 on Sep 9, 2010 4:09 PM

Posted on Sep 9, 2010, 4:08 PM

Respond to this message   

Return to Index


More answers:

by Solitaire (Login Solitaire1)
S

LET is a legacy command left over from the original version of BASIC. It was used by GWBASIC before QuickBasic came along and eliminated the requirement.

Positive numbers have a space to the left which implies the + symbol. Negative numbers use the - symbol so they don't have the extra space.
I guess the space to the right was included so the numbers don't bump up against each other, even if one of them is a negative. Try this for example:

PRINT 23; 89; -72; "**"; 56; "**"; -45; "**"

You don't need to use a single long PRINT statement to display a string on one line. Use a ; at the end of a string and it will be continued with the next PRINT statement. Example:

PRINT "Keep this string ";
PRINT "on one line."

========================================================================
SPECIAL NOTE:

A little-known way to display string output is with the PRINT USING statement. An ampersand (&) placeholder symbol is used instead of the actual variable name, and the entire string, including the placeholder, is enclosed within quotes. A semicolon follows the close-quote, and then the variable names, separated by semi-colons if more than one variable is used. (This is the expression list.) They must be placed in the same order as the placeholders in the string. When the program is run, the value of each variable will take the place of the &.

Example is shown below. Numbers must be converted back to strings or you will get a type mismatch error. The extra space to the left of a number must also be trimmed after converting to a string, or you must compensate for the extra space.

CLS
DIM A AS INTEGER, B AS INTEGER, C AS INTEGER
A = 3
B = 2
C = A + B
PRINT USING "A equals&. B equals&."; STR$(A); STR$(B)
PRINT : PRINT USING "The total is&."; STR$(C)
END

========================================================================
In order to do this with your program, I would add the following assignments in order to simplify the expression list at the end of the PRINT USING statement:

name1$ = "Bob"
name2$ = "Mike"
food1% = 2
food2% = 5
away% = 4
fd1$ = STR$(food1%)
fd2$ = STR$(food2%)
aw0$ = STR$(away%)
aw1$ = STR$(food2% - away%)
aw2$ = STR$(food1% + away%)

However, your string is much too complicated. Here is the first part:

PRINT USING "& has& apples, and & has& apples. "; name1$; fd1$; name2$; fd2$

You can take it from there. However, the entire statement has to be entered on one line if you want it to display that way.



    
This message has been edited by Solitaire1 on Sep 10, 2010 11:27 AM

Posted on Sep 10, 2010, 11:25 AM

Respond to this message   

Return to Index


LET is even older

by Zom-B (Login Zom-B)
R

GWbasic didn't need LET and even Commodore 64 BASIC didn't need it. My guess is that pre-80s basic dialects still required it.

It's a left-over statement from the time that any basic line could only contain a line number+statement, and the statement defines the action taken. Just an assignment is not a statement.

Posted on Sep 12, 2010, 6:08 AM

Respond to this message   

Return to Index


I did say that LET is a legacy command leftover from the "original" version of BASIC.

by Solitaire (Login Solitaire1)
S

Nothing is older that the "original."

GWBASIC was NOT the original, but an offshoot. LET was was required by APPLESOFT BASIC. I know Commodore BASIC didn't need it. I mentioned GWBASIC because it came just before QuickBASIC. It was the same as BASICA, a proprietary version used by genuine IBM computers. BASICA would not run on clone computers because of a slight hardware difference, copyrighted by IBM. The A after BASIC in BASICA stood for "Advanced." GWBASIC was identical except it would run on all compatible computers, not just on IBM.

By the way, I still have a copy of GWBASIC on my computer and I just ran it to make sure that LET was not required.

Posted on Sep 12, 2010, 12:33 PM

Respond to this message   

Return to Index


want to get a screenshot

by codeguy (Login codeguy)
R

i want to get a screenshot from a program of mine onto qb64 screenshot page but am having no luck. i have tried inserting a screen capture sub (the thirtytwobit sub) and doing a capture after a complete round of stuff, but i get nothing. it's fromhttp://www.qb64.net/forum/index.php?topic=1373.msg10468#msg10468 and i want to post a picture of that in all its visual glory. i think it's a nice demo of what qb64 can do and if someone could a) help me get it done or b) submit a screenshot for me, i'd be really grateful. so dammit, pete, put your skillz to work and please give me a power assist as i refuse to submit another failed screenshot. i know the page HATES bmps and it has to be gif (even tried rich geldreich's screen to gif) or jpeg, so any assist you could give me would be terrific!



    
This message has been edited by codeguy on Sep 4, 2010 11:31 PM

Posted on Sep 4, 2010, 11:07 PM

Respond to this message   

Return to Index


Have you tried the Prt Scr button? ...

by (Login qb432l)
R

I have Windows 7, and pressing the Print Screen button still works. Namely, it puts an image of the screen into the clipboard. You then open Windows Paint and click Paste. You may have to crop if your screenshot was in a window, but you can then save in any format you want.

-Bob

Posted on Sep 5, 2010, 1:53 AM

Respond to this message   

Return to Index


Re: Have you tried the Prt Scr button? ...

by codeguy (no login)

thanks! i was trying to put a gif emitter that would do occasional intermittent frame shots for a demo i wrote (see my ugly code for gif emitter on qb64). it emits a gif (gif87a standard) without requiring an include file. as i said, it is ugly code, but beautifully compliant with gif87a. i did get my screenshot uploaded to qb64's screenshot section and it came out nicely.

Posted on Sep 13, 2010, 2:05 AM

Respond to this message   

Return to Index


Where's your code?

by (Login burger2227)
R

You can use Galleon's SaveImage SUB to get the handle of a _NEWIMAGE screen.

The other SUB allows you to get portions of the screen. Did you use _SOURCE 0 or what? I found that if you use a handle you get a different image than the 0 screen. Even go back in time so to speak.

Download this to get fullscreen desktop

http://dl.dropbox.com/u/8440706/printkey510ef.zip

Use the Rectangle to cut out an image. It will look like your desktop, but it is the actual picture taken after you press the Prt Scrn key.

Hold the left button down to draw a box around the area you want. let go when done. It can save as any kind of image.

Ted



    
This message has been edited by burger2227 on Sep 5, 2010 6:48 AM

Posted on Sep 5, 2010, 6:45 AM

Respond to this message   

Return to Index


Come on donny, why don't you ask for the moon while you're at it!

by (Login The-Universe)
Admin


What I do is to post a screen shot here...

1) Run my program and press Prt Scr.

2) Open Paint and select Paste.

3) Save my screen shot as a jpeg.

4) Open a post in the QB64 sub-forum. (You must be signed in to Network54.)

5) Click the Photobucket button: Image Services Photobucket.com

6) In the window that opens, sign in to Photobucket.

7) Upload your image from your computer.

8) Copy and paste the Photobucket link to your image into your post.

9) Write any description in your post and Click the forum Respond button.

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

See, just 9 easy steps! I really think cave painting was faster, oh well.

Pete

PS Oh, I almost forgot.... THE MOON

[linked image]

Posted on Sep 5, 2010, 10:28 AM

Respond to this message   

Return to Index


What's your Gallery address? Never mind....

by Clippy (Login burger2227)
R

[linked image]
I'd love to view that Gallery of images! happy.gif



    
This message has been edited by burger2227 on Sep 5, 2010 2:16 PM

Posted on Sep 5, 2010, 2:15 PM

Respond to this message   

Return to Index


* It is the gallery version of the Bush education act - Gnome Left Behind.

by (Login The-Universe)
Admin

Posted on Sep 5, 2010, 2:28 PM

Respond to this message   

Return to Index


To get a screen shot of your running program---

by Solitaire (Login Solitaire1)
S

Your program must be running in a window.

If you press PrtScr alone, or Ctrl-PrtScr, it will capture the entire screen including the desktop.

To capture only the window with the running program, press Alt-PrtScr.

Posted on Sep 5, 2010, 8:13 PM

Respond to this message   

Return to Index


Re: Come on donny, why don't you ask for the moon while you're at it!

by codeguy (Login codeguy)
R

nice moon, but i'm not much into a$$trology, but thanks for letting me a$$ you a question! my screenshot is finally up there.

Posted on Sep 10, 2010, 11:27 PM

Respond to this message   

Return to Index


About the VAL function

by Solitaire (Login Solitaire1)
S

Someone posted a question to the VBNETNETFORUMS forum. He is trying to write a parsing method that will convert a string into a Double, but will do more than the TryParse method will do. He described several of the requirements as follows:

-------------------------------------------------------------------
"I'm writing my own parsing method to parse a String to a double. I have a lot of requirements of this parsing method, so none of the existing parsing methods actually work.

Here are the requirements:

Like TryParse, on most failures we should return 0. Things like stack overflow and the sort still bubble out.

Unlike TryParse, I don't want to pass the return value as a reference. Instead it just returns the value... like say Convert.ToDouble(...) does.

Accept optional NumberStyles in case the user wants to modify that.

must be able to support leading/trailing whitespace (the strings come from xml so there is no guarantee there isn't leading/trailing whitespace)

must be able to support hex values dynamically... meaning if the numeric value in the string starts with 0x, #, or &H... it automatically drops into hex mode.

Is numeric greedy, meaning that it will read through the string up until it hits the last numeric value and convert that... just cutting off any dangling none numeric values. For instance " 12zzz" return 12 because it just slices off the zzz"
---------------------------------------------------------------------------

He posted the code he wrote so far and asked people to help him optimize it because it's very slow.

Several people responded, posting very complicated code.

It looks to me as if he is trying to emulate the Val() function, and I responded with a small sample. I also made the following comments:

---------------------------------------------------------------------------
Val() will return a type Double number using a string argument.
If the entire string is non-numeric or blank, it will return 0.
It will convert the left part of the string which is numeric and ignore any non-numeric characters after that.
It will ignore any leading, trailing, or inclusive spaces.
It will convert a Hexadecimal value which begins with &H.
---------------------------------------------------------------------------

Is there anything I left out about VAL()? I seem to remember there were several other obscure properties of this function.


Posted on Sep 4, 2010, 3:01 PM

Respond to this message   

Return to Index


* What about 12zzz13aaa145cde? Or Scientific notation?

by (Login burger2227)
R

Posted on Sep 4, 2010, 4:06 PM

Respond to this message   

Return to Index


A suggestion

by (Login Mikrondel)
Moderator

Maybe a hybrid approach will get the desired results?

Rather than finding a built-in function that does ALL the work, or creating a new function that does ALL the work, perhaps it would be enough to simply test whether the string starts with 0x, #, or &H and then pass it on to tryParse or Val or whatever as appropriate.

For example, if it starts with 0x or #, replace that with &H. Then send it on to Val.

Maybe strip off any problematic stuff as well (does Val accept scientific notation? I can't remember).



    
This message has been edited by Mikrondel on Sep 4, 2010 11:41 PM

Posted on Sep 4, 2010, 11:39 PM

Respond to this message   

Return to Index


Yes it does scientific notation, using E or D

by Solitaire (Login Solitaire1)
S

Example:
45E4 or 45D4

I know E is for Exponent, but what is the D for?

Posted on Sep 5, 2010, 5:03 PM

Respond to this message   

Return to Index


Using E or D

by Moneo (no login)

Hi Solitaire,

If I remember correctly from some of Mac's conversion programs, the E is for single-precision exponential forms, and D is for double-precision exponential forms.

Regards..... Moneo

Posted on Sep 7, 2010, 4:36 PM

Respond to this message   

Return to Index


* Ah -- thanks.

by Solitaire (Login Solitaire1)
S

Posted on Sep 7, 2010, 5:37 PM

Respond to this message   

Return to Index


Re: About the VAL function

by codeguy (Login codeguy)
R

create a separate string composed of all the numeric characters from the original string and for every non-numeric character in the original, put space so it's sorta like a numeric-filtered mask.
say you have the string:

"fhv99x&H6693.14159Bananas00068&" (original)
" 99 &H6693.14159 00068 " (all numeric)
"fhv x Bananas &" (all non-numeric)

and then parse away.

i have had to do this to parse code when i wrote a cross-referencer to analyze code. there is no substitute for going through the entire string any way you look at it. that way you can easily separate words from numbers. of course, you have to include logic to filter out multiple decimal points and other conditions.

Posted on Sep 4, 2010, 11:52 PM

Respond to this message   

Return to Index


16 bit DMA sound

by (no login)

Greetings, all!

I'm working on a sound project and while I am able to find many examples of 8-bit .wav playback, I have not yet found any functional 16-bit code to do so...

any suggestions / examples?

Many thanks in advance! :)

Posted on Sep 1, 2010, 4:20 AM

Respond to this message   

Return to Index


* Try QB64. You can play WAV, OGG and MP3 files(see link at top of forum)

by (Login burger2227)
R

Posted on Sep 1, 2010, 9:46 AM

Respond to this message   

Return to Index


Re: * Try QB64. You can play WAV, OGG and MP3 files(see link at top of forum)

by (no login)

Yes, but the rest of the project is written in regular basic, so I'm looking for code I could use in that without having to translate everything over to a new language. Thank you for the suggestion though :)

Posted on Sep 1, 2010, 3:46 PM

Respond to this message   

Return to Index


* Regular Basic? Like what kind is that?

by (Login burger2227)
R

Posted on Sep 1, 2010, 4:12 PM

Respond to this message   

Return to Index


About 20 lines down this page is the example you seek

by Zom-B (Login Zom-B)
R

Posted on Sep 1, 2010, 12:49 PM

Respond to this message   

Return to Index


Re: About 20 lines down this page is the example you seek

by (no login)

I did look at this example and it seems to hang on 16 bit sounds... not sure why.

Posted on Sep 1, 2010, 3:44 PM

Respond to this message   

Return to Index


* WHY tell people to try stuff that YOU CAN'T EVEN GET TO WORK?

by (Login burger2227)
R

Posted on Sep 1, 2010, 5:12 PM

Respond to this message   

Return to Index


donny, quit sitting in the Index. No one is going to steal Collider Worms...

by (Login The-Universe)
Admin

But I did try it out. Nice effects!' Reminds me of something I grew once in mivrobiology, back in my pre-med days. Shortly before the AIDS epidemic broke out, go figure.

For my monitor, I needed to change _FULLSCREEN to _FULLSCREEN _SQUAREPIXELS to get it to display. You might want to add that info to your posts. I'm using an XP, with a 20" 4x3 display/ I also drive an Edsel. I'm pretty proud of it though. Last week I raced Clippy and left jim in the dust. He complained, I know, Clippy complaining? What a stretch.. but back to our story... He complained his arm was too sore to shovel coal fast enough into his vehicle, oh well. I'd tell you more about his arm trouble, but this is a family forum! happy.gif

Pete



    
This message has been edited by The-Universe on Aug 30, 2010 11:22 AM
This message has been edited by The-Universe on Aug 30, 2010 11:14 AM

Posted on Aug 30, 2010, 11:12 AM

Respond to this message   

Return to Index


Re: donny, quit sitting in the Index. No one is going to steal Collider Worms...

by codeguy (Login codeguy)
R

i welcome anyone to steal my code, PLEASE! the original version cleared the screen with each iteration but then someone got the bright idea to NOT clear the screen and it looked like a bunch of worms to them, so that is where i got the idea to rename it collider worms. i'm glad you enjoyed it so much. i figured if nothing else it was a nice twist on an otherwise too-perfect visual presentation. can't do much about it being slow because paint is incredibly syrupy, but given reasonable resolutions, it's a nice effect like you say.



    
This message has been edited by codeguy on Sep 4, 2010 11:07 PM

Posted on Sep 4, 2010, 10:56 PM

Respond to this message   

Return to Index


Cannot post at QB64.net Forum posting down?...

by (Login The-Universe)
Admin


At least it is for me, and I haven't seen any new posts, since I've noticed that. Session timed-oit is the error message.

Anyone else experiencing this problem? If do... Please place QB64 posts here, or in the QB64 sub-forum, if the problem contimues, until the problem is fixed.

Pete

Posted on Aug 30, 2010, 7:02 AM

Respond to this message   

Return to Index


hmm

by Zom-B (Login Zom-B)
R

I just sent Galleon an email reporting this and everything I couldn't do (including even logging out), and it was like this on all my machines at my home.

Then I had an inspiration and cleared my cookies. That worked. It seems something in the forum code screwed up and the cookies became unusable but still active (hmm zombie cookies with brain pâté).

Posted on Aug 30, 2010, 7:22 AM

Respond to this message   

Return to Index


Read this first before clearing cookies

by Zom-B (Login Zom-B)
R

There were a lot of new posts, when I looked at the threads, but "recent posts" page was empty, as you described.

However, after deleting cookies, these threads were no longer flagged as having new replies.

So: Check all the forums, and open all threads with new tab or something before clearing the cookies, otherwise you don't know what's new.

Posted on Aug 30, 2010, 7:27 AM

Respond to this message   

Return to Index


Re: Read this first before clearing cookies

by donny (Login codeguy)
R

i prefer my cookies with a little dirt on them! (jfk)*
* jfk=just f* kidding



    
This message has been edited by codeguy on Sep 5, 2010 12:05 AM

Posted on Sep 4, 2010, 11:30 PM

Respond to this message   

Return to Index


Yes, that worked... but you don't have to clear all cookies...

by (Login The-Universe)
Admin

There is a www.qb64.net cookie with an SMFCookie164....

Just delete it, reenter your loggin and password, and you're good to post again.

Thanks Zom-B for figuring that out.

Pete



    
This message has been edited by The-Universe on Aug 30, 2010 7:33 AM

Posted on Aug 30, 2010, 7:33 AM

Respond to this message   

Return to Index


I FORGOT MY PASSWORD AGAIN

by (Login burger2227)
R

That's just Galleon's feeble attempt to cut down on humorous posts. EVEN if they are not that funny.

Posted on Aug 30, 2010, 8:15 PM

Respond to this message   

Return to Index


Re: I FORGOT MY PASSWORD AGAIN

by Anonymous (Login codeguy)
R

dammit, clippy, it's not paypal or ebay, so there's little reason to do a full logout.

Posted on Sep 4, 2010, 11:09 PM

Respond to this message   

Return to Index


* I NEVER log out anywhere! I'm always connected. That's how Zip got in!

by (Login burger2227)
R

Posted on Sep 7, 2010, 10:53 PM

Respond to this message   

Return to Index


* WHO on earth LOGS OFF and WHY would said person do that?

by (Login burger2227)
R

Posted on Aug 30, 2010, 8:17 PM

Respond to this message   

Return to Index


You get logged off automatically after a set period of time,

by Solitaire (Login Solitaire1)
S

and whenever you switch to another computer.

Posted on Aug 31, 2010, 11:34 AM

Respond to this message   

Return to Index


How to post on QB64 forum

by (no login)

I am recognised on the forum and have a profile. When I log in, I cannot find any way of posting to it. Nowhere can I find a "new topic" or "reply" button. I need to find out how to start the QB64 program now I have downloaded it. Please help.

Posted on Aug 4, 2011, 2:33 PM

Respond to this message   

Return to Index


* Resolved

by (Login burger2227)
R

Posted on Aug 4, 2011, 4:24 PM

Respond to this message   

Return to Index


what INP do i use to get input from soundcard

by (Login codeguy)
R

trying to get values from soundcard in order to do visualization, so if you can get me the right procedure, this would be great -- even though environment BLASTER is set, other examples of getting these values from soundcard are not working, so a general routine would be nice. i was told to leave a msg on this site for artelius.

Posted on Aug 25, 2010, 10:25 AM

Respond to this message   

Return to Index


* What kind of values? Analog sounds?

by (Login burger2227)
R

Posted on Aug 25, 2010, 10:45 AM

Respond to this message   

Return to Index


I'm no expert but

by (Login Mikrondel)
Moderator

to the best of my knowledge, sound has always been too data-heavy to travel by INP/OUT.

The sound data is written to a memory area which the sound card then reads using DMA.

The timing is tight, and I think that trying to snoop this data is a bad idea. Under pure DOS you can maybe hook into the sound card interrupt handler, but in any other case you'd need to interface with the OS API.

I'm not a big fan of the QB64 sound API. I'd prefer it to simply provide a facility to let you play raw digitised sound samples. That would (among other things) make what you want easier to do.

Posted on Aug 28, 2010, 1:22 AM

Respond to this message   

Return to Index


artelius, you're right

by (Login codeguy)
R

it was an idea i thought with the speed of qb64 exe's would be practical, but there's not a whole lot i can do about the complexity. but at least someone gained an FFT that works in the process. i was going to use that to measure the relative sound intensities and use the result of the fft to bounce some stuff around in sync with the intensity of the sound. thanks again for all your advice and i will know that this isn't something i should mess with in qb64. and besides, with win7, microsoft has added crappy drm that disallows (at least qb64) reading output directly from my soundcard.

Posted on Aug 28, 2010, 7:36 AM

Respond to this message   

Return to Index


*Well don't just sit there in the Index, codeguy. Post something and edit it!

by Pete (no login)

Posted on Aug 28, 2010, 11:18 AM

Respond to this message   

Return to Index


This might be helpful

by Zom-B (no login)

This is a pure-dos wav player that displays FFT bars of the sound it plays. It uses the BLASTER env. I haven't used it recently but a quick run in dosbox failed (visuals worked but no audio). Maybe you can do something with this.

DECLARE SUB fft.calc (x() AS ANY, w() AS ANY)
DECLARE FUNCTION dsp.reset% ()
DECLARE SUB dsp.dmaplay ()
DECLARE SUB getblaster ()
DECLARE SUB init.sb ()
DECLARE SUB init.screen ()
DECLARE SUB openwavfile (filename$)
DECLARE FUNCTION checkcommand$ ()
DECLARE SUB commandline ()
DEFINT A-Z
RANDOMIZE TIMER

'イイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイ constants

fftsize = 7

CONST empty = " "
CONST pi5 = 6.283185
CONST l2 = .6931472

CONST nowav = -1
CONST iswav = 0
CONST pcm = 1

'イイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイ definitions

TYPE wav
rID AS STRING * 4 'Contains the characters "RIFF"
rLen AS LONG 'The length of the data in the next chunk
wID AS STRING * 4 'Contains the characters "WAVE"
fID AS STRING * 4 'Contains the characters "fmt"
fLen AS LONG 'Length of data in the format chunk
wFormatTag AS INTEGER 'This specifies the wave format
nChannels AS INTEGER 'Number of channels, 1=mono, 2=stereo
nSamplesPerSec AS LONG 'Playback frequency
nBytesPerSec AS LONG 'Indicates the average number of wav.nBlockAlign a second
nBlockAlign AS INTEGER 'Indicates the block alignment of the data in the data chunk
FormatSpecific AS INTEGER 'Format specific data area
dID AS STRING * 4 'Contains the characters "data"
dLen AS LONG 'Length of data in the dData field
END TYPE
TYPE sb
port AS INTEGER
irq AS INTEGER
dma AS INTEGER
C AS INTEGER
END TYPE
TYPE dmap
page AS INTEGER
addr AS INTEGER
length AS INTEGER
mask AS INTEGER
mode AS INTEGER
clr AS INTEGER
status AS INTEGER
terminal AS INTEGER
END TYPE
TYPE buff
buffer AS STRING * 21740
freq AS LONG
timeconst AS INTEGER
END TYPE
TYPE complex
x AS SINGLE
y AS SINGLE
END TYPE

DIM SHARED wav AS wav
DIM SHARED sb AS sb
DIM SHARED dmap AS dmap
DIM SHARED buff AS buff

DIM SHARED overridebits, overridechannels, overridefreq

DIM SHARED buffer, num, num2
DIM SHARED ln2, dt AS SINGLE, barsize
DIM SHARED infile$, tijd, start AS LONG

REDIM SHARED x(1) AS complex
REDIM SHARED w(1) AS complex
REDIM SHARED fftw(1) AS SINGLE
REDIM SHARED t(1) AS complex
REDIM SHARED bar(1) AS SINGLE

'イイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイ init

filename$ = checkcommand$

init.sb

openwavfile filename$

init.screen

GOSUB resetall

'イイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイ main

tt! = 0
totaltime! = TIMER

temp = buffer: buffer = 0
dsp.dmaplay
buffer = temp

a$ = " "
WHILE NOT EOF(1)
FOR n = 0 TO buffer
GET 1, 1 + wav.nBlockAlign * (start + n), infile$
IF wav.FormatSpecific = 16 THEN
y = CVI(infile$)
IF n < num THEN x(n).x = y / 32768
MID$(buff.buffer, n + 1, 1) = CHR$(((y \ 256) + 128) AND 255)
ELSE
IF n < num THEN x(n).x = ASC(infile$) / 128 - 1
MID$(buff.buffer, n + 1, 1) = infile$
END IF
NEXT
FOR n = 0 TO num - 1
x(n).x = x(n).x * fftw(n)
x(n).y = 0
NEXT
start = start + buffer - 1

nn = 0
partitialtime! = TIMER

DMADone = 0
DO
bytes& = INP(dmap.length) + 256& * INP(dmap.length)
IF bytes& = 65535 THEN JUNK = INP(0): DMADone = 1 ELSE nn = 1
IF bytes& > 868 THEN i$ = INKEY$: IF i$ <> "" THEN GOSUB checkkey
LOOP UNTIL DMADone

dsp.dmaplay
tijd! = TIMER

IF tijd! < partitialtime! THEN partitialtime! = partitialtime! - 86400
partitialtotal! = partitialtotal! + (tijd! - partitialtime!)
total! = (tijd! - totaltime!)
IF nn = 0 THEN
GOSUB resettime
e = e + 1
LOCATE 29, 8: PRINT e;
COLOR 12
END IF
LOCATE 25, 7: PRINT total!; empty
LOCATE 26, 11: PRINT partitialtotal!; empty
IF total! > 0 THEN LOCATE 27, 9: PRINT partitialtotal! / total! * 100; empty
LOCATE 28, 6: PRINT (tijd! - partitialtime!); empty
COLOR 15
LOCATE 24, 6: PRINT start \ buff.freq; "/"; tijd; empty

fft.calc x(), w()
WEND
END

'イイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイ handle keyboard

checkkey:
SELECT CASE i$
CASE CHR$(0) + "K": IF fftsize > 5 THEN fftsize = fftsize - 1: GOSUB resetall
CASE CHR$(0) + "M": IF fftsize < 9 THEN fftsize = fftsize + 1: GOSUB resetall
CASE CHR$(0) + "P": IF fps > 2 THEN fps = fps - 1: GOSUB resetnum
CASE CHR$(0) + "H": IF fps < 70 THEN fps = fps + 1: GOSUB resetnum
CASE CHR$(0) + "s": start = start - buff.freq * 5: IF start < 44 THEN start = 44
CASE CHR$(0) + "t": start = start + buff.freq * 5
CASE " ": LOCATE 24, 16: PRINT "Paused": i$ = INPUT$(1)
CASE "": END
END SELECT
RETURN

'イイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイイ layered resets

resetall:
SELECT CASE fftsize
CASE 9: fps = 3
CASE 8: fps = 7
CASE 7: fps = 14
CASE 6: fps = 28
CASE 5: fps = 50
END SELECT

resetnum:
num = 2 ^ fftsize
num2 = num \ 2

buffer = buff.freq \ fps


REDIM x(num - 1) AS complex
REDIM w(num - 1) AS complex
REDIM fftw(num - 1) AS SINGLE
REDIM t(num - 1) AS complex
REDIM SHARED bar(num2) AS SINGLE

dt = pi5 / num
barsize = 638 \ num2
ln2 = CINT(LOG(num) / l2) 'Number of bits in num

FOR n = 0 TO num - 1
dn! = -dt * n
w(n).x = COS(dn!)
w(n).y = SIN(dn!)
NEXT

FOR n = 0 TO num - 1
fftw(n) = .5 * (1 - COS(pi5 * n / (num - 1)))
NEXT

LOCATE 22, 5: PRINT fps
LOCATE 23, 5: PRINT num2


init.screen

resettime:
partitialtotal! = 0
totaltime! = TIMER
total! = 1
RETURN


'DMA table
'
0 DATA &h87,&h00,&h01,&h0A,&h0B,&h0C,&h08,&h01
1 DATA &h83,&h02,&h03,&h0A,&h0B,&h0C,&h08,&h02
2 DATA &h81,&h04,&h05,&h0A,&h0B,&h0C,&h08,&h04
3 DATA &h82,&h06,&h07,&h0A,&h0B,&h0C,&h08,&h08
4 DATA &h8F,&hC0,&hC2,&hD4,&hD6,&hD8,&hD0,&h01
5 DATA &h8B,&hC4,&hC6,&hD4,&hD6,&hD8,&hD0,&h02
6 DATA &h89,&hC8,&hCA,&hD4,&hD6,&hD8,&hD0,&h04
7 DATA &h8A,&hCC,&hCE,&hD4,&hD6,&hD8,&hD0,&h08

FUNCTION checkcommand$
DIM p(2) AS STRING * 5

a$ = COMMAND$
IF a$ = "" THEN commandline

x = INSTR(a$, " ") + 1

IF x > 1 THEN
b$ = ""
FOR y = x TO LEN(a$) + 1
m$ = MID$(a$, y, 1)
IF m$ = " " OR LEN(m$) = 0 THEN
IF ASC(p(0)) = 0 THEN
p(0) = b$
ELSE
IF ASC(p(1)) = 0 THEN
p(1) = b$
ELSE
IF ASC(p(2)) = 0 THEN p(2) = b$
END IF
END IF
b$ = ""
ELSE
b$ = b$ + m$
END IF
NEXT

overridebits = 0
overridechannels = 0
overridefreq = 0
FOR a = 0 TO 2
SELECT CASE p(a)
CASE "M ": overridechannels = 1
CASE "S ": overridechannels = 2
CASE "8 ": overridebits = 8
CASE "16 ": overridebits = 16
CASE ELSE
y = VAL(p(a))
IF y >= 4000 AND y <= 65535 THEN overridefreq = y
END SELECT
NEXT

a$ = LEFT$(a$, x - 2)
END IF

checkcommand$ = a$
END FUNCTION

SUB commandline
PRINT "FFT3 - Wave audio player with FFT spectrum analyzer - (C) 2000 by Digisoft Corp."
PRINT
PRINT "FFT3 <filename> [8|16] [M|S] [####]"
PRINT
PRINT "Options: 8 - Override 8-bits mode"
PRINT " 16- Override 16-bits mode"
PRINT " M - Override Mono mode"
PRINT " S - Override Stereo mode"
PRINT " #### - Number from 4000 to 65535: Override playing frequency"
PRINT
PRINT "Controls:  - Smaller FFT spectrom analyzer"
PRINT " " + CHR$(26) + " - Larger FFT spectrom analyzer"
PRINT "  - More fps"
PRINT "  - Less fps"
PRINT " ALT+ - Rewind 5 playing seconds"
PRINT " ALT+" + CHR$(26) + " - FForward 5 playing seconds"
PRINT " SPACE - Pause"
PRINT " ESC - End"
PRINT
PRINT "Note: fps resets to factory default when FFT size changes."
PRINT
END
END SUB

SUB dsp.dmaplay
memloc& = VARSEG(buff.buffer) * 16& + VARPTR(buff.buffer)
memlocaddr& = VARPTR(memloc&)
bufferaddr = VARPTR(buffer)
bufferaddrlo = PEEK(bufferaddr)
bufferaddrhi = PEEK(bufferaddr + 1)



OUT dmap.mask, &H4 + sb.dma
OUT dmap.clr, &H0
OUT dmap.mode, 72 + sb.dma
OUT dmap.addr, PEEK(memlocaddr&)
OUT dmap.addr, PEEK(memlocaddr&)
OUT dmap.page, PEEK(memlocaddr& + 1)
OUT dmap.length, bufferaddrlo
OUT dmap.length, bufferaddrhi
OUT dmap.mask, sb.dma


'every time
WAIT sb.C, &H80, &H80: OUT sb.C, &H14
WAIT sb.C, &H80, &H80: OUT sb.C, bufferaddrlo
WAIT sb.C, &H80, &H80: OUT sb.C, bufferaddrhi
END SUB

FUNCTION dsp.reset
dsp.reset = 0

OUT sb.port + 6, 1
FOR a = 1 TO 4
b = INP(sb.port + 6)
NEXT
OUT sb.port + 6, 0

tijd! = TIMER: WHILE TIMER = tijd!: WEND
tijd! = TIMER
WHILE TIMER = tijd!
IF (INP(sb.port + 14) AND &H80) = &H80 AND INP(sb.port + 10) = &HAA THEN dsp.reset = -1: EXIT FUNCTION
WEND
END FUNCTION

SUB fft.calc (x() AS complex, w() AS complex)
FOR n = 0 TO num - 1
t(n) = x(n)
NEXT
FOR n = 0 TO num - 1
x = n
a = 0
FOR C = ln2 - 1 TO 0 STEP -1
cc = 2 ^ C
IF x >= cc THEN x = x - cc: a = a + 2 ^ (ln2 - C - 1)
NEXT
x(a) = t(n)
NEXT
FOR C = 0 TO ln2 - 1
cc = 2 ^ C
ccc = 2 ^ (ln2 - C - 1)
FOR n = 0 TO num - 1
t(n) = x(n)
NEXT
FOR d = 0 TO num - 1 STEP cc + cc
FOR e = 0 TO cc - 1
a = d + e
b = a + cc
p = ccc * e
wx! = t(b).x * w(p).x - t(b).y * w(p).y
wy! = t(b).y * w(p).x + t(b).x * w(p).y
x(a).x = t(a).x + wx!
x(a).y = t(a).y + wy!
x(b).x = t(a).x - wx!
x(b).y = t(a).y - wy!
NEXT
NEXT
NEXT
FOR n = 1 TO num2
LINE (n * barsize, 0)-STEP(0, bar(n)), 0, , &HAAAA
bar(n) = SQR(x(n).x * x(n).x + x(n).y * x(n).y) / num2
IF n > 0 THEN bar(n) = bar(n) * n
IF bar(n) > 1 THEN C = 13 ELSE C = 10
LINE (n * barsize, 0)-STEP(0, bar(n)), C, , &HAAAA
NEXT
END SUB

SUB getblaster
IF LEN(ENVIRON$("BLASTER")) = 0 THEN PRINT "BLASTER environment variable not set.": EXIT SUB

x = INSTR(ENVIRON$("BLASTER"), "A")
sb.port = VAL("&H" + MID$(ENVIRON$("BLASTER"), x + 1, 3))

x = INSTR(ENVIRON$("BLASTER"), "I")
sb.irq = VAL("&H" + MID$(ENVIRON$("BLASTER"), x + 1, 3))

x = INSTR(ENVIRON$("BLASTER"), "D")
sb.dma = VAL("&H" + MID$(ENVIRON$("BLASTER"), x + 1, 3))

FOR n = 0 TO sb.dma
READ dmap.page, dmap.addr, dmap.length, dmap.mask, dmap.mode, dmap.clr, dmap.status, dmap.terminal
NEXT

sb.C = sb.port + &HC
END SUB

SUB init.sb
getblaster

IF NOT dsp.reset THEN PRINT "DSP failed to reset.": END
PRINT
END SUB

SUB init.screen
SCREEN 12: CLS
VIEW (0, 1)-(639, 319), , 8
WINDOW (0, 0)-(639, 1)
LINE (0, .5)-STEP(639, 0), 8
COLOR 8
LOCATE 25, 1: PRINT "total:"
LOCATE 26, 1: PRINT "partitial:"
LOCATE 27, 1: PRINT "percent:"
LOCATE 28, 1: PRINT "last:"
COLOR 15
LOCATE 29, 1: PRINT "Errors:";
LOCATE 22, 1: PRINT "fps:"
LOCATE 23, 1: PRINT "num:"
LOCATE 24, 1: PRINT "Tijd: "
END SUB

SUB openwavfile (filename$)
OPEN "b", 1, filename$

filetype = nowav

IF UCASE$(RIGHT$(filename$, 3)) = "PCM" THEN filetype = pcm
IF UCASE$(RIGHT$(filename$, 3)) = "WAV" THEN filetype = iswav

IF filetype <> pcm THEN
GET 1, 1, wav

IF wav.rID <> "RIFF" OR wav.wID <> "WAVE" OR wav.fID <> "fmt " OR wav.dID <> "data" THEN
filetype = nowav
END IF

IF wav.wFormatTag <> 1 AND filetype = iswav THEN
PRINT "Can't play a compressed, non-PCM or headerless wav file"

PRINT "Override? (Y/N)"
DO
i$ = UCASE$(INKEY$)
LOOP UNTIL INSTR("YN", i$)
IF i$ <> "Y" THEN END

filetype = nowav
END IF
END IF

IF filetype <> iswav THEN
IF overridechannels THEN
wav.nChannels = overridechannels
ELSE
PRINT "Channels? (1/2) [2]"
DO
i$ = LEFT$(INKEY$ + "", 1)
LOOP UNTIL INSTR("12" + CHR$(13), i$)
IF i$ = "" THEN END
IF i$ = CHR$(13) THEN i$ = "2"
wav.nChannels = VAL(i$)
END IF

IF overridebits THEN
wav.FormatSpecific = overridebits
ELSE
PRINT "Bytes per sample? (1/2) [2]"
DO
i$ = LEFT$(INKEY$ + "", 1)
LOOP UNTIL INSTR("12" + CHR$(13), i$)
IF i$ = "" THEN END
IF i$ = CHR$(13) THEN i$ = "2"
wav.FormatSpecific = VAL(i$) * 8
END IF

IF overridefreq THEN
wav.nSamplesPerSec = overridefreq
ELSE
PRINT "Frequency (4000 to 65535) [44100] ?"
DO
LOCATE CSRLIN - 1, 37
INPUT i$
IF i$ = "" THEN i$ = "44100"
wav.nSamplesPerSec = VAL(i$)
LOOP WHILE wav.nSamplesPerSec < 4000 OR wav.nSamplesPerSec > 65535
END IF

wav.nBlockAlign = wav.nChannels * wav.FormatSpecific \ 8
END IF

buff.timeconst = 256 - 1000000 / (wav.nSamplesPerSec * wav.nChannels)
buff.freq = (1000000 / (256 - buff.timeconst)) / wav.nChannels

start = 44 \ wav.nBlockAlign
tijd = wav.dLen / buff.freq / wav.nBlockAlign
infile$ = SPACE$(wav.FormatSpecific / 8)

WAIT sb.C, &H80, &H80: OUT sb.C, &H40
WAIT sb.C, &H80, &H80: OUT sb.C, buff.timeconst
END SUB

Posted on Aug 28, 2010, 2:16 PM

Respond to this message   

Return to Index


I thought professional programmers indented their code?

by Pete (no login)

Hi Zom-B,

Maybe it's been too long for you to remember, but N54 doesn't preserve spaces in posts. If you have a Network54 user name, I can add you to the "R" group. That will at least allow you to edit your post, but to get indented code, you will need to open your code in WordPad, and do a global replace, Ctrl + H, to replace 2-spaces with Alt + 0160 Alt + 0160 on the numbers pad:

This
 is
  an
   example.

Thanks for posting it though,

Pete

- Network54, so simple... a caveman "did" do it.



    
This message has been edited by The-Universe on Aug 28, 2010 3:11 PM

Posted on Aug 28, 2010, 3:05 PM

Respond to this message   

Return to Index


You once said you dont indent your code

by Ben (no login)

Posted on Aug 28, 2010, 5:57 PM

Respond to this message   

Return to Index


But I do use asterisks for blank posts... and apostrophes for contractions.

by (Login The-Universe)
Admin

But it's true, I don't indent. I just finished converting a smaller 810K program from QN to QB64, and it doesn't have any indented code.

I also used to code in all caps, but I'm nor so rigid about that anymore.

Mac, who was a professional programmer, was surprised that I just do this stuff as a sideline. The thing is, I like building stuff, but I really don't care about a lot of the math involved in some aspects of it. I went through college trig, but I never took calc, probability, or other more advanced mathematics courses. I enjoyed inorganic chemistry, biology, physiology, anatomy, kinesiology, and similar courses, better.

I did make an algorithm, when I was 20, that correctly calculated mortgage amortization schedules. That was fun. I remember experimenting with geometric progressions, until I finally got it right. I used it later, when I got my first computer, and discovered it was within pennies of what other computer programs, written by professionals, reported.

In regard to Zom-B, he is a professional programmer, and he was one of the first QB coders to grace this forum nearly ten years ago. I think it's really cool to have him back, thanks to the QB64 project. I would like N54 to get it together and improve the forum engine. They are really in the Dark Ages when it comes to tech I'm afraid. By now, you think they would have put together an upgrade, that would allow preserved spacing within a code box and a few other features that are common to other forums. This is one of my reasons I would rather see this forum combined with Galleon's, so we could have an easier time posting code.

Pete

Posted on Aug 28, 2010, 8:47 PM

Respond to this message   

Return to Index


I thought I had to use a kind of bbcode tag to keep indentation on this forum.

by Zom-B (Login Zom-B)
R

but I couldn't remember if that was the case.

Also, when I copy the indented spaces you just used in your example, they're just , so the forum replaces them with normal spaces.

I don't really care about indentation in forums anymore as the QB64 IDE redoes the indentation anyway, but of course this is not true for most of the other users here.

My forum name is just Zom-B. You can add me to that group of yours if you like, Pete.

Posted on Aug 30, 2010, 7:19 AM

Respond to this message   

Return to Index


Ahoy matey, you're in the "R" Group.

by (Login The-Universe)
Admin


You eye-patch will arrive in your inbox, shortly. Well, now you can edit posts and I'm glad the indentation thing doesn't upset you.

The "R" Group was here, by the way, when Mac, who passed away a few years ago, managed this forum. I don't know how things were handled before that. I learned when Mac issued the account to me, that the "R" in 'R" Groups stood for the Network54 keyword "Revise" Group. Mac loved to keep things simple, hence the name "R" Group, but it always makes me think of pirates, go figure.

So welcome aboard our sinking row boat (Artelius compared the QB Forum once to a sinking row boat... but stated his forum was a sinking sail boat... How's that sail working out now, 1-star? Blub, blub, blub.) But seriously, he is an excellent programmer and would have my vote to run this or any other QB forum, any day, except today, because I'm golfing, and Tuesday is the Senior Dollar menu at Denny's.

Pete

Posted on Aug 30, 2010, 10:43 AM

Respond to this message   

Return to Index


*Thanks, but I still can't edit that message because i wasn't logged in when I posted it.

by Zom-B (Login Zom-B)
R



    
This message has been edited by Zom-B on Aug 31, 2010 4:43 AM
This message has been edited by Zom-B on Aug 31, 2010 4:43 AM

Posted on Aug 31, 2010, 4:35 AM

Respond to this message   

Return to Index


Re: Ahoy matey, you're in the "R" Group.

by codeguy (Login codeguy)
R

you sure that's not the argh! group?

Posted on Sep 4, 2010, 11:12 PM

Respond to this message   

Return to Index


* Indentation also messes up comment alignment. I think I'll start another Crusade. :-P

by (Login burger2227)
R

Posted on Aug 30, 2010, 8:20 PM

Respond to this message   

Return to Index


Re: I thought professional programmers indented their code?

by codeguy (Login codeguy)
R

i prefer indented code as it's much easier for my adhd mind to follow.

Posted on Sep 5, 2010, 12:08 AM

Respond to this message   

Return to Index


One of these would be way cooler (*URL)

by (Login Mikrondel)
Moderator

Posted on Aug 31, 2010, 1:16 AM

Respond to this message   

Return to Index


This is still cooler

by Zom-B (Login Zom-B)
R

Posted on Aug 31, 2010, 4:38 AM

Respond to this message   

Return to Index


to add to matrixs

by (no login)

I am new to programming, i want to calcuate 2 sets of matirx a and b and put the result in c using multi dimensional arrays, i require some body to help me in same.

Posted on Aug 21, 2010, 12:38 AM

Respond to this message   

Return to Index


Read the Homework Policy (one of the top-right links) and search....

by Pete (no login)


http://www.network54.com/Forum/13959/search?searchterm=multidimensional+arrays&sort=match

Posted on Aug 21, 2010, 4:47 AM

Respond to this message   

Return to Index


need help in calculating matrix

by (no login)

Dear Mark,
Thank you, i have posted my code below, i am new to programming and i am getting to next level i have posted the code below, i need some guidance in calucating the matrix.
need help
Thank you


CLS
DIM a(2, 2)
INPUT "enter the number of row", r
INPUT "enter the number of col", c
FOR i = 1 TO r
FOR j = 1 TO c
INPUT a(i, j)
NEXT j
NEXT i
DIM b(2, 2)
INPUT "enter the number of row", r1
INPUT "enter the number of col", c1
FOR k = 1 TO r1
FOR l = 1 TO c1
INPUT b(k, l)
NEXT l
NEXT k
" i am getting stuck here i do not how to calcuate
dim c(2,2)
add rows and add colums and print the result
for .....
for ...
print c

Posted on Aug 22, 2010, 7:16 AM

Respond to this message   

Return to Index


sorry

by Anonymous (no login)

Sorry , i wanted to say thank you for pete

Posted on Aug 22, 2010, 7:17 AM

Respond to this message   

Return to Index


Just use a loop like you did earlier

by qbguy (no login)

Your input code is wrong -- it should dimension A and B after getting the number of rows. Also you can only add matrices when they both have the same dimensions.

CLS
INPUT "enter the number of row", r
INPUT "enter the number of col", c
DIM a(r,c), b(r,c), c(r,c)
FOR i = 1 TO r
FOR j = 1 TO c
INPUT a(i, j)
NEXT j
NEXT i
' you don't need to get the dimensions for the second matrix
FOR k = 1 TO r1
FOR l = 1 TO c1
INPUT b(k, l)
NEXT l
NEXT k

Then to calculate the sum of the two matrices use a loop like you did earlier
FOR i = 1 TO r
FOR j = 1 TO c
c(i,j) = ... ' figure out how to calculate the new entry
PRINT c(i,j);
NEXT j
PRINT
NEXT i

Posted on Aug 22, 2010, 7:36 AM

Respond to this message   

Return to Index


*For graphics, animation, and color, there's TheBOB. For everything else, there's qbguy.

by MasterCard (no login)

Posted on Aug 22, 2010, 9:55 AM

Respond to this message   

Return to Index


Phylo - Do you remember where your movable windows program is located?

by Pete (no login)


It was part of a "Moving Window Experiment" that I posted here...

http://www.network54.com/Forum/190883/thread/1230456207/Moving+Window+Experiment---

But I believe the topic also got posted in another subforum. You nade a program with three overlapping dragable windows. I'm interested in finding it, because a person at QB64 is attempting a similar project. I posted my example over there, and linked bak to ones made by Artelius and Ben, but I can't seem to find your demo.

Thanks,

Pete

Posted on Aug 19, 2010, 4:27 AM

Respond to this message   

Return to Index


Pete

by Ben (no login)

regarding window moving, i was wondering if this works on your computer Windows XP

you have to change tof ullscreen first in QBasic, ALT+ENTER
then move the window to the top left corner. it should be smooth pxp


DEFINT A-Z
DIM mb, mx, my
DIM a(6) AS LONG
a(0) = &H8BE58955
a(1) = &H33CD0C46
a(2) = &H890A768B
a(3) = &H8768B1C
a(4) = &H768B0C89
a(5) = &H5D148906
a(6) = &H8CA
DEF SEG = VARSEG(a(0))

SCREEN 0
CLS
CALL absolute(BYVAL 1, mb, mx, my, VARPTR(a(0)))

LOCATE 15, 50: COLOR 15, 1
PRINT " Windows XP" + SPACE$(10) + "_ [] X"
LOCATE , 50: COLOR 0, 7
PRINT SPACE$(27)
LOCATE , 50
PRINT SPACE$(27)
LOCATE , 50
PRINT " Windows encountered " + SPACE$(6)
LOCATE , 50
PRINT " and illegal operation" + SPACE$(5)
LOCATE , 50
PRINT " Drag me!!!" + SPACE$(16)
LOCATE , 50
PRINT SPACE$(27)
LOCATE , 50
PRINT SPACE$(27)
'OUT &H3D4, &H8
x = 0
y = 0
DO
CALL absolute(BYVAL 3, mb, mx, my, VARPTR(a(0)))

IF mb = 1 THEN
ox = mx + x
oy = my + y

DO
CALL absolute(BYVAL 3, mb, mx, my, VARPTR(a(0)))
x = ox - mx
y = oy - my

s = (y \ 15) * 80& + x \ 8
OUT &H3D4, &HC
OUT &H3D5, s \ 256
OUT &H3D4, &HD
OUT &H3D5, s

OUT &H3D4, &H8
OUT &H3D5, y MOD 15

d = INP(&H3DA)
OUT &H3C0, &H33
OUT &H3C0, x MOD 8
LOOP WHILE mb = 1

END IF
OUT &H3D4, &H8
OUT &H3D5, 0

LOOP UNTIL INP(&H60) = 1
SYSTEM

Posted on Aug 19, 2010, 3:19 PM

Respond to this message   

Return to Index


Just put SCREEN 12 before SCREEN 0 to get fullscreen 0

by Clippy (Login burger2227)
R

Works good, but the cursor should stay with the Window instead of going on ahead like an Indian scout.



    
This message has been edited by burger2227 on Aug 19, 2010 10:15 PM

Posted on Aug 19, 2010, 10:10 PM

Respond to this message   

Return to Index


Same results as Clippy...

by Pete (no login)


The window catches up to the mouse pointer, instead of the pointer staying with the window. The window also will split and appear on the other half of the screen when pulled to an edge.

The coding method is interesting, to say the least. I think you developed a sound alternative to the more commonly used mouse routines.

Pete

Posted on Aug 20, 2010, 3:06 AM

Respond to this message   

Return to Index


Point is...

by Ben (no login)

when draggin some things in screen 0 it will move it in incrememnts of the character size, like 8 pixels left / right 15 pixels down. But here I attempt to move character smooth 1 pixel at a time in screen 0. it have run full screen mode

Posted on Aug 20, 2010, 9:46 AM

Respond to this message   

Return to Index


Windows still has us beat...

by Pete (no login)


Drag any window on an XP desktop and you can't get that mouse pointer off the drag point, it's that fast.

Ben, if your example could stop the wrap effect so the window would just vanish into a side without re-appearing on the other side, that would be a step closer to a real moving window application. Of course if you are only demonstrating a point, great. I'm not trying to goad you into building it into a purposeful application (hehe). Well, that's how I goad TheBOB, but I digress, oops, I hear the mailman coming... Oh that's OK, the wife's got it. So as I was stating, great job, and if you want to check out some of the similar stuff posted at qb64.net, the link is...

http://www.qb64.net/forum/index.php?topic=742.0

Pete

Posted on Aug 20, 2010, 10:45 AM

Respond to this message   

Return to Index


Re: Windows still has us beat...

by Ben (no login)

In my program, the reason mouse pointer not in mosue window is cause the mouse coordinate different system it has to be divided by 8 in screen 0 but i didnt divided by eight so it 640x200 mouse

Posted on Aug 20, 2010, 11:20 AM

Respond to this message   

Return to Index


I just used Ben's mouse for this (link)

by Clippy (Login burger2227)
R

Posted on Aug 20, 2010, 10:55 AM

Respond to this message   

Return to Index


Nice, but you might want to go back...

by Pete (no login)


and edit in "Mouse routine from Ben."

Pete

PS I still would rather have one forum in the future, the QB64 one, but I do think these two forums have been working well together. There is also the ability to post screen shots here, which was discontinued at QB64.net. I think that screenshot of you (Clippy) in a Speedo was the reason Galleon removed that feature. Now get to the gym, you skinny paper clip! :)

Posted on Aug 20, 2010, 11:06 AM

Respond to this message   

Return to Index


no need to credit mouse routine

by Ben (no login)

it's just mouse routine. But he did steal the entire centroid program from the qb64 forum

Posted on Aug 20, 2010, 11:11 AM

Respond to this message   

Return to Index


I gave credit, but Zom-B stole it from somebody else too!

by Clippy (Login burger2227)
R

I had a bit of effort making it work in QB. Overflows, original was SCREEN 12(no page flipping like in QB64), etc.

What is up with N54? EVERY post I have to fill in my Name again and the email doesn't come until I type "b" in the box! Are those people monkeys or what? STILL messing with it!

Posted on Aug 20, 2010, 11:21 AM

Respond to this message   

Return to Index


Don't get me started....

by Pete (no login)


Everything else evolves in this industry except this forum hosting service. I had to make three reposts to correct code errors placed by that darn <> bug a few days ago. It took me longer to post than it did to write the code. :(

And speaking of evolution, they are not monkeys, but given 1,000,000 or so years from now, this statement may not be valid. (I needed to clarify that, since this forum will probably still be here and I don't want Zom-B correcting me when it happens.)

Pete

Posted on Aug 20, 2010, 12:58 PM

Respond to this message   

Return to Index


*It's not my program. Dick made it with an algorithm from Wikipedia and I added mouse.

by Zom-B (no login)

*

Posted on Aug 23, 2010, 1:25 PM

Respond to this message   

Return to Index


Here you go

by (Login PhyloGenesis)
Moderator

I posted this code on the programs you are proud of forum:
http://www.network54.com/Forum/178387/message/1230549828/last-1230549828/OO+Window+Dragger

I added a response to that with my QB64 compatible version (uses _MOUSE instead of CALL ABSOLUTE stuff).

Thanks for remembering it! I was quite proud of how well it worked (on QB64 anyway >.
PhyloGenesis

Posted on Oct 26, 2010, 12:39 AM

Respond to this message   

Return to Index

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