Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Including variables in arrays?

Author
Message
foozle my moose
19
Years of Service
User Offline
Joined: 23rd Jun 2005
Location:
Posted: 24th Jun 2005 00:39
I am making a text adventure for my first ever game, and I am using arrays for user input synonyms:

DIM take$(2)
directions$(1)="take"
directions$(2)="pick up"

How do you put a variable after "take" and "pick up" for whatever the user specifies? Would it be better to use a parser? Where can I get one for DarkBasic?

Thanks,
Jack
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 24th Jun 2005 03:32
to put a variable to it, just add it with the + operator:

when the variable is a string:
direction$(1) = "take" + variable$

when the variable is an number:
direction$(1) = "take" + str$(variable)
OR
direction$(1) = "take" + str$(variable#)

(str$() converts a nr to a string.)

Immunity and Annihalation makes Immunihalation...
foozle my moose
19
Years of Service
User Offline
Joined: 23rd Jun 2005
Location:
Posted: 24th Jun 2005 03:44
excellent, thanks Sven!

Login to post a reply

Server time is: 2024-09-23 23:24:51
Your offset time is: 2024-09-23 23:24:51