473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

questions about saving/loading multiple variables from .txt file

mrnn
29
Ok I know how to save and load 1 variable from a file, but when it comes to loading multiple variables, I get confused. And all the articles I've found using Google and on here haven't helped too much.

For example I want to save the player's name (strName), which level they're on (intLevel), and which cheats are available (bolCheats(9), a true-false array). Please help me out.

Also it saves the file to (app.path & "\levels\" & strName & ".txt") and when it loads it opens to the folder (app.path & "\levels") then you select the file from a basic file seeker application which I can make myself.

Also I promise this is the last question I'll ask for a long while :P this is the last thing I don't know/remember and need to know for my game, just please help me out with this final question?
Sep 23 '07 #1
7 2574
Killer42
8,435 Expert 8TB
What version of VB are you using? And what technique are you using to save/retrieve your single variable? It's probably simplest if we just build on that.
Sep 24 '07 #2
mrnn
29
What version of VB are you using? And what technique are you using to save/retrieve your single variable? It's probably simplest if we just build on that.
Using VB6 (as usual :P) and I'm not saving/retrieving a single variable, it's multiple. There will be more but if I know how to save/read 3 it shouldn't be a problem to put more on.

Expand|Select|Wrap|Line Numbers
  1.  Open App.Path & "\" & strName & ".txt" for Output As #1
  2. Dim a as String
  3. Dim b, c(29), i As Integer
  4. a = strName     ' [player's name]
  5. b = intDiff     ' [difficulty level]
  6. For i = 0 To 29 
  7.     c(i) = ifBeat(i) ' [Variable that keeps track if you beat a level or not, and the levels arent in linear order (you can choose which to go to) hence the array]
  8. Next
  9. Close #1
I think that's how the saving works, but I don't 100% remember and at the moment I'm not at my home computer so I can't test it either.
Sep 24 '07 #3
Killer42
8,435 Expert 8TB
As far as I can see, that doesn't save anything anywhere. It just opens the file, puts values in an array of Variant-type variables, then closes the file.
Sep 24 '07 #4
mrnn
29
As far as I can see, that doesn't save anything anywhere. It just opens the file, puts values in an array of Variant-type variables, then closes the file.
Oops I forgot some stuff, sorry. Forgot to put:
Expand|Select|Wrap|Line Numbers
  1. write #1, a
  2. write #1, b
  3. for i = (0 to 29)
  4.      write #1, c(i)
  5.  
  6. Close #1
Sep 25 '07 #5
mrnn
29
aww nobody's gonna help me? :P

...unless i'm stupid and its somethin simple like Read #1, a or somethin like that...but please i dont remember how to load multiple variables from a file

and sorry i dont have access to my usual computer (the one with vb6) so i cant test it out at the moment, but please help refresh my memory?
Oct 1 '07 #6
Killer42
8,435 Expert 8TB
I think what it boils down to is that if you can store and load one item of data, you can repeat the same thing as many times as you like for multiple items. If you want to save multiple items on a line, then I believe the Input # statement can handle reading them. You would write them using either Write # or Print #, I forget which. It's all in the documentation.
Oct 1 '07 #7
mrnn
29
I think what it boils down to is that if you can store and load one item of data, you can repeat the same thing as many times as you like for multiple items. If you want to save multiple items on a line, then I believe the Input # statement can handle reading them. You would write them using either Write # or Print #, I forget which. It's all in the documentation.
yeah ur probably right...i'll make sure to try it out when i can...i've been readin through the huge manual i have and lookin around on google...

anyways sorry for bein stupid :P ...and thanks for helpin
Oct 1 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jim Williams | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** I have some questions aboyt XML, and it's use for file loading/saving. I'm working in a C++ environment, on MS Windows. I'll try...
3
by: Jim Williams | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** I have some questions aboyt XML, and it's use for file loading/saving. I'm working in a C++ environment, on MS Windows. I'll try...
3
by: Peter Oliphant | last post by:
Trying to save/load a class instance to a file is tough. The reason is because there is no way to preserve its type other than by conventon. For eample, one can save all the states of the members...
2
by: sachaburnett | last post by:
Hi everyone! I'm new to Javascript and am finding so much useful information on this group, so thanks to you all! I have a question about preloading images for onmouseover/out effects and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.