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.

DarkBASIC Discussion / Text file reading issue

Grim Gary
Years of Service
User Offline
Joined: 12th Dec 2010
Posted: 16th Dec 2010 23:33
I have three files that are no more than text files with lists of names. Male names, female names and last names. I am trying to make a random name generator where the program first reads the number of names in each file (from a small text file) which works fine. The number of names always comes up great. Those are stored in GLOBAL variables.

Then I made who functions, one to get a first name based on the preferred sex of the name and then the second to simply grab a last name out of the last names file. However, whenever I try to access these functions, the program crashes. Only once did it ever read and then never again.

Here is the code I'm using which seems pretty simple.

Is this code correct or is there a more efficient way to do this?

Ashingda 27
Years of Service
User Offline
Joined: 15th Feb 2008
Posted: 17th Dec 2010 23:01 Edited at: 17th Dec 2010 23:06
Make sure these variables are global (iNumMaleNames) otherwise you end up trying to rnd(-1)+1 instead.

You do not need to
you can just use sRead$ as the return string

I have never used a "." while locating the file before maybe try without it?

If this is DBC that you are using, it dont have global variables, the only way to go about it is to use arrays.

Login to post a reply

Server time is: 2020-08-15 12:35:20
Your offset time is: 2020-08-15 12:35:20