Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 2nd, 2006, 6:48 AM   #11
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by m0rb1d View Post
Can you use a variable?
Use a variable for what?
Arevos is offline   Reply With Quote
Old Dec 2nd, 2006, 6:53 AM   #12
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Also, you probably want something more like:
%hit = gethit%()

FUNCTION gethit%()
    RANDOMIZE TIMER
    gethit% = INT(RND * 20) + 1
END FUNCTION
Arevos is offline   Reply With Quote
Old Dec 2nd, 2006, 6:58 AM   #13
m0rb1d
Newbie
 
Join Date: Nov 2006
Posts: 19
Rep Power: 0 m0rb1d is on a distinguished road
From my earlier post:

IF choice% = 1 THEN
     CALL combat(hit%)
     CALL defense(def%)
     ELSE GOTO 190

Would this be valid, is what I am asking.

With the SUB combat, im wanting it to generate a random number, hence, using a variable. combat(hit%)
m0rb1d is offline   Reply With Quote
Old Dec 2nd, 2006, 7:00 AM   #14
m0rb1d
Newbie
 
Join Date: Nov 2006
Posts: 19
Rep Power: 0 m0rb1d is on a distinguished road
Quote:
Originally Posted by Arevos View Post
Also, you probably want something more like:
%hit = gethit%()

FUNCTION gethit%()
    RANDOMIZE TIMER
    gethit% = INT(RND * 20) + 1
END FUNCTION

Whenever I do something like that, it gets me errors. Expecting an Expression error I believe. Im not at my home pc atm, so, I cant really fire it up and give you the exact error.

Also, did you intentionally use %hit instead of hit%? I've not seen anything stating using the % before the variable name.
m0rb1d is offline   Reply With Quote
Old Dec 2nd, 2006, 7:54 AM   #15
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by m0rb1d View Post
Also, did you intentionally use %hit instead of hit%? I've not seen anything stating using the % before the variable name.
No, sorry, that was unintentional. Unfortunately, I lack a QBASIC interpreter, so I'm relying on decade-old memories.

Unfortunately, when it comes to functions, QBASIC is rather obscure.
Arevos is offline   Reply With Quote
Old Dec 13th, 2006, 3:57 PM   #16
E.K.Virtanen
Newbie
 
Join Date: Dec 2006
Location: Finland
Posts: 4
Rep Power: 0 E.K.Virtanen is on a distinguished road
Send a message via ICQ to E.K.Virtanen Send a message via MSN to E.K.Virtanen Send a message via Skype™ to E.K.Virtanen
im not 100% sure is this what you are looking for...

...but hopefully helps and if not, let me know.

DECLARE FUNCTION MyFunc! (FuncInt AS INTEGER)

RANDOMIZE TIMER ' this must be done in main module. best place is in start of program



Value = MyFunc(20)



PRINT Value

SLEEP

END



FUNCTION MyFunc (FuncInt AS INTEGER)

        MyFunc = INT(RND * FuncInt) + 1

END FUNCTION
__________________
ASCII-World
E.K.Virtanen is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:39 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC