Notifications
Clear all
[Closed] Finding lowest number
Mar 07, 2013 7:35 pm
I have a text file with data formatted like this:
{
id = 1,
someData1 = someValue1,
someData2 = someValue2,
}
{
id = 355,
someData1 = someValue1,
}
{
id = 20,
someData1 = someValue1,
}
etc...
So there is an id and some other data and they are not in any particular order. I need to create new “block” of properties in that file but I need to find lowest number for id that is not already in use. Any ideas what would be the best way to do that?
4 Replies
1 Reply
(
ss = openfile @"c: emp\ids.txt"
ids = #{}
while not eof ss do
(
if (skipToString ss "id = ") != undefined do
(
id = readDelimitedString ss ","
append ids (id as integer)
)
)
close ss
lowest = undefined
for k=1 to ids.count while lowest == undefined where not ids[k] do lowest = k
format "lowest available: %
" lowest
lowest
)
1 Reply