Get line record from a file

Example:
I have the below list in a single text file.

1234567,3456,apple,15.00
7654321,5432,ball,25.30
1237890,3789,car,35.67

How can I get all the details of a line record by just selecting any word from the line.
Example, if i input on a textbox “5432”, i will get “7654321”, “5432”, “ball”, “25.30”

thanks.

2 Likes

I tried to convert your work on my blocks, but ALL RECORDS are showing instead of just getting the row where my input is included.

here are my blocks

Try this:

you are storing your text as csv table, i.e. each row does have the invisible end of line character \n
to get the blocks from @bodymindpower working, use the split block and split at \n (new line)

Taifun

2 Likes

Who says that?
As you can see, in my example I separated the items with a space and my solution works. Of course you can also separate the items with \n (in rows) and then split at \n.

1 Like

it looks like @jawaradelcarmen said it here
Unbenannt
Taifun
PS: I might be wrong… :wink:

It looks the same to me …
grafik

what if
1234567,3456,apple,15.00
7654321,5432,ball,25.30
1237890,3789,car,35.67

is in a textfile, how can create a global variable from reading a textfile?

How about next time you try something yourself. :roll_eyes:

use the file component to read the textfile
you might want to do some tutorials to learn the basics…


A very good way to learn App Inventor or Kodularis to read the free Inventor’s Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials Tutorials for MIT App Inventor to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun

1 Like