How to count by programm whole lines belong to Chappter 1,2,3,4 etc

kkasiekk Messages postés 12 Date d'inscription dimanche 11 octobre 2009 Statut Membre Dernière intervention 9 février 2015 - 24 oct. 2009 à 13:23
Caribensila Messages postés 2527 Date d'inscription jeudi 15 janvier 2004 Statut Membre Dernière intervention 16 octobre 2019 - 27 oct. 2009 à 21:35
Hi Friends
I am looking for solution for my programm ... Hope there is someone to help me with
As about my problem:
I have to redaging my file (*.txt one) and it looks like that:

X_1,1
X_1,1 and a text

x_1,2
x_1,2 and a text

in other words. There is a lot of lines (strings) of Holy Bible
I must to find solution to read it and to blockade UpDown component
when Chappter one is over (Let say Exodus 1 has 31 vesets) the second chappter has 25 wersets and so one, and so one...
How to count by programm whole lines belong to Chappter 1,2,3,4 etc.
I'll be greatfull for any sugestion from U
Please send it on my address kallas555@wp.pl

ps. I am polish beginner of Delphi and sorry for my English

24 réponses

Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
24 oct. 2009 à 22:48
I am polish beginner of Delphi and sorry for my English


Why not try on English/Polish forums then, such as ExpertsExchange.com ? You currently are on a French website

Anyway, if I understand your problem, you want to count the number of lines that make up a chapter ? Maybe by starting on the first line of chapter 2, then walking through the textfile until you find "Chapter 2" or something like that ?

Regards, Bacterius !
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
24 oct. 2009 à 22:49
Sorry, read "on the first line of chapter 1"

Regards, Bacterius !
0
solilog Messages postés 273 Date d'inscription samedi 13 juin 2009 Statut Membre Dernière intervention 18 avril 2015 10
24 oct. 2009 à 23:32
Bonsoir tous,
Just for this time we'll talk in english.
I'm interested by the subject, i also did some prog on bible verses. But your question is not clear at all.
- What do you want do. Just display the bible, starting anywhere and scroll on the verses and, at the end of a chapter display the next one, ... at end of a book (ie: Genesis) passing to next one (Exodus) ... to the end of the bible (Revelations)?
- Is the Bible text stored in a .txt file with the verses references format as shown in your question (xx_1,1) ?
- The verses references are repeated twice ? (strange)
- You want count :
- the verses
- or the lines needed in a tMemo (or tRichEdit) to display the verses ?

Good evening
solilog
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
25 oct. 2009 à 02:06
Cordialement, Bacterius !
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Caribensila Messages postés 2527 Date d'inscription jeudi 15 janvier 2004 Statut Membre Dernière intervention 16 octobre 2019 18
25 oct. 2009 à 02:47
Try an Holy File...
0
f0xi Messages postés 4205 Date d'inscription samedi 16 octobre 2004 Statut Modérateur Dernière intervention 12 mars 2022 35
25 oct. 2009 à 02:59
"(strings) of Holy Bible"

Holy Bible not compatible with "Strings"...
0
Caribensila Messages postés 2527 Date d'inscription jeudi 15 janvier 2004 Statut Membre Dernière intervention 16 octobre 2019 18
25 oct. 2009 à 17:23
... or turn yourself towards the side of TFileStream.
0
kkasiekk Messages postés 12 Date d'inscription dimanche 11 octobre 2009 Statut Membre Dernière intervention 9 février 2015
25 oct. 2009 à 20:14
So, a lot of sugestions. but ... no solution
Bacterius your sugestion for me about polish sities is well, but
be sure that I asked there a lot of times and logic says I am here if on polish sities of Delphi I did not find ansfers
Greetings for All of you
0
Caribensila Messages postés 2527 Date d'inscription jeudi 15 janvier 2004 Statut Membre Dernière intervention 16 octobre 2019 18
25 oct. 2009 à 20:48
As u can't know the number of lines of a *.text file without looking through, the best solution is to use the class TFileStream, and flags.

In any case, it's what I'd try, coz it's very convenient and made for that.

Of course, it's only a suggestion...
For operational solution, we need more motives (give us an other Holy Bible like Kama-Sutra, for instance).
0
solilog Messages postés 273 Date d'inscription samedi 13 juin 2009 Statut Membre Dernière intervention 18 avril 2015 10
25 oct. 2009 à 21:38
Hi guys,
I've written a small prog last night for kkasiekk's problem.
A class with 2 tStrngList to keep references and text.
A readfile procedure sweeping the file extracting only lines with
- 1 .. 3 letters + '_' + number + "," plus number + space or tab
- a text after the last space / tab
A search proc to disply all verses containing a word or a string.
The code has nothing really genius, but if somone of you wants it ... (not enough technical interest to publish it)
Good night.
solilog
0
Caribensila Messages postés 2527 Date d'inscription jeudi 15 janvier 2004 Statut Membre Dernière intervention 16 octobre 2019 18
25 oct. 2009 à 21:48
kkasiekk can be interested, I think.
He said in PM that he works with Delphi3, so no Stream i believe...

Anyway, I rajoute a couche : TFileStream is tout indiqué in this case...
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
25 oct. 2009 à 22:02
And why not use TStringList ? Doesn't it seem appropriate for "text files" ?

Cordialement, Bacterius !
0
Caribensila Messages postés 2527 Date d'inscription jeudi 15 janvier 2004 Statut Membre Dernière intervention 16 octobre 2019 18
25 oct. 2009 à 22:33
Oeuf corse, u're right, Bacterius. TStringList is appropriate for *.text as in the f0xi's snippet which counts the number of lines...
But in fact, I think that a *.text is not appropriate in this case.

Let's imagine in the future, this holy text with a system of footnotes, for instance...
So I think that TFileStream'll be more appropriate to make this application evolving.

'coz a Bible without note is like Kama Sutra without illustration. No? :)))
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
25 oct. 2009 à 23:56
Sure, if you start putting illustrations & flash applets inside the holy text, it should be better to use TFileStream with a *.hff file (Holy File Format).

Cordialement, Bacterius !
0
solilog Messages postés 273 Date d'inscription samedi 13 juin 2009 Statut Membre Dernière intervention 18 avril 2015 10
26 oct. 2009 à 00:30
Bonsoir,
D3 guys, i use : fTxt : Text, assign, reset & readln, not sure stream exists in his Delphi3, so it'll work like that. I put data in tStringList, but i'll change to fixed array (same reason). I don't remember what was in D3.
Let's wait kkasiekk closes the post. I've proposed him to give him my source.
Yes there are footnotes and links to other verses (ll see that later), substring search with matching options (as sql LIKE *, %, ...) to extract all verses with that string (done last night), ... funny this problem in my sleepless nights.

Regards
solilog

Ah guys, maybe you'll help me. To read the txt file, check the verses and insert +/- 31000 verses in 2 tStringListit's (ref & verse itself) it's very quick (2/10e sec), but for display, i want insert them in a tReachEdit (to change font between ref & verse) it's very very slow (> 3 mn). I use rEdt.lines.add(myVerse), verse by verse in the reading loop after validity check.
so DO YOU KNOW A QUICKER WAY TO INSERT LINES IN A RICHEDIT ? Maybe creating a very big string (4/5 Mo here) and use other rEdit methods ? compatible with D3 ?

Tcho à tous
solilog
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
26 oct. 2009 à 04:21
Enclose your display code in a protected section (try..finally) using BeginUpdate and EndUpdate on the RichEdit lines. It should be quite quick then.

Cordialement, Bacterius !
0
solilog Messages postés 273 Date d'inscription samedi 13 juin 2009 Statut Membre Dernière intervention 18 avril 2015 10
26 oct. 2009 à 19:04
Hi guys,
Bacterius, i've tested your solution, no change. I did it in the loop, verse by verse using rEdit.lines.add( myline ) and also rEdit.lines.text := AllTxt (a string with all the lines). Same duration (5' 45'') with & without Beginupdate/endupdate.
try
form1.rEdit.Lines.beginupdate;
form1.rEdit.lines.text := AllTxt;
form1.rEdit.Lines.endupdate;
finally
result := vCount;
end;
No way to speed adding lins, idem with tMemo, also very slow.
Bye
solilog
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
26 oct. 2009 à 19:59
You shouldn't modify the Text property. Change the RichEdit.Lines.Text property instead. Then it "should" work.

Cordialement, Bacterius !
0
solilog Messages postés 273 Date d'inscription samedi 13 juin 2009 Statut Membre Dernière intervention 18 avril 2015 10
26 oct. 2009 à 21:28
Bonsoir,
You're right Bacterius, it speeds x 30 ! passed 5' 45'' to 10.5 '' !
You're a star Bacterius, thanks.
solilog
0
Bacterius Messages postés 3792 Date d'inscription samedi 22 décembre 2007 Statut Membre Dernière intervention 3 juin 2016 10
27 oct. 2009 à 03:31
I know

Cordialement, Bacterius !
0
Rejoignez-nous