File IO
From Hack Wars Wiki
Using the File IO functions you can write and read from the text-files on your virtual HackWars computer. These functions were released along with powerful new functions for editing the content of your web-site, you can now dynamically replace page-content.
Examples
An example of the File IO functionality follows.
replaceContent(String key,String Content): Replaces the content represented by key in your HTML page with the new content.
For example, if you had "Test.txt" on your harddrive with these contents:
Some Content
Some More Content
replaceContent(String key,String Content)
Your Web Page:
<html> <body> <?key1?> <?any_string?> </body> </html>
Your HTTP Script:
replaceContent("key1",readLine("Test.txt",0)); replaceContent("any_string",readLine("Test.txt",1));
Output for Visitor To Page:
Some Content
Some More Content
This new functionality is made much more powerful when combined with the file IO functions allowing you to store sections of your in-game website to disk:
string fetchGetVariable(string key): Using this function you can extract variables from the get string of a web-site request. For example, someone types in: 192.168.2.002?var1=hello&var2=goodbye
HTTP Script:
fetchGetVariable("var1") -->Returns "hello"
fetchGetVariable("var2") -->Returns "goodbye";;
For a full function listing see the API section of the manual under the section File IO.
Potential uses
You can do some pretty powerful things with File IO, some ideas:
- Text-based adventure games.
- CMS system for your website.
- A system for remotely administrating your computer.
Cost
File IO used to cost a one-time payment of $5. Now it's FREE (as in beer).
