[Resolved] Reading from text files

Hi all,

After watching Peach’s webinar last night I’m hooked! It was great btw.

I have a couple of specific questions that I would really like to resolve before diving in completely.

I have already created a desktop app for a client who now wants it to be available on iOS and Android. This app reads data from a txt file which is generated from another app I built.

At present the txt file is formatted using “;” i.e.

&Cercueil1=Toury;Cercueil en pin massif;Teinte claire;Finition vernis satiné;Côté mouluré;Couvercle en forme de dôme;5;2;Cercueil, 4 poignées, plaque d’identification et garniture étanche.;0;Cache vis;0;Emblème;

Each piece of data is read and put into different text fields or loads an image etc.

What I would like to know is if this is possible in Corona? I have found the functions to load a txt file and read it but I don’t seem to be able to find a way of accessing specific data.

The second question is regarding network connection.

I want to create another app where I want users to see how many other users are using the app at the same time. Basically there will be a counter at the top that goes up and down depending how may people are using the app. Is this possible?

Thanks in advance for the help.

Cheers

Neil [import]uid: 159904 topic_id: 31247 reply_id: 331247[/import]

function split(pString, pPattern)  
 local Table = {} -- NOTE: use {n = 0} in Lua-5.0  
 local fpat = "(.-)" .. pPattern  
 local last\_end = 1  
 local s, e, cap = pString:find(fpat, 1)  
 while s do  
 if s ~= 1 or cap ~= "" then  
 table.insert(Table,cap)  
  
 end  
 last\_end = e+1  
 s, e, cap = pString:find(fpat, last\_end)  
 end  
 if last\_end \<= #pString then  
 cap = pString:sub(last\_end)  
 table.insert(Table, cap)  
 end  
 return Table  
end  

should take care of letting you split the string after you read it in and put into a table for you.
[import]uid: 19626 topic_id: 31247 reply_id: 124984[/import]

Hi Rob

Thanks very much, that is perfect! Really appreciated.

Cheers

Neil [import]uid: 159904 topic_id: 31247 reply_id: 125030[/import]

function split(pString, pPattern)  
 local Table = {} -- NOTE: use {n = 0} in Lua-5.0  
 local fpat = "(.-)" .. pPattern  
 local last\_end = 1  
 local s, e, cap = pString:find(fpat, 1)  
 while s do  
 if s ~= 1 or cap ~= "" then  
 table.insert(Table,cap)  
  
 end  
 last\_end = e+1  
 s, e, cap = pString:find(fpat, last\_end)  
 end  
 if last\_end \<= #pString then  
 cap = pString:sub(last\_end)  
 table.insert(Table, cap)  
 end  
 return Table  
end  

should take care of letting you split the string after you read it in and put into a table for you.
[import]uid: 19626 topic_id: 31247 reply_id: 124984[/import]

Hi Rob

Thanks very much, that is perfect! Really appreciated.

Cheers

Neil [import]uid: 159904 topic_id: 31247 reply_id: 125030[/import]

I just saw this - thanks so much for the kind words about the webinar, I really do appreciate that kind of thing :slight_smile:

And as usual Rob steps in to save the day so I will mark this as resolved :wink: [import]uid: 52491 topic_id: 31247 reply_id: 125382[/import]

I just saw this - thanks so much for the kind words about the webinar, I really do appreciate that kind of thing :slight_smile:

And as usual Rob steps in to save the day so I will mark this as resolved :wink: [import]uid: 52491 topic_id: 31247 reply_id: 125382[/import]