Author Topic: Looking for a tutorial on creating data files  (Read 8323 times)

0 Members and 1 Guest are viewing this topic.

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Looking for a tutorial on creating data files
« on: November 19, 2012, 04:35:10 PM »
0
I am interested in learning how to create retrievable data files for things like: setting a series of waypoints, creating a list of people who are mean to me, saving a bunch of tarket clicks -- you get the idea. If someone really smart like (TM, Cerv, EN, Crome...) has 20 minutes to write up a basic, comprehensive tutorial on creating a sub that will write a retriveable file and (also important) a sub for retrieving the data, that would be super cool.
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #1 on: November 19, 2012, 05:29:33 PM »
0
That's pretty insulting to TM, EN and Crome.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #2 on: November 19, 2012, 05:35:33 PM »
0
2 methods

(1) Registry values
      set *this that

(2) File
Load Method
  call Myfile.txt

Save Method - write out the data in code
  ie set %this that

  exectution
  gosub ENs_SetupCommandLine
  set %PercentSign %
  set %Output  set , #spc , %PercentSign , This , #spc , That
  Execute %Cmd /c Echo %output >> Myfile.txt

Code: [Select]
Sub ENs_SetupCommandLine
  Set %Cmd cmd.exe
  Str Left #OSVer 1
  If #StrRes = 1
      Set %Cmd command.com
  If #StrRes = 2
      Set %Cmd cmd.exe
Return
« Last Edit: November 19, 2012, 06:16:38 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #3 on: November 19, 2012, 06:16:09 PM »
0
I'll one up myself and heres all the code you need :->> http://www.scriptuo.com/index.php?topic=2454.msg88662#msg88662

Can load save multiple vars in a single line.... very nice.. had been meaning to finish that forever.,.  ... enjoy
« Last Edit: November 19, 2012, 07:09:52 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #4 on: November 19, 2012, 07:09:14 PM »
0
Pretty much everything en said. You also might look into road kills writefastarray  sub or... Something or another... Its very handy at saving large quantities of data into text files at once
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #5 on: November 19, 2012, 07:13:23 PM »
0
I knew you had something handy EN, thanks a ton!! I have been looking at subs trying to figure it out, but wanted something clean to learn from.
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #6 on: November 19, 2012, 07:16:13 PM »
0
I knew you had something handy EN, thanks a ton!! I have been looking at subs trying to figure it out, but wanted something clean to learn from.

I editted the post .. follow the link.. allows you to save multi vars in one shot.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline manwinc

  • Elite
  • *
  • *
  • Posts: 2556
  • Activity:
    0%
  • Reputation Power: 32
  • manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!manwinc is a rising star!
  • Gender: Male
  • "The Devs Hard at Work"
  • Respect: +123
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #7 on: November 19, 2012, 07:33:59 PM »
0
OOo... Nice. I shall have to give that one a try myself.
Monkeys and Typewriters!

" Oh I know, We'll make a Boss Encounter that requires 3 keys per player to enter, Then we'll make it not a closed instance so you never know if you are going to pop into a fresh room or a boss that has 1% Health left with 20 dudes smashing its face in, wasting your time and effort"

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #8 on: November 19, 2012, 07:37:28 PM »
0
OOo... Nice. I shall have to give that one a try myself.



Yea pretty usefull bit of code for sure.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #9 on: November 20, 2012, 03:35:28 AM »
0
Your tool kit got me thinking, so figured I would ask!
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #10 on: November 20, 2012, 02:20:41 PM »
0
I am liking this. Digging in and I have a few questions.

Is there a limit on the number of parameters I can send with this system?

I have not looked at parsing the percentage sign from the front of a variable before, but that seems like something that would be good to be able to do so that the save data sub could accept dynamic variables. Is that even possible?

Code: [Select]
gosub ENs_SaveData %File_Path_And_Name_txt TestVar TestVar2

I took your test code and played about a bit pulling the file path off of the file name and I got that working so that I can have a dynamic file name for use in building sets of data.  

Code: [Select]
Event Macro 1 0 STARTING TEST
wAIT 5
SET %TestVar 1
set %testvar2 test
set %File_Name Data_test
Set %File_Path C:\Users\CRS\Desktop\EUO\
set %File_Name_txt Data_test . .txt
;Event exmsg #charid 3 4 TEST MESSAGE The file is now named %File_Name_txt
Set %File_Path_And_Name_txt %File_Path , %File_Name_txt
;Event exmsg #charid 3 4 TEST MESSAGE  The File path with the file name %File_Path_And_Name_txt is saveing a test value of %testvar - %testvar2
goSub ENs_ClearFile %File_Path_And_Name_txt
gosub ENs_SaveData %File_Path_And_Name_txt TestVar TestVar2
; ~~~~~~~~~~~~~~~~~~~
set %testvar 2
set %testvar2 boo
;Event exmsg #charid 3 4 TEST MESSAGE  reseting testvalue to %testvar : %testvar2
; ~~~~~~~~~~~~~~~~~~~
gosub ENs_LoadData %File_Path_And_Name_txt
;Event exmsg #charid 3 4 TEST MESSAGE TestValue = %testvar : %testvar2 $ (should be 1 : test what was saved in file)
halt
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #11 on: November 20, 2012, 06:15:53 PM »
0
Thier is a limit for each time you call the gosub.. that is a total string lenght (buffertext) of 1700 characters.  String length =  (Number of vars * (18 +  Lenght of filename/path ) ) + Lenght Of each VarNAme sent + Lenght of each of the actual vars

Thier is No limit to the number of vars you can send that fit inside the above criteria. Of course if you think you are getting close just split it over a number of gosub ENs_SaveData Lines .. Each call to SaveData APPENDS to the file .. thats why in my example code i clear the file first.

I could implement a detection of the 1700 char limit, in other IO code i have done this... so if you think you might hit the limit I will add it

Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #12 on: November 21, 2012, 06:42:07 AM »
0
I did a little more testing with this code and confirmed that you can use a variable in the gosub ENs_SaveData call line.

The tool becomes really flexible once you start using string and apend as it will allow you to pair a sequenced variable with a sequenced variable name (See below). If you run a character counter you can use that as a trigger to use the same process to promote the file name -- so yes, I think we do want a counter sub also.

I broke apart the file path from the file name so that the name could easily be promoted with a trigger from a character count sub.  While is not used in this example, I wanted to show that I had it working to demonstrate that automatically promoting the file name is possible.

My test script looked like this:

Code: [Select]
Set %Test_Variable Blah
Set %Test_Variable_Save Test_Variable
Set %File_Name Data_test
Set %File_Path C:\Users\CRS\Desktop\EUO\
Set %File_Name_txt Data_test . .txt
Set %File_Path_And_Name_txt %File_Path , %File_Name_txt
goSub ENs_ClearFile %File_Path_And_Name_txt
For %X 1 10
    {
    Set %Test_Variable_Save . %X %Test_Variable_Save , %X
    Set %Test_Variable . %X %Test_Variable , %X
    gosub ENs_SaveData %File_Path_And_Name_txt %Test_Variable_Save . %X
    }
Halt

The data file it created, appeared in my UO file named Data_test.txt  and it looks like this:

Code: [Select]
Set %Test_Variable1 Blah1
Set %Test_Variable2 Blah2
Set %Test_Variable3 Blah3
Set %Test_Variable4 Blah4
Set %Test_Variable5 Blah5
Set %Test_Variable6 Blah6
Set %Test_Variable7 Blah7
Set %Test_Variable8 Blah8
Set %Test_Variable9 Blah9
Set %Test_Variable10 Blah10

Pretty much exactly what I was looking for EN!!


 
« Last Edit: November 21, 2012, 09:20:37 AM by Paulonius »
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #13 on: November 21, 2012, 08:54:34 AM »
0
Nice Paulonius... using a var to reference a var  sweet gooble gooble   


Saving script config setups just got a whole lot easier didnt it.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +162
  • Referrals: 1
    • View Profile
Re: Looking for a tutorial on creating data files
« Reply #14 on: November 21, 2012, 09:48:25 AM »
0
A lot of cool stuff we can do with this. 

Could you share what you did to calculate character count?
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Tags: