LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 598 users online 221673 members 937 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Solomon Grundy
Favs: The Redemption of Althalus by David Eddi...
Mood: Scheming
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
10 online / 12 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

Simple humour with BASIC
and what should I do with arrays
Replies: 12Last Post Dec. 9, 2004 11:56am by squirellplayingtag
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( penguincube )


1839

Patron
Reply
I'm sure I'm not the first person to do this, but one day it just popped into my head to make MAD LIBS on QBASIC.  It's really *really* easy to do and you can make someone laugh!

Code:

LIBS:
CLS
PRINT "Welcome to Mad Libs.  Please type in a word that matches"
PRINT "what I ask for, then we'll make a funny paragraph!"
PRINT ""
INPUT "Plural Noun"; liba$
INPUT "Colour"; libb$
INPUT "Plural Article of Clothing"; libc$
INPUT "Something you don't care about"; libd$
INPUT "A foreign country"; libe$
INPUT "Your last name"; libf$
PRINT ""
PRINT ""
PRINT "The Congress is made up of two houses: The Senate and the"
PRINT "House of "; liba$; ".  When Congress is in Session, they all wear"
PRINT libb$; " "; libc$; " and they debate important issues, such as"
PRINT libd$; ".  They meet in  "; libe$; " ,because their jobs were outsourced"
PRINT "under President "; libf$
INPUT ""; anykey$

Also, in a program that I have to make for school, we have to use arrays.  I know how to load data into arrays, bubble sort them, print them out and stuff, but I just don't want to make a program that is just like "Hey, this is an array.  Type some numbers."  Do you know have any creative or fun uses for arrays?

-------
firman consensus facit


8:02 am on Dec. 2, 2004 | Joined: May 2003 | Days Active: 1,347
Join to learn more about penguincube Florida, United States | GLBT Ally Male | Posts: 14,869 | Points: 36,909
LiveWire Humor
lacunacoil

Dairy Product Addict
Reply
righttt...

-------
Change your signature.
-Moderator

8:16 am on Dec. 2, 2004 | Joined: Oct. 2004 | Days Active: 239
Join to learn more about lacunacoil Ontario, Canada | Straight Female | Posts: 4,570 | Points: 6,804
squirellplayingtag


Dairy Product Addict

Patron
Reply
I remember the first time I made madlibs with javascript. I barely knew html let alone javascript(what I coded it in). It took me serveral hours which would now take me 5-10 mins. I then later tried to make one on the calculator. The code looked very similar to that (TI83+'s language is BASIC) except it was about 5 times as long because I still blew at programing.

Props to you.

EDIT: The array's part. I made a blackjack game that pulled cards out of an array. You could do something like that but print something like "King" instead of a picture. That has a good amount of logic involved in it too.

(Edited by squirellplayingtag at 9:28 pm on Dec. 2, 2004)

-------
"The most abundant element in the universe is
hydrogen, then second is stupidity."-Harlan Ellison
"What good fortune for our governments that the
people do not think."-Hitler


6:24 pm on Dec. 2, 2004 | Joined: Jan. 2003 | Days Active: 1,260
Join to learn more about squirellplayingtag Maryland, United States | Straight Male | Posts: 6,458 | Points: 27,128
( penguincube )


1839

Patron
Reply
Wow a calculator with BASIC on it would be so freaking awesome.  I bet that was expensive, huh?

EDIT: I think we have TI-83s Pluses at school!  Can you code on those??

also, did you pull the cards out of the array randomly?  how do you go about doing something like that?


(Edited by penguincube at 9:50 pm on Dec. 2, 2004)

(Edited by penguincube at 10:14 am on Dec. 3, 2004)

-------
firman consensus facit


6:48 pm on Dec. 2, 2004 | Joined: May 2003 | Days Active: 1,347
Join to learn more about penguincube Florida, United States | GLBT Ally Male | Posts: 14,869 | Points: 36,909
squirellplayingtag


Dairy Product Addict

Patron
Reply
It was about $70 and I've had it for 5 years.

Sure you can program on it. It's how I do so well on test. ;). And it's not cheating, "it's making using of technology available to me."

Yea I pulled the cards out randomly. I'm not sure what basic arrays look like but here's what it looked like in javascript.
Code:

function randomize(N1, N2) {
return Math.floor((N2 - N1 + 1)*Math.random() + N1)
}

      myArray[randomize(0,3)][randomize(0,12)]


The randomize function accepts two values, the low number and the high number. It then creates a random number between the low and high numbers and returns it. I have a two dimensional array(first number is for suit, second is for card; but you could just put them all in just one array to make it simpliar.) that uses the returned values to pull a card.

-------
"The most abundant element in the universe is
hydrogen, then second is stupidity."-Harlan Ellison
"What good fortune for our governments that the
people do not think."-Hitler


9:16 am on Dec. 5, 2004 | Joined: Jan. 2003 | Days Active: 1,260
Join to learn more about squirellplayingtag Maryland, United States | Straight Male | Posts: 6,458 | Points: 27,128
( penguincube )


1839

Patron
Reply
Here is how I used arrays, squirrel.  It's a fun little game that I am actually quite proud of.  I get it to generate a random number from 1-10 from the array, but the user has to guess it first.  They win if they guess within 2 integers.  The fun part is the user gets to wager how many points they want to risk on each of the 15 turns.  But not more than they have!

Code:
TEST:                        
CLS
PRINT "This is a game of chance. The program will pick a RANDOM"
PRINT "number between 1 - 10.  Before the computer picks the number,"
PRINT "you will be asked to GUESS a number that IS WITHIN 2 INTIGERS"
PRINT "from the random one."
PRINT "Your score will be based on how well you guess."
INPUT "STRIKE ANY KEY WHEN YOU ARE READY"; ANY$
RESTORE
SCORE = 5
FOR X = 1 TO 10
CLS
READ NUM(X)
NEXT X
DATA 1,2,3,4,5,6,7,8,9,10
FOR X = 1 TO 15
CLS
RANDOMIZE TIMER
RN = INT(RND * 9) + 1
PRINT "YOU HAVE "; SCORE; " POINTS."
INPUT "HOW MANY POINTS WOULD YOU LIKE TO WAGER?"; WAG
IF WAG > SCORE THEN GOTO POINTTILT
INPUT "TAKE YOUR GUESS"; GUESS
PRINT ""
PRINT "YOU HAVE "; 15 - X; " TURNS REMAINING."

IF GUESS = RN + 1 OR GUESS = RN + 2 OR GUESS = RN - 1 OR GUESS = RN - 2 THEN GOSUB RANDRIGHT
IF GUESS < RN - 2 OR GUESS > RN + 2 THEN GOSUB RANDWRONG
IF GUESS = RN THEN GOSUB RANDEXACT
NEXT X

RANDRIGHT:
PRINT ""
PRINT ""
SCORE = SCORE + WAG
PRINT "YOUR GUESS: "; GUESS
PRINT "THE RANDOM NUMBER IS: "; RN
PRINT "YOU GAINED "; WAG; " POINTS "
PRINT "YOUR SCORE: "; SCORE
SLEEP 4
RETURN

RANDWRONG:
PRINT ""
PRINT ""
SCORE = SCORE - WAG
PRINT "YOUR GUESS: "; GUESS
PRINT "THE RANDOM NUMBER IS: "; RN
PRINT "YOU LOST "; WAG; " POINTS"
PRINT "YOUR SCORE: "; SCORE
SLEEP 4
RETURN

RANDEXACT:
PRINT ""
PRINT ""
BONUS = WAG + 3
SCORE = SCORE + BONUS
PRINT "YOUR GUESS: "; GUESS
PRINT "THE RANDOM NUMBER IS: "; RN
PRINT "YOU GOT"; WAG; " POINTS, PLUS A 3 POINT BONUS!"
PRINT "YOUR SCORE: "; SCORE
SLEEP 4
RETURN

POINTTILT:
PRINT "YOU TRIED TO WAGER MORE POINTS THAN YOU HAVE!!!"
SLEEP 3
RETURN



-------
firman consensus facit


6:46 am on Dec. 8, 2004 | Joined: May 2003 | Days Active: 1,347
Join to learn more about penguincube Florida, United States | GLBT Ally Male | Posts: 14,869 | Points: 36,909
squirellplayingtag


Dairy Product Addict

Patron
Reply
Awsome. That's the first time I've ever actually looked at basic code other then on my calculator. Can you return a value such as an integer? Like if X =5 could you do something like RETURN X? And is your array named DATA with 10 values?


-------
"The most abundant element in the universe is
hydrogen, then second is stupidity."-Harlan Ellison
"What good fortune for our governments that the
people do not think."-Hitler

12:19 pm on Dec. 8, 2004 | Joined: Jan. 2003 | Days Active: 1,260
Join to learn more about squirellplayingtag Maryland, United States | Straight Male | Posts: 6,458 | Points: 27,128
( penguincube )


1839

Patron
Reply
My array is not named "DATA" my array is named "NUM"

Code:

FOR X = 1 TO 10
CLS
READ NUM(X)

NUM is the name of the array.   The "DATA" you saw comes into play with the READ command up there.  It says for X = 1 to 10  READ the data.  It reads the first ten numbers in my DATA line, which happen to be 1-10

Code:
DATA 1,2,3,4,5,6,7,8,9,10

So, when X = 1, it loaded 1 into NUM(1), when X = 2, it loaded 2 into NUM(2), and so on, until the ten numbers from my DATA line were in my array....called NUM

I'm not sure I understand the other part of your question.  By "when X = 5" do you mean the fifth time the loop "For x = 1 to 10?"   Like:

Code:

FOR X = 1 to 10
PRINT X
NEXT X

That would print the numbers 1-10 on the screen.  Clarify what you meant.

I'll miss this class :p   I get to take C++ next year though so yay.

-------
firman consensus facit


6:01 pm on Dec. 8, 2004 | Joined: May 2003 | Days Active: 1,347
Join to learn more about penguincube Florida, United States | GLBT Ally Male | Posts: 14,869 | Points: 36,909
squirellplayingtag


Dairy Product Addict

Patron
Reply
What does a return do? Are you able to return a value? In java we can do something like (this is very abbreviated)
Code:

System.out.println(myX());

myX(){
int x = 5;
return x
}


and that would print out 5.


-------
"The most abundant element in the universe is
hydrogen, then second is stupidity."-Harlan Ellison
"What good fortune for our governments that the
people do not think."-Hitler

6:16 pm on Dec. 8, 2004 | Joined: Jan. 2003 | Days Active: 1,260
Join to learn more about squirellplayingtag Maryland, United States | Straight Male | Posts: 6,458 | Points: 27,128
( penguincube )


1839

Patron
Reply
What does RETURN --do-- in java?  The only thing I know that command for in BASIC is to go back to were you started after you execute a subroutine, like in my program above.   Maybe what RETURN does in java is called something else in basic?

-------
firman consensus facit

6:21 pm on Dec. 8, 2004 | Joined: May 2003 | Days Active: 1,347
Join to learn more about penguincube Florida, United States | GLBT Ally Male | Posts: 14,869 | Points: 36,909
squirellplayingtag


Dairy Product Addict

Patron
Reply
Returns, well return, a value, string,array, almost anything really from a method(subroutine). The value can be used in another method or in almost anyway the coder seems fit.

From the looks of what your saying BASIC can't return a value, which answers why my program kept giving me errors on my calculator when I tried to return H. Haha.

-------
"The most abundant element in the universe is
hydrogen, then second is stupidity."-Harlan Ellison
"What good fortune for our governments that the
people do not think."-Hitler


6:30 pm on Dec. 8, 2004 | Joined: Jan. 2003 | Days Active: 1,260
Join to learn more about squirellplayingtag Maryland, United States | Straight Male | Posts: 6,458 | Points: 27,128
( penguincube )


1839

Patron
Reply
How do you get a string on the TI-83+?  I couldn't find $ or anything.  I only fiddled with it for a minute during math class but it looks different from QBASIC...doesn't it use display or something instead of "Print?"

-------
firman consensus facit

6:33 pm on Dec. 8, 2004 | Joined: May 2003 | Days Active: 1,347
Join to learn more about penguincube Florida, United States | GLBT Ally Male | Posts: 14,869 | Points: 36,909
squirellplayingtag


Dairy Product Addict

Patron
Reply
I've never stored a string. But yes, it uses

Disp "Text to Print"

-------
"The most abundant element in the universe is
hydrogen, then second is stupidity."-Harlan Ellison
"What good fortune for our governments that the
people do not think."-Hitler


11:56 am on Dec. 9, 2004 | Joined: Jan. 2003 | Days Active: 1,260
Join to learn more about squirellplayingtag Maryland, United States | Straight Male | Posts: 6,458 | Points: 27,128
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic