Hi,
I’ve searched the forums but couldn’t find an answer. Sorry if I overlooked a post.
I have this script so far
--the .zip (txt) file includes [i], new line [Am] another new line and [Testing]
property DataBase : missing value
set DataBaseFile to POSIX file "/Untitled.zip" --note that .zip is a working example but not .txt, I'll make my own extension later on.
open for access DataBaseFile
set DataBase to (read DataBaseFile) as text
close access DataBaseFile
set AppleScript's text item delimiters to {"["}
set DataBase to every text item of DataBase --result :{"", "I]
", "Am]
", "Testing"}
But I want a text file something like this :
[i][Test]
this is a test
[Test2]
this is the second test[/i]
and then let the script read the contents underneath the […]'s (and maybe if possible, make a list with all the [titles] as there name as a variable containing the lines beneath them…)–if that is possible, then I can get variables in the list with their contents
Thanks in advance.
I always found it a bit complicated to parse such structures with pure AppleScript, mostly because of the absence of hash tables, which would make it much easier to efficiently store key/value-pairs.
Of course one can use multiple lists to mimick hash tables, but personally I like to use a helper script through which the AppleScript gains access to the data structures.
In one of my scripts, named subidoo, I am using a Python helper script to manage sets of folder names saved in the same structure you mentioned.
The AppleScript source code contains a handler named aspybridge, which calls certain routines in the Python script to read, add and delete folder sets from the text file. It works well and I invite you to study it.
Thanks a lot 
Haven’t used Python in my life before… but I’ll check it out 
The script does exactly what I want it to do. But because my app only needs to read the file and not write it, I guess it’s easier then.
Am I understanding you wrong or are you suggesting another (better) solution ? maybe XML ?. I’ll go with the one that works the fastest even if it’s harder to write. (I guess that would be objective-c
, but that’s too complicated probably…)
EDIT
This works (most of the times) too,
set SearchBlock to "Alphabet"
set SearchBlock to "[" & SearchBlock & "]"
set theFile to ":foldersets.db"
set fileText to read (open for access (theFile as alias))
set AppleScript's text item delimiters to SearchBlock
set fileText to text item 2 of fileText
set AppleScript's text item delimiters to "["
set fileText to text item 1 of fileText
set fileText to text 2 thru -4 of fileText
It’s based on your foldersets.db file. But it gives errors sometimes…
When I change A B C into ABC I get an error saying “End of file error.” and it highlights the “read (open for access (theFile as alias))” part.
Of course if you can use XML that would also be a nice option, as there are some free tools (XML Suite, XSLT Tools, the built in XML parser from System Events) enabling AppleScript to parse and read XML structured data 
Ok, then I’ll probably go with XML…
Thanks 