How do I present a very large number of paragraphs, each with its own attributes?

I hope someone can point me the right direction for an app idea.

I would like to create a book reader app. Each paragraph of the book has an attribute of "importance" which is a known value. This value will affect how the paragraph is displayed to the user for reading, perhaps by font size, or color, etc. according to a choice by the user.

The text of the "book" is shown in column C below. Each paragraph is number and has the importance value as shown in column B.


If the user chooses to view the paragraphs by font size, he might see something like below. In this case, the font size of each paragraph is controlled by column B.

If the user selects "font size" I would need to layout the entire book and present it to him. If he selects "color" (maybe red for the most important paragraphs, yellow for less, etc.) then I would need to layout the book that way.

Since the book will consist of many paragraphs I'm concerned about how to do this and present it to the user in a fast way.

Any ideas would be very much appreciated.

1 Like

Isn't that what html is for?


I am not qualified to comment on the purpose of HTML. And for sure, I am no expert in coding or AI. But I do need this to be an app, and a quick look indicates that there is interest amongst AI coders in showing PDF files, etc. So I think a viewer type app is not out of range. There seems to be plenty of "Bible reader" apps around, and other apps of that ilk (readers).

Perhaps what makes it difficult is simply the amount of data. If there were truly only 10 paragraphs in the book it would seem very do-able. Two parallel lists (one containing the text for each paragraph, and the other some attribute "importance" or whatever) and some labels would probably do it, no?

If you would elaborate on how you would approach this with HTML I would be grateful. Or, perhaps others will chime in.

1 Like

@ABG Suppose the limit on number of labels is very large (which I think it might be). I think my task would be to create many labels (one for each paragraph) and then stuff each label with a paragraph from my book. Once done, the app is basically just playing with attributes of the labels--which I think could be done.

So, do you have any insights as to how to automatically create a bazillion labels inside a vertical scroll arrangement? And then, the one time operation of stuffing each of them with text?

1 Like

One method may go something like this:

  • Create a list and set each paragraph to the list as elements
  • Create your "Importance" list using the index of your paragraph list
  • Display the output in ONE label (in a scrolling vertical arrangement). Set the label to HTMLFormat.
  • Iterate over your paragraph and importance lists applying each paragraph in turn. If importance is required for a paragraph, apply html/css elements to the paragraph as specified in your file/list.
  • Use the HTMLContent block to combine the previous content of the label with the next item

You could do something similar to apply inline styles to your importance paragraphs, then create a single html file to display in a webviewer. For this, you may want to consider using an html/css framework such as w3css

1 Like

That's asking for trouble, in my book.

I would rather build a HTML stream on the fly, using function procedures to wrap my text with the appropriate html, and text JOINs to build up the html stream, then a Web Viewer to display it (assuming that's still alowed in recent Android versions.)

Here is some sample code based on a trick I stole from TimAI2 to feed a Web Viewer ...
pad viewbox webviewer_SVG.aia (3.7 KB)


P.S. I used text blocks for proof of concept only.

Do not add your text to your app as text blocks, or you will overload the Blocks Editor.
Use files loaded from the Media folder at run time.

1 Like guys are great. Given my inexperience it will take me some time to sink my teeth into this, but I will. I will advise how it goes.

1 Like

I think ABG's HTML suggestion is best - the User will use the App to select the preferences, the App can build HTML + CSS pages on demand and display each page in a WebView Component (No Internet Required). HTML (Hypertext Markup Language) and CSS (Cascading Style Sheets) together deliver good text presentation, which is why all websites are based on this combination.

What will be interesting is the actual file(s) size that you have your text in - and if the User has preferences per paragraph, then each paragraph is probably going to need to be a seperate text file.

Do the paragraphs already exist for just the one book or is your App actually intended to be ambidextrous? Just the text files for one book might take you beyond the maximum App size (100mb) - so if there are numerous books, you will need to provide a web-based facility for Users to download from.

1 Like

To better explain, the "book" is a set of proverbs which can be read sequentially. But some passages are more important than others, hence the filtering. One can read the entire book sequentially, or a filtered version sequentially (either by hiding paragraphs altogether, or using tiny fonts to suggest skipping them, or coloring them light grey, etc.).

Total paragraphs: ~42,000
Words per paragraph: generally 5 to 100
I guestimate the total data size to be something around 5 MB

The book won't change and it seems smart to take advantage of that however possible. For example, I'd like the user to be able to dial up/down (w/ slider or equivalent) the "importance" filtering and see in real time how long the total read would be (as an option the user would tell the app to not show lower importance paragraphs at all). So if the user minimized the filtering to none the total read time would be approximately 140 hours. But the user could see in real time that if he sets maximum filtering that read time could be reduced to a matter of minutes.

So, have only 10 minutes? Just dial down to 10 minutes and read the essence of the whole book. That's the goal here.

I don't want the user to wait for processing. They dial up or down and then start reading. If it weren't for the data size the idea is simple.

1 Like

I think that with such a number of paragraphs there will always be some waiting time for data processing. Real-time processing as the text scrolls will be too difficult with A2 blocks. Better if you present the problem in some html forum, do it with html and display the result in WebView.

1 Like

Ya, I'm likely trying to use the wrong tool for the job. Well, I'll probably play with it a bit before giving up.

1 Like

I tried your aia to understand it, but the app crashes after clicking on a button.

1 Like

Wish I had an aia, ha ha, not that far yet and I will be slow due to time/expertise challenge. I think the aia you downloaded was from @ABG and I also had the same result, but didn't look into it yet.

1 Like

My app crashes in the Companion on an emulator, but the built version runs OK on MemuPlay emulator:
SVG Demo

This is tricky stuff, so I am not surprised it crashes.

1 Like

Hmm. I also tested the compiled APK.

1 Like

Do you have any spreadsheet with an example of long text in the format you presented in the first post? Gotta test something.

1 Like

I just do not believe that the total size of the data would be around 5MB.
Since you already seem to have the book, you could just take a text file with the whole text and tell us how big it is.
The whole thing sounds like a spreadsheet problem, or rather a database problem, where you would have a table with columns indicating importance, font size, and where the text can be found.


I did a test project. You need to test with a large csv file.

test_text.aia (9.7 KB)

1 Like

I can't keep up with you guys. I have limited time and am new to all this. BUT, since you asked I did make a sample full file. The "book" is not actually finalized and I'd rather not share at this point. I filled a file with some Latin. I know the book will be very similar in size to what I'm posting here.

I created the simulation file with Excel. The Excel file came to just over 1MB. Then I exported to csv thinking I would share that. The csv file came to over 15MB! Since I would use the csv file with AI, maybe that dooms the project. For what it's worth, the zipped Excel file is 735KB but I'm not allowed to upload Zip files or XLSX files here. So here is the zipped Excel file in Google Drive:

I'll be looking at what you guys are saying in the next couple weeks. I was guessing size based on the Excel size...obviously not a good idea. Wo is me.

1 Like

This is better, this is the actual csv file, zipped:

1 Like