WPTXT is a programming language for storing and exchanging data, written for lua.
There are five Types in WPTXT: STRING, NUMBER, BOOLEAN, LIST, NOTHING. The NOTHING Type is returned by interpreter if the value is equals nil. Value with Type BOOLEAN can only be equal to either True or False.
All Values have Name and Type:
Value1?STRING:WPTXT
Value2?NUMBER:123.45
Value3?BOOLEAN:true
Value4?LIST:One|Two|Three|Four|Five
Value5?NOTHING:%NIL%Objects are needed to store values. They must have their own Name and be denoted by -> <- at the beginning and at the end:
->Account
FullName?STRING:Mark Mjaucher
Login?NOTHING:%NIL%
Age?NUMBER:26
PhoneNumbers?LIST:+355-69-123-4567|+355-69-711-0711
IsPrivate?BOOLEAN:True
<-There can be an unlimited number of Objects in one file.
The WPTXT.lua file needs to be thrown into the project and required from it:
WPTXT = require("WPTXT")The next step is to OPEN the file:
WPTXT:OPEN("Test") --Test is the file name (Test.WPTXT)Function OBJ() сreates a new Object:
WPTXT:OBJ("Account")Function ADD() сreates a new Value:
WPTXT:ADD("Account", "FullName", "Mark Mjaucher") --STRING
WPTXT:ADD("Account", "Login", nil) --NOTHING
WPTXT:ADD("Account", "Age", 26) --NUMBER
WPTXT:ADD("Account", "PhoneNumbers", { "+355-69-123-4567", "+355-69-711-0711" }) --LIST
WPTXT:ADD("Account", "IsPrivate", true) --BOOLEANFunction GET() gives Value:
local FullName = WPTXT:GET("Account", "FullName")
local PhoneNumbers = WPTXT:GET("Account", "PhoneNumbers")
print(FullName)
for ind, pnumber in ipairs(PhoneNumbers) do
print(pnumber)
end
> Mark Mjaucher
> +355-69-123-4567
> +355-69-711-0711Function SET() changes Value:
print(WPTXT:GET("Account", "Login"))
WPTXT:SET("Account", "Login", "mjaucher")
print(WPTXT:GET("Account", "Login"))
> %NIL%
> mjaucherTo save your progress, use the SAVE() function:
WPTXT:SAVE()WPTXT is distributed under the terms of the MIT License.
