Qbasicnews.com
February 22, 2020, 08:24:55 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 [3]
  Print  
Author Topic: Another Question - File opening and writing  (Read 6791 times)
Phydaux
Senior Member
**
Posts: 200



« Reply #30 on: June 07, 2003, 05:37:18 AM »

Quote from: "casonon"
Glenn.

Ok I guess that I don't understand what you mean by a user-defined type.  Also I am not clear on why you can't have the $.  I thought that the $ allowed the answer to an input to be a entry other then a numeric answer.  Maybe you can give me an example of what I should have inorder to get this to work.  Sorry for being such a dumbass.  But after 6 years of not doing this, you kind of forget ALOT.  :roll:   But I appreciate everyones help.

Thanks
Just to try and help clear up your understanding of types.
    QBASIC has 5 pre-defined types:
  • Integer - A numeric value, with no decimal point.
  • Long Integer - Like an integer, but with a larger range.
  • Single Precision - A numeric value, with a decimal point.
  • Double Precision - Like a single precision, but with a larger range.
  • String - A string of characters.
A variable can be any of these types, but with QBASIC's loose aproach to programming, you don't have to pre-define them. You just add a data suffex (%, &, !, #, $) e.g. lives%, address$.

You don't have to add a suffex on the end at all you could just predefine the variable using DIM.
E.G.
Code:
DIM myname AS STRING

You could then use myname the same way you would normaly use myname$.


The TYPE statement makes new data types from existing ones.
e.g.
Code:
TYPE  card
   suit AS STRING * 7
   value AS INTEGER
END TYPE


we now have the data type card as well as the existing ones, integer, single, string etc... but there is no data suffex for card so to define a variable as a card data type, we use DIM
Code:
DIM deck(1 TO 52) AS card


Only now instead of writing information to the deck() variable, we need to use the dot-operator (.) to say which part of the user-defined type we are writing to.
e.g. to make card 1 the Ace of Spades
Code:
deck(1).suit = "Spade"
deck(1).value = 1


I really hope this helps, and doesn't confuse the matter more.
Logged

url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][/url]
END OF LINE.
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #31 on: June 07, 2003, 11:59:09 AM »

enough of a misnomer.)
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
toonski84
__/--\__
*****
Posts: 2567



« Reply #32 on: June 07, 2003, 12:03:36 PM »

I think he meant QBasic has 5, not QBasic 5, though the runtime file in qbasic.exe is brun50.lib (or bcom50.lib, i can't remember).
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #33 on: June 07, 2003, 12:39:55 PM »

for QBASIC.EXE?  The runtime libraries for QB 4.5 are in BCOM45.EXE.
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!