![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
|
|
|
|
|
|
#12 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Also, you probably want something more like:
%hit = gethit%()
FUNCTION gethit%()
RANDOMIZE TIMER
gethit% = INT(RND * 20) + 1
END FUNCTION |
|
|
|
|
|
#13 |
|
Newbie
Join Date: Nov 2006
Posts: 19
Rep Power: 0
![]() |
From my earlier post:
IF choice% = 1 THEN
CALL combat(hit%)
CALL defense(def%)
ELSE GOTO 190Would 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%) |
|
|
|
|
|
#14 | |
|
Newbie
Join Date: Nov 2006
Posts: 19
Rep Power: 0
![]() |
Quote:
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. |
|
|
|
|
|
|
#15 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
Unfortunately, when it comes to functions, QBASIC is rather obscure. |
|
|
|
|
|
|
#16 |
|
Newbie
|
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|