It is currently Sat Jan 23, 2021 3:31 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Templates file format
PostPosted: Thu Nov 12, 2015 2:59 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 2:15 pm
Posts: 901
Location: Cuernavaca, Mexico
My Templates file is getting large (~ 500k bytes)

It's getting harder to find code that I wish to insert into my program.

So I've decided that I have to build a search engine for the Templates.prefs file.

Is there a way to get the format of this file? :?:

_________________
- It was too lonely at the top.

Current Machine: Win 10 Pro 64-bit, Dual Xeon E5-2670, 64 gigs ram, Geforce GTX 1660 Ti w/6 gigs ram


Top
 Profile  
Reply with quote  
 Post subject: Re: Templates file format
PostPosted: Thu Nov 12, 2015 6:28 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5818
Location: Germany
Its a rather simple format:

  • First line must be "TEMPLATES:1.0" (case sensitive, without the quotes)
  • Following lines are either in the form "keyword:data" or just "keyword" where:
    • whitespace around keyword and data is ignored
    • the keyword is case insensitive
  • Possible keywords are:
    • Directory - starts a new directory. The data is the directory name
    • Expanded - if directly following a "Directory", this means that the directory is expanded in the view
    • CloseDirectory - end of a directory
    • Template - defines a template. The data is the template name
    • Comment - defines the comment for the most recent template (optional). The data is the comment (escaped)
    • Code - defines the code for the most recent template. The data is the code (escaped) on one line
  • Anything that does not match one of these keywors (like empty lines) is simply ignored

The comment and code fields are escaped so they only consist of one line each. This is done by:
  • Replacing every "\" with "\\"
  • Replacing every newline with "\n"
  • No other special chars are escaped

One day I'll replace this with something that is easier to manage (like XML or JSON).

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject: Re: Templates file format
PostPosted: Fri Nov 13, 2015 1:38 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 2:15 pm
Posts: 901
Location: Cuernavaca, Mexico
Thanks Freak.. That's enough to get me started. :)

_________________
- It was too lonely at the top.

Current Machine: Win 10 Pro 64-bit, Dual Xeon E5-2670, 64 gigs ram, Geforce GTX 1660 Ti w/6 gigs ram


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye