🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.pascal
18 messages
18 total messages Started by fatrix Sun, 06 Jan 2008 08:25
Odczyt pliku
#92378
Author: fatrix
Date: Sun, 06 Jan 2008 08:25
28 lines
1534 bytes
Witam,

Mam sobie plik .txt i chcę z niego czytać dość nietypowo - muszę podzielić 
dane na porcje 4x4 znaki.

Jak to zrobić?

Moge zczytać pierwsze 4 znaki pierwszej lini, 4 znaki drugiej, 4 znaki 
trzeciej i już mam jedną porcję, ale jak później czytać dalej w prawo - tzn:

x - pojedyńczy char (kompilator TP 7.0)

||xxxx||xxxx|xxx
||xxxx||xxxx|xxxxxxxxxxx
||xxxx||xxxx|xxxx
||xxxx||xxx
|xxxx|xxxxxxxxxx

Pomiędzy || to porcja zczytana jakoś jak już wyżej napisałem, ale jak 
później zczytać porcję na prawo od już zczytanej itp.


Proszę o jakąś wskazówkę.

-- 
Fatrix
http://www.naskwerze.pl
--- 
Re: Odczyt pliku
#92379
Author: Tygrys
Date: Sun, 06 Jan 2008 08:49
36 lines
1971 bytes
fatrix pisze:
> Witam,
> 
> Mam sobie plik .txt i chcę z niego czytać dość nietypowo - muszę 
> podzielić dane na porcje 4x4 znaki.
> 
> Jak to zrobić?
> 
> Moge zczytać pierwsze 4 znaki pierwszej lini, 4 znaki drugiej, 4 znaki 
> trzeciej i już mam jedną porcję, ale jak później czytać dalej w prawo - 
> tzn:
> 
> x - pojedyńczy char (kompilator TP 7.0)
> 
> ||xxxx||xxxx|xxx
> ||xxxx||xxxx|xxxxxxxxxxx
> ||xxxx||xxxx|xxxx
> ||xxxx||xxx
> |xxxx|xxxxxxxxxx
> 
> Pomiędzy || to porcja zczytana jakoś jak już wyżej napisałem, ale jak 
> później zczytać porcję na prawo od już zczytanej itp.

Możesz po najmniejszej lini oporu:
przeczytać jeszcze raz ignorując pierwsze cztery znaki i czytając następne.

Albo załaduj plik do array of string i przetwarzaj stringi po kawałku

Bardziej elegancko jest czytać pierwsze cztery do jakiejś zmiennej 
(tablicy) a potem drugie cztery do drugiej itd.

Trochę zależy, jak masz zorganizowane te dane, czy ilość znaków w 
linijce jest stała, czy długość pliku (ilość linijek)  jest 
stała/ograniczona itp

Tygrys
Re: Odczyt pliku
#92380
Author: fatrix
Date: Sun, 06 Jan 2008 09:00
8 lines
1423 bytes
Użytkownik "Tygrys" <news15@wywalto.tygrys.com.pl> napisał

> Trochę zależy, jak masz zorganizowane te dane, czy ilość znaków w linijce 
> jest stała, czy długość pliku (ilość linijek)  jest stała/ograniczona itp

Nie, programik ma działać zarównoa dla danych optymistycznych - 4,8,12.... 
linijek po 4,8,12.. znaków jak i dla danych pesymistycznych - wtedy do 
wypełnienia do równych 4x4 mam dać puste znaki. 
Re: Odczyt pliku
#92381
Author: Tygrys
Date: Sun, 06 Jan 2008 09:12
29 lines
2255 bytes
fatrix pisze:
> Użytkownik "Tygrys" <news15@wywalto.tygrys.com.pl> napisał
> 
>> Trochę zależy, jak masz zorganizowane te dane, czy ilość znaków w 
>> linijce jest stała, czy długość pliku (ilość linijek)  jest 
>> stała/ograniczona itp
> 
> Nie, programik ma działać zarównoa dla danych optymistycznych - 
> 4,8,12.... linijek po 4,8,12.. znaków jak i dla danych pesymistycznych - 
> wtedy do wypełnienia do równych 4x4 mam dać puste znaki.

Czy to na pewno wymaga przetwarzania najpierw wszystkich znaków z 
początku wszystkich linijek ?

Najmniej myślenia wymaga przetworzenie tego raz jak piszesz, potem drugi 
raz ignorując pierwsze 4 znaki i tak dopóki coś jest w którejkolwiek 
linijce. Jest to nieeleganckie (wolne i nieefektywne) rozwiązanie, ale 
jak potrzebujesz to rzadko używać albo szybko napisać to może być.


Jak to ma być zaliczenie ta za takie podejście bym nie dał.
Jak to ma pracować gdzieś praktycznie to bym się wstydził.

Inny sposób podejścia wymaga znajomości założeń (np. że znaków w lini 
jest mniej niż 200) albo użycia jakiegoś delphi gdzie taki plik 
wczytujesz do TStringList i obrabiasz już potem jak chcesz.
W sumie to nie piszesz, co z tym trzeba zrobić i trudno coś zasugerować.

Tygrys
Re: Odczyt pliku
#92382
Author: fatrix
Date: Sun, 06 Jan 2008 09:50
11 lines
1640 bytes
Użytkownik "Tygrys" <news15@wywalto.tygrys.com.pl> napisał

> W sumie to nie piszesz, co z tym trzeba zrobić i trudno coś zasugerować.

Później na tych porcjach będę przeprowadzał transponowanie i jeszzce parę 
operacji - to ma być taka metoda szyfrowania. Ale z resztą dam sobie już 
radę. Nie mam tylko pomysłu na wczytanie pliku w odpowiednie struktury, a i 
sam spoób tego wykonania powinien być "ładny" a nie "na chama".

Musi być pod TP 7.0 więc odgórnie założenie jest, że linijka ma nie więcej 
jak 255 znaków, Tstringlist też odpada. 
Re: Odczyt pliku
#92383
Author: Tygrys
Date: Sun, 06 Jan 2008 11:13
32 lines
2068 bytes
fatrix pisze:
> Użytkownik "Tygrys" <news15@wywalto.tygrys.com.pl> napisał
> 
>> W sumie to nie piszesz, co z tym trzeba zrobić i trudno coś zasugerować.
> 
> Później na tych porcjach będę przeprowadzał transponowanie i jeszzce 
> parę operacji - to ma być taka metoda szyfrowania. Ale z resztą dam 
> sobie już radę. Nie mam tylko pomysłu na wczytanie pliku w odpowiednie 
> struktury, a i sam spoób tego wykonania powinien być "ładny" a nie "na 
> chama".
> 
> Musi być pod TP 7.0 więc odgórnie założenie jest, że linijka ma nie 
> więcej jak 255 znaków, Tstringlist też odpada.

s: string;
f: Text;
i: Integer;
Element: array[0..63] of string[4];


Readln(f, s);

for i := 0 to 63 do
   Element[i] := Copy(s, i*4 + 1, i*4 + 4);

i w tablicy element masz linijkę podzieloną na to co chcesz.

jak potrzebujesz tego więcej to robisz sobie array of Element i 
wczytujesz kilka(naście/dziesiąt) na raz, z przykładu wynika że używasz 
3 lub 4, ale nie piszesz dokładnie.

Tygrys
Re: Odczyt pliku
#92384
Author: fatrix
Date: Sun, 06 Jan 2008 11:36
13 lines
1740 bytes
Użytkownik "Tygrys" <news15@wywalto.tygrys.com.pl> napisał

> jak potrzebujesz tego więcej to robisz sobie array of Element i wczytujesz 
> kilka(naście/dziesiąt) na raz, z przykładu wynika że używasz 3 lub 4, ale 
> nie piszesz dokładnie.

hmm, nie bardzo mi o to chodzi

nie chce podzielić linijki na macierz, a wczytac przykładowo: cały plik .txt 
w x macierzy 3x3 czy 4x4 czy dowolne (ale ustalone z góry przy pisaniu), 
czyli musze przy 1 takiej operacji wziąść pod uwage (np przy 1 odczycie) 3 
pierwsze linijki, i z nich po 3 znaki, pozniej, 3 pierwsze linijki, i 
kolejne 3 znaki
Re: Odczyt pliku
#92385
Author: Tygrys
Date: Sun, 06 Jan 2008 13:32
23 lines
1938 bytes
fatrix pisze:
> Użytkownik "Tygrys" <news15@wywalto.tygrys.com.pl> napisał
> 
>> jak potrzebujesz tego więcej to robisz sobie array of Element i 
>> wczytujesz kilka(naście/dziesiąt) na raz, z przykładu wynika że 
>> używasz 3 lub 4, ale nie piszesz dokładnie.
> 
> hmm, nie bardzo mi o to chodzi
> 
> nie chce podzielić linijki na macierz, a wczytac przykładowo: cały plik 
> .txt w x macierzy 3x3 czy 4x4 czy dowolne (ale ustalone z góry przy 
> pisaniu), czyli musze przy 1 takiej operacji wziąść pod uwage (np przy 1 
> odczycie) 3 pierwsze linijki, i z nich po 3 znaki, pozniej, 3 pierwsze 
> linijki, i kolejne 3 znaki
> 
> 

Masz tu pokazane, jak wczytać linijkę do wiersza macierzy.
Jak to zrobisz kilka razy, wczytasz całą macierz.

Zamiast element[i] użyj element[j, i] i będzie

Tygrys
Re: Odczyt pliku
#92386
Author: fatrix
Date: Sun, 06 Jan 2008 14:29
6 lines
1417 bytes
Użytkownik "Tygrys" <news15@wywalto.tygrys.com.pl> napisał

> Masz tu pokazane, jak wczytać linijkę do wiersza macierzy.
> Jak to zrobisz kilka razy, wczytasz całą macierz.

aha, no to coś mi nie wychodzi 
Re: Odczyt pliku
#92387
Author: Magda S
Date: Wed, 16 Jan 2008 12:16
22 lines
1326 bytes
> 
> Musi być pod TP 7.0 więc odgórnie założenie jest, że linijka ma nie 
> więcej jak 255 znaków


Skąd to założenie?


{$X+}

var
   X: array[0..4095] of char;
   F: Text;

...


   Readln(F, X);

{ przeczyta się pierwsze 4095 znaków z linii albo cała linia gdy krótsza }

A w ogóle to całe zadanie jest dziecinnie proste, gdy się trochę pomyśli.
Re: Odczyt pliku
#92394
Author: Tygrys
Date: Thu, 24 Jan 2008 18:10
43 lines
1908 bytes
upon all flesh."

67Ps. 82:6. "Ye are gods."

68Is. 40:6. "All flesh is grass."

69Ps. 49:12, 13. "He is like the beasts that perish; this their way is their
folly."

70Eccles. 3:18. "I said in mine heart concerning the estate of the sons of
men."

[71]1 Cor. 1:25 "The foolishness of God is wiser than men; and the weakness
of God is stronger than men."

[72]Ovid, Metamorphoses, iii. "No one is happy before death."

[73]1 John 2:16.

74Cor. 1:31. "He that glorieth, let him glory in the Lord."

75John 14:6. "I am the way, the truth, and the life."

761 Cor. 6:17. "But he that is joined unto the Lord is one spirit."

77Gen. 4:7. "Unto thee shall be his desire."

78Office for Holy Saturday. "Which won for us a Saviour."

79Office for Good Friday. "Which won for us God's hallowed members to
embrace."

80Hymn Vexilla regis. "Worthy God's hallowed members to embrace."

81Luke 7:6 "I am not worthy."

821 Cor. 11:29. "Who eateth unworthily."

83Rev. 4:11. "Thou art worthy to receive."

84Office of the Holy Virgin. "Make me worthy."

[85]Matthew, 7:
Re: Odczyt pliku
#92388
Author: fatrix
Date: Thu, 24 Jan 2008 18:14
34 lines
2595 bytes
world feels this and does so;
for the world is often a good judge.

38. A poet and not an honest man.

39. If lightning fell on low places, etc., poets, and those who can only
reason about things of that kind, would lack proofs.

40. If we wished to prove the examples which we take to prove other things,
we should have to take those other things to be examples; for, as we always
believe the difficulty is in what we wish to prove, we find the examples
clearer and a help to demonstration.

Thus, when we wish to demonstrate a general theorem, we must give the rule
as applied to a particular case; but if we wish to demonstrate a particular
case, we must begin with the general rule. For we always find the thing
obscure which we wish to prove and that clear which we use for the proof;
for, when a thing is put forward to be proved, we first fill ourselves with
the imagination that it is, therefore, obscure and, on the contrary, that
what is to prove it is clear, and so we understand it easily.

41. Epigrams of Martial.--Man loves malice, but not against one-eyed men nor
the unfortunate, but against the fortunate and proud. People are mistaken in
thinking otherwise.

For lust is the source of all our actions, and humanity, etc. We must please
those who have humane and tender feelings. That epigram about two one-eyed
people is worthless, for it does not console them and only gives a point to
the author's glory. All that is only for the sake of the author is
worthless. Ambitiosa recident ornamenta.[4]

42. To call a king "Prince" is pleasing, because it diminishes his rank.

43. Certain authors, speaking of 
Re: Odczyt pliku
#92395
Author: fatrix
Date: Thu, 24 Jan 2008 18:15
29 lines
2676 bytes
She answered, Yes, it does
sometimes.

She has often manifested a great concern for the good of others' souls:
and has been wont many times affectionately to counsel the other
children. Once, about the latter end of September, the last year, when
she and some others of the children were in a room by themselves,
husking Indian corn, the child, after a while, came out and sat by the
fire. Her mother took notice that she appeared with a more than ordinary
serious and pensive countenance; but at last she broke silence, and
said, I have been talking to Nabby and Eunice. Her mother asked her what
she had said to them. Why, said she, I told them they must pray, and
prepare to die; that they had but a little while to live in this world,
and they must be always ready. When Nabby came out, her mother asked
her, whether she had said that to them. Yes, said she, She said that,
and a great deal more. At other times, the child took opportunities to
talk to the other children about the great concern of their souls, so as
much to affect them. She was once exceeding importunate with her mother
to go with her sister Naomi to pray: her mother endeavored to put her
off; but she pulled her by the sleeve, and seemed as if she would by no
means be denied. At last her mother told her, that Amy must go and pray
by herself; but, says the child, she will not go; and persisted
earnestly to beg of her mother to go with her. She has discovered an
uncommon degree of a spirit of charity, particularly on the following
occasion. A poor man that lives in the woods, had lately lost a cow that
the family much depended on; and being at the house, he was relating his
misfortune, and telling of the straits and difficulties they were
reduced to by it. She took much notice of it, and it wrought exceedingly
on her compassion. After she had attentively heard
Re: Odczyt pliku
#92389
Author: Tygrys
Date: Thu, 24 Jan 2008 19:13
17 lines
2021 bytes
that to take four from nothing leaves nothing). First
principles are too self-evident for us; too much pleasure disagrees with us.
Too many concords are annoying in music; too many benefits irritate us; we
wish to have the wherewithal to overpay our debts. Beneficia eo usque laeta
sunt dum videntur exsolvi posse; ubi multum antevenere, pro gratia odium
redditur.[6] We feel neither extreme heat nor extreme cold. Excessive
qualities are prejudicial to us and not perceptible by the senses; we do not
feel but suffer them. Extreme youth and extreme age hinder the mind, as also
too much and too little education. In short, extremes are for us as though
they were not, and we are not within their notice. They escape us, or we
them.

This is our true state; this is what makes us incapable of certain knowledge
and of absolute ignorance. We sail within a vast sphere, ever drifting in
uncertainty, driven from end to end. When we think to attach ourselves to
any point and to fasten to it, it wavers and leaves us; and if we follow it,
it eludes our grasp, slips past us, and vanishes for ever. Noth
Re: Odczyt pliku
#92390
Author: fatrix
Date: Thu, 24 Jan 2008 19:37
24 lines
2335 bytes
and concern. If I saw nothing there which revealed a Divinity, I
would come to a negative conclusion; if I saw everywhere the signs of a
Creator, I would remain peacefully in faith. But, seeing too much to deny
and too little to be sure, I am in a state to be pitied; wherefore I have a
hundred times wished that if a God maintains Nature, she should testify to
Him unequivocally, and that, if the signs she gives are deceptive, she
should suppress them altogether; that she should say everything or nothing,
that I might see which cause I ought to follow. Whereas in my present state,
ignorant of what I am or of what I ought to do, I know neither my condition
nor my duty. My heart inclines wholly to know where is the true good, in
order to follow it; nothing would be too dear to me for eternity.

I envy those whom I see living in the faith with such carelessness and who
make such a bad use of a gift of which it seems to me I would make such a
different use.

230. It is incomprehensible that God should exist, and it is
incomprehensible that He should not exist; that the soul should be joined to
the body, and that we should have no soul; that the world should be created,
and that it should not be created, etc.; that original sin should be, and
that it should not be.

231. Do you believe it to be impossible that God is infinite, without parts?
Yes. I wish therefore to show you an in
Re: Odczyt pliku
#92393
Author: fatrix
Date: Thu, 24 Jan 2008 20:33
34 lines
2517 bytes
it and reason together. Behold, ye are of nothing,
and only an abomination, etc. Who," (among contemporary writers), "hath
declared from the beginning that we may know of the things done from the
beginning and origin? that we may say, You are righteous. There is none that
teacheth us, yea, there is none that declareth the future."

Is. 42: "I am the Lord, and my glory will I not give to another. I have
foretold the things which have come to pass, and things that are to come do
I declare. Sing unto God a new song in all the earth.

"Bring forth the blind people that have eyes and see not, and the deaf that
have ears and hear not. Let all the nations be gathered together. Who among
them can declare this, and shew us former things, and things to come? Let
them bring forth their witnesses, that they may be justified; or let them
hear, and say, It is truth.

"Ye are my witnesses, saith the Lord, and my servant whom I have chosen;
that ye may know and believe me, and understand that I am He.

"I have declared, and have saved, and I alone have done wonders before your
eyes: ye are my witnesses, said the Lord, that I am God.

"For your sake I have brought down the forces of the Babylonians. I am the
Lord, your Holy One and Creator.

"I have made a way in the sea, and a path in the mighty waters. I am He that
drowned and destroyed for ever the mighty enemies that have resisted you.

"Remember ye not the former things, neither consider the things of old.

"Behold, I will do a new thing; now it shall spring forth; shall ye not know
it? I will even make a way in the wilderness, and rivers in the desert.

"T
Re: Odczyt pliku
#92391
Author: fatrix
Date: Thu, 24 Jan 2008 21:02
26 lines
1915 bytes
the Christians. The
prophets have foretold the Christians; Saint John, Jesus Christ.

700. It is glorious to see with the eyes of faith the history of Herod and
of Caesar.

701. The zeal of the Jews for their law and their temple (Josephus, and
Philo the Jew, Ad Caium). What other people had such a zeal? It was
necessary they should have it.

Jesus Christ foretold as to the time and the state of the world. The ruler
taken from the thigh, and the fourth monarchy. How lucky we are to see this
light amidst this darkness!

How fine it is to see, with the eyes of faith, Darius and Cyrus, Alexander,
the Romans, Pompey and Herod working, without knowing it, for the glory of
the Gospel!

702. Zeal of the Jewish people for the law, especially after there were no
more prophets.

703. While the prophets were for maintaining the law, the people were
indifferent. But, since there have been no more prophets, zeal has succeeded
them.

704. The devil troubled the zeal of the Jews before Jesus Christ, because he
Re: Odczyt pliku
#92392
Author: Tygrys
Date: Thu, 24 Jan 2008 21:22
29 lines
2166 bytes
nature was like
that of the brutes, and led you to seek your good in the lusts which are
shared by the animals. This is not the way to cure you of your
unrighteousness, which these wise men never knew. I alone can make you
understand who you are...."

Adam, Jesus Christ.

If you are united to God, it is by grace, not by nature. If you are humbled,
it is by penitence, not by nature.

Thus this double capacity...

You are not in the state of your creation.

As these two states are open, it is impossible for you not to recognise
them. Follow your own feelings, observe yourselves, and see if you do not
find the lively characteristics of these two natures. Could so many
contradictions be found in a simple subject?

Incomprehensible. Not all that is incomprehensible ceases to exist. Infinite
number. An infinite space equal to a finite.

Incredible that God should unite Himself to us. This consideration is drawn
only from the sight of our vileness. But if you are quite sincere over it,
follow it as far as I have done and recognise that we are indeed so vile
that we are incapable in ourselves of knowing if His mercy cannot make us
capable of Him. For I would know how this animal, who knows himself to be so
weak, has the right to measure the mercy of God and set limit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads