×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Arrays and functions of long integers?

Arrays and functions of long integers?

Arrays and functions of long integers?

(OP)
Two questions:

1)  How do I create arrays of long integers?

CODE

DIM A(100) AS INTEGER

This statement creates an array of short (two byte) integers.  But what is the comparable statement for an array of long (four byte) integers?

2)  How do I create a function that returns a long integer?

CODE

DECLARE FUNCTION name% ()

PRINT name%

FUNCTION name%
     result% = 10               ' an integer under 32767
     name% = result%
END FUNCTION

This code returns a short integer.  But what is the comparable code for a function that returns a long integer?
 

RE: Arrays and functions of long integers?

My qbasic is way rusty.  Once Caelius had a "working" demo, I moved on.  But...

1.
DIM myArray() AS LONG

2.
FUNCTION func
   myLong& = 2147483647
   func& = myLong&
END FUNCTION

-Geates

RE: Arrays and functions of long integers?

(OP)
Thanks!

BTW  I'm using the Microsoft user's manual which is, frankly, crap.  It's not answering any of my questions.  In this case there was nothing about LONG or using the & suffix.  They just gave us DEFLNG and some sales-type talk about how wonderful and convenient long integers are.

Can you recommend a manual that has a comprehensive alphabetical list of all the commands and statements?

Note that I am not a total beginner. I don't need a Dummies-type book that spends 50 pages describing FOR/NEXT loops.  I just need something more comprehensive than that half-baked manual that Microsoft published 20 years ago.

RE: Arrays and functions of long integers?

I've used Qbasic Command List in Google:

http://www.qbasicstation.com/index.php?c=t_adv

It was the first one listed for me.  I don't know if it has everything you're looking for but you can compare their list to the F1 in QB.

HTH.
--MiggyD

My mind not only wanders, it sometimes leaves completely.

RE: Arrays and functions of long integers?

Sorry I was not watching sooner. this is part of a handout on QBASIC variables. cut & paste into notepad.

Example:

DIM MYVALUE&(100)

CREATES A TABLE OF LONG INTEGERS OF +- 2 BILLION

DIM A#(100)

CREATES A TABLE OF LONG FLOATING POINT OF 8 BYTES WITH 15 DIGITS WHICH IS AS BIG AS IT GETS
-----------------------------------------------------------
 THE FOLLOWING ARE DATA DEFINITION AND TRANSFORMATION STATEMENT EXAMPLES:

A$ = "STRING"     :' CREATES A STRING OF CHARACTERS UP TO 32,767 BYTES LONG
A% = 6            :' CREATES A SHORT INTEGER UP TO +32K = 2 BYTES BINARY + SIGN
A& = 1456789      :' CREATES A LONG INTEGER UP TO +2 BILLION = 4 BYTES BINARY + SIGN
A! = 123.456      :' CREATES A SHORT +FLOATING POINT NUMBER = 4 BYTES WITH 7 DIGITS x1038
A# = 1234567.123  :' CREATES A LONG +FLOATING POINT NUMBER = 8 BYTES WITH 15 DIGITS x10308
A% = X\Y          :' RETURNS THE INTEGER VALUE OF THE DIVIDE
A% = X MOD Y      :' RETURNS THE REMAINDER AFTER DIVIDING X BY Y
A% = INT(3.685)   :' RETURNS "3" THE ROUNDED DOWN VALUE OF "3.685)
A% = FIX(3.685)   :' RETURNS "3" THE TRUNCATED VALUE OF "3.685)
A% = CINT(3.685)  :' RETURNS "4" THE ROUNDED UP VALUE OF "3.685"
A& = CLNG(3.685)  :' RETURNS A LONG INTEGER VALUE "4" THE ROUNDED UP VALUE OF "3.685"
A@ = 23.67        :' CREATES A CURRENCY VALUE

DIM MYVALUES(50)          :' A REAL NUMERIC TABLE WITH 50 ENTRIES
DIM NAMELIST$(200)        :' A CHARACTER TYPE TABLE WITH 200 ENTRIES
DIM BOWLINGSCORES(60,100) :' A TWO DIMENSIONED TABLE WITH 60 ENTRIES OF A 100 ENTRIES EACH
 

Computer thought: I teach a lot of programming so I can learn. You can never learn it all.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close