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 / Array question

Author
Message
Ozor Mox
21
Years of Service
User Offline
Joined: 30th Mar 2003
Location:
Posted: 3rd Apr 2003 00:20
Ok I have a bit of a problem with arrays which I would like to know if anyone can help with. The program needs to open a file depending on the "item number" the user enters, and at the moment it is a case statement something like this:

select item
case 1 : open to write "item1.txt" : endcase
case 2 : open to write "item2.txt" : endcase
etc.
case default : print "invalid selection" : goto wherever : endcase
endselect

At the moment there is only up to case 10 so it isn't a problem, but it may become something like case 100, then case 500 etc. so it really needs to use arrays. The problem is, how do you get it to do something like:

open to write "item(t).txt"

Or is it not possible? Or does it need to look like:

open to write "item" + t + ".txt"? :-s

Can anyone help?
Medicine Soup
21
Years of Service
User Offline
Joined: 25th Mar 2003
Location: Arizona, USA
Posted: 3rd Apr 2003 01:02
I don't know if either of those lines will work. You may have to dedicate a string variable to open the file. try something like this:


sFileString = "item" + t + ".txt"
open to write sFileString


-Medicine Soup
DangYankee
21
Years of Service
User Offline
Joined: 19th Feb 2003
Location: United States
Posted: 3rd Apr 2003 05:36 Edited at: 3rd Apr 2003 05:53
oops never mind.

It's not the size of your code but how efficiently you use it!
Ben
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location: United Kingdom
Posted: 3rd Apr 2003 11:11
Damn, Soupie, you got there first!

Tha D'lithi'om CRR'ist'lls Can'na Tek it Cap'n!

Login to post a reply

Server time is: 2024-11-24 08:21:03
Your offset time is: 2024-11-24 08:21:03