rozanek
asked on
How to read the text from Edit1 word-by-word?
I have Edit1 (for example with text „No comment“), Button1 and Memo1. I would like to make this: When the user clicks on Button1, the program read first word and in Memo1 will show the german translate (Nein). Then the program read second word „comment“ and place the translate in Memo1 after the word „Nein“. How to make this?
what should this result in? a translator? which translates "no comment" to "nein kommentar"? that would be quite stupid, don't you agree?
and the parser lecossois wrote wouldn't work either.
look at: Index := Pos(S, Separator);
well.
in this case, it should be: Index := Pos(Separator, S);
(i don't believe the function would be able to find the passed parameter string (s) at any index within the separator (' '). it's more the other way round, isn't it?)
bye,
Black Death.
and the parser lecossois wrote wouldn't work either.
look at: Index := Pos(S, Separator);
well.
in this case, it should be: Index := Pos(Separator, S);
(i don't believe the function would be able to find the passed parameter string (s) at any index within the separator (' '). it's more the other way round, isn't it?)
bye,
Black Death.
Ok, ok, I admit that I switched the Pos parameters. But I don't have Delphi here at work, so I can't check what I write. I definitely should be more careful when writing examples.
The fact that you don't consider this an interesting problem is irrelevant, because programmers are not allowed to question the specifications, are they (well, at least not in my company).
Greetings.
The fact that you don't consider this an interesting problem is irrelevant, because programmers are not allowed to question the specifications, are they (well, at least not in my company).
Greetings.
lecossois:
no offence meant.
i didn't say this won't be interesting.
i'm just of the opinion that it wouldn't make too much sense to translate phrases word-by-word.
a translator which works fairly usable would mean _lotsa_ mindwork, indeed quite an interesting task...
bye,
Black Death.
no offence meant.
i didn't say this won't be interesting.
i'm just of the opinion that it wouldn't make too much sense to translate phrases word-by-word.
a translator which works fairly usable would mean _lotsa_ mindwork, indeed quite an interesting task...
bye,
Black Death.
Backdeath, no offence taken. I agree completely with your point.
Rozanek, is your problem part of a larger problem ? Maybe there is a much better way of doing things.
Lecossois.
Rozanek, is your problem part of a larger problem ? Maybe there is a much better way of doing things.
Lecossois.
Backdeath, no offence taken. I agree completely with your point.
Rozanek, is your problem part of a larger problem ? Maybe there is a much better way of doing things.
Lecossois.
Rozanek, is your problem part of a larger problem ? Maybe there is a much better way of doing things.
Lecossois.
ASKER
This is no solution. I would like to make this: When the user write some sentence (for example "Good Morning, sir.") in Edit1 and press the Button1, in Memo1 will be this text appear: "Guten Morgen, Herr".
How to make this? I have no experience with Buffers or making functions.
How to make this? I have no experience with Buffers or making functions.
just comment ... :)
if you no experience with buffers or making functions
try to cut and paste 'leccosois' answer, is easy way ... :)
if you no experience with buffers or making functions
try to cut and paste 'leccosois' answer, is easy way ... :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Eum.. if you want to make a translation programm
Then If I was you,I would concentrate me more on the database
you will use =) .. start overtyping your dictionary now ... !
Sk
Then If I was you,I would concentrate me more on the database
you will use =) .. start overtyping your dictionary now ... !
Sk
ow.. almost forgot:
for X:=1 to tembbox1.lines.count {- 1} //not sure do
edit2.text := edit2.text+' '+tempbox1.lines[x {-1}]
for X:=1 to tembbox1.lines.count {- 1} //not sure do
edit2.text := edit2.text+' '+tempbox1.lines[x {-1}]
It's parser problem.
In overall cases you must use lexical analizators (LEX for example).
I usially make my parsers.
After lexical analizators mabe you interesting by syntaxis
analizators :-).
Looking specification (writing for stdin and stdout):
%{
uses LexLib;
var words : array [1..100] of string;
pos : word;
%}
%%
[a-zA-Z]+ begin
words[pos]:=yytest;
inc(pos);
end;
|
\n ;
%%
var i : Integer;
begin
pos := 1;
if yylex=0 then;
for i := 1 to 100 do
writeln(Words[i]);
end.
In overall cases you must use lexical analizators (LEX for example).
I usially make my parsers.
After lexical analizators mabe you interesting by syntaxis
analizators :-).
Looking specification (writing for stdin and stdout):
%{
uses LexLib;
var words : array [1..100] of string;
pos : word;
%}
%%
[a-zA-Z]+ begin
words[pos]:=yytest;
inc(pos);
end;
|
\n ;
%%
var i : Integer;
begin
pos := 1;
if yylex=0 then;
for i := 1 to 100 do
writeln(Words[i]);
end.
ASKER
For Skatan187: Thank you for solution. It's an easy way to make a translator in Delphi!
Hey.. thx =)
Make a function Translate(const S : String); that translates the word.
In the Button1 OnClick event you write the folling code :
const
Separator = ' ';
var
S : String;
Index : Integer;
begin
S := Edit1.Text;
Index := Pos(S,Separator);
while Index > 0 do
begin
Memo1.Lines.Add(Translate(
Delete(S,1,Index);
Index := Pos(S,Separator);
end;
// Now there could be a last word
If Trim(S) <> '' then
Memo1.Lines.Add(Translate(