Seting variables with txt files
Author |
Message |
copthesaint
|
Posted: Sat Jan 17, 2009 12:11 pm Post subject: Seting variables with txt files |
|
|
This is a tutorial but it's made in 2003
http://compsci.ca/v3/viewtopic.php?t=5&highlight=seting+vars+txt+files
I'm just wondering does this still apply to the new turing ver?
Also how would I know what loads what from the text file?
Can you accually rename the txt file then load it every time? (probably would take multiple text files)
Can turing create text files?
If so can turing delet them?
How does it acually SET vars with txt files (eg fun:= 3)
Can someone help me? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
The_Bean
|
Posted: Sat Jan 17, 2009 1:24 pm Post subject: Re: Seting variables with txt files |
|
|
Yes this still applies to the newer version.
When you get information from the text file, you can get it line by line, or word by word separated by spaces.
Yes you can rename a text file using File.Rename() although you would have to know what the old name was first.
Yes Turing can create text files, you if you try to put to a file that doesn't exist it will make one.
Turing can delete files using File.Delete.
To actually set variables:
- create the variable in turing depending on what information your getting
- open the stream to the file with the capability 'get'
- get: streamNumber , variable
- this will set the variable to the first word or integer in the text file.
Yes I can help you. |
|
|
|
|
|
copthesaint
|
Posted: Sun Jan 18, 2009 1:33 am Post subject: Re: Seting variables with txt files |
|
|
Okay I didn't really need help
I spent 20 min and learned how to set vars from my text file (Sorry Bean But Tanks ne ways)
The only thing I do not know how to do is get turing to re write the variable values anyone know how too?
this is what I did on my own
ALSO can I encrypt files? and still get the same values? |
|
|
|
|
|
TheGuardian001
|
Posted: Sun Jan 18, 2009 8:49 am Post subject: Re: Seting variables with txt files |
|
|
by having it re-write the variables, do you mean having it output a new value to the file, or just changing it locally? Locally, just treat it as a regular variable, for outputting to the file, This tutorial should point you in the right direction.
As for encryption, yes, technically anything you output to a text file can be encrypted, however as Turing has no built in encryption method, you would need to write your own encryption/decryption algorithm, and run the variables through it before outputting them to the file.
for example (this is pretty basic, it just replaces letters with other predefined letters )
code: |
%decrypt
for i : 1 .. length(myString) %go through the entire string
if myString(i) = a then
newString += s
elsif myString(i) = b then
newString += o
%etc etc
end if
end for
%encrypt
for i : 1 .. length(newString)
if newString(i) = s then
myString += a
elsif newString(i) = o then
myString(i) += b
%etc etc etc
end if
end for
put : filename, myString
|
|
|
|
|
|
|
copthesaint
|
Posted: Sun Jan 18, 2009 1:34 pm Post subject: RE:Seting variables with txt files |
|
|
I don'y realy care about that so much right now I just want to export my vars when I save to the txt file. After that its all working then I will see about encrypting it |
|
|
|
|
|
|
|