News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

I need a program called "FindLine"

Started by learn64bit, November 29, 2022, 04:41:33 AM

Previous topic - Next topic

learn64bit

idea update,
somebody suggest: no need to check line length if memory pointer in last 4mb of memoryOfFile.
I think he is right.

hutch--

That does not make sense, depending on how the data is stored, if its text with a zero terminator, you scan it like normal, if its binary data it would require a length specified when it was created.

learn64bit

0D0Ah+4mb(all 00h)+0D0Ah

make sure it's not over 4mb, then next step we don't care about line length any more.
this is the idea.

his idea speed up the length check procedure.
(because I check to the endOfFileMemory)

learn64bit

#78
Idea update,
another lady suggest create lineTable(2 column: lineLenght and lineLocation) to speed up the making c and a1 procedure.
I think it's a good idea.
next step will be create these 2 table

I think in order to create table, first we need to find out how many lines in a and b.

learn64bit

idea update,

find the maximum number of lines in a or b.
maybe we can caculate it without open a and b...
it will less than (1 giga)/3...
maybe the formular to caculate it is complicated

I should say the number is in the range of 1 to x...
can we caculate x?
we need a formular
which number is x?
just use the number, we don't need to know why it is this number

[sizeOfTableMemory = 4 bytes * 2 * x]

zedd151

Quote from: learn64bit on December 12, 2022, 12:12:08 PM
find the maximum number of lines in a or b.
A byte scanner that scans for carriage return/linefeed (0D0Ah) could count the lines. In masm32.lib is a function"lfcnt" that can handle that job.

learn64bit

zedd151,

we don't care about emptyLines(like 0D0A0D0Ah), and we care about noneEmptyLines(like 0D0A000D0Ah)

learn64bit

the step after table be created will be:
make sure every noneEmptyLine in a or b is a unique line

zedd151

Quote from: learn64bit on December 12, 2022, 01:31:27 PM
... and we care about noneEmptyLines(like 0D0A000D0Ah)

I think you mean 'non empty' lines not 'none empty' lines. But okay, that function that I mentioned will not work, as your example contains zero's.
I cannot think of any ready made function that will do what you want. Reason being there are many functions that work with ascii text. Your example is NOT ascii text as it contains zero bytes.
A zero byte would be recognized as the end of string, and the text handling function would exit immediately after encountering it. That means you need a custom function to count the number of lines, which should not be very hard to do. But you wouldn't be able to depend on (0h) as end of file, but would need to compare the byte counter to the file size to determine if the end of file has been reached.  :biggrin:  Good luck with this project.  :thumbsup:

learn64bit

idea update,
first we need to make sure no duplicated line in a and b.
otherwise one lineTableMemory will be 2.4gb...

jj2007

Quote from: zedd151 on December 12, 2022, 01:52:57 PM
Quote from: learn64bit on December 12, 2022, 01:31:27 PM
... and we care about noneEmptyLines(like 0D0A000D0Ah)

I think you mean 'non empty' lines not 'none empty' lines. But okay, that function that I mentioned will not work, as your example contains zero's.
I cannot think of any ready made function that will do what you want. Reason being there are many functions that work with ascii text. Your example is NOT ascii text as it contains zero bytes.
A zero byte would be recognized as the end of string, and the text handling function would exit immediately after encountering it. That means you need a custom function to count the number of lines, which should not be very hard to do. But you wouldn't be able to depend on (0h) as end of file, but would need to compare the byte counter to the file size to determine if the end of file has been reached.  :biggrin:  Good luck with this project.  :thumbsup:


https://www.deepl.com/translator:

我想你指的是 "非空 "行,而不是 "非空 "行。但是好吧,我提到的那个函数不会起作用,因为你的例子中含有零。
我想不出有什么现成的函数可以做你想做的。原因是有很多函数可以处理ascii文本。你的例子不是ascii文本,因为它包含零字节。
零字节会被识别为字符串的结尾,文本处理函数会在遇到它时立即退出。这意味着你需要一个自定义函数来计算行数,这应该不难做到。但你不能依赖(0h)作为文件的结束,而是需要将字节计数器与文件大小进行比较,以确定是否已经达到文件的结束。 祝你在这个项目中好运。

亲爱的learn64bit。
你应该使用Deepl.com,它比谷歌翻译好得多。当把你的帖子翻译成英文时,你可以:a)确保我们这些成员理解你的意思;b)提高你的英语水平。你有一个很好的项目,但直到现在还绝对不清楚你真正想做什么。

zedd151

#86
jj, no hablar chino. this is an English speaking forum.  :tongue:  Except for hutch, he speaks 'stralian.  :toothy:

edited to clarify, just for jj2007 {in response to his PM}:
Yes I know that the link (and translation above) was intended for learn64bit.
My reply was meant as humour, Jochen.  :sad:

No need to send PM's. :eusa_naughty:   :biggrin:

learn64bit

now a and b are unique line file.
what is maximum number of lines?

I hope tableSpace is not over 256mb.

learn64bit

daydreamer,

we will check available memory later.

I think create table still is a good idea.

learn64bit

idea update,

someone say the number is bigger than 170000000.
so tableSpace will over 256mb.

we cannot afford such big table.
It's a good idea, but now we must forget it.