From: Valdes <valdesl@wanadoo.fr>
Subject: Re: Some problems with string type
Date: Thu, 07 Jun 2001 06:06:02 +0200
Date: 2001-06-06T17:59:16+00:00 [thread overview]
Message-ID: <3B1EFDAA.E2818BE9@wanadoo.fr> (raw)
In-Reply-To: 3B1E5BAA.49F1EF9B@amsjv.com
Philip Anderson a �crit :
> Valdes wrote:
> >
> > I have my program writen in Ada that raise some exceptions:
> >
> > raised CONSTRAINT_ERROR : gestindex.adb:5
> >
> > ... And at line 5...
> >
> > function createindex (S:string) return index is
> > I:Index;
> > begin
> > i.nameindex:=s; -- Ligne cinq
>
> Note that Constraint Error will be raised if s is not _exactly_ 20
> characters long.
I have undertood this one. It works fine now.
>
> > i.firstletter:=null;
> > return i;
> > end createindex;
> >
> > ... The index record is defined as follow...
> >
> > type index is record
> > nameindex:String(1..20);
> > firstletter:ptrletter;
> > end record;
> >
> > ... The mistake seems to be trivial but I don't see it.
> >
> > I have seen the same for this also:
> >
> > Ptrtemp.Letter:=Charat(M,Ni);
> >
> > there is the same error but Charat return a character and letter is also
> > one. (ptrtemp is also type ptrlettre)
>
> Is M a String and Ni an index into it?
M is not exactly a string. It is a pointer to a string. I had to make this one
for the first error.
> If so Ni must be within the
> range M'first .. M'last, and M'first may be greater than 1 (and won't be
> 0).
Perhaps I have better to show the function:
--------------------------------------
function addwordtoindex(I :Index;M:word) return Index is
ptrtemp:ptrword:=I.firstletter;
aux:firstletter;
J:Index;
long,Ni:Natural;
B:Boolean;
begin
long:=Lengthword(M);Ni:=1;
if (ptrtemp /= Null) then
while(ptrtemp /=null) loop
Aux:=ptrtemp;
if (ptrtemp.letter /=Charat(M,ni+1)) then
ptrtemp:=ptrtemp.right;
B:=false;
else
ptrtemp:=ptrtemp.bottom;
ni:=ni+1;
B:=True;
end if;
end loop;
ptrtemp:=Aux;
if (B) then
ptrtemp.bottom:=new Cellword;
ptrtemp:=ptrtemp.bottom;
Ptrtemp.letter:=Charat(M,Ni+1); --possible exception
else
ptrtemp.Droite:=new Celword;
ptrtemp:=ptrtemp.right;
Ptrtemp.Letter:=Charat(M,Ni+1); --possible exception
end if;
else
Ptrtemp:=new Cellword;
Ptrtemp:=I.firstletter;
Ptrtemp.Letter:=Charat(M,Ni); --possible exception
end if;
Ni:=ni+1;
while(ni<Long)loop
ptrtemp.bottom:=new Cellword;
ptrtemp:=ptrtemp.bottom;
ni:=Ni+1;
end loop;
ptrtemp.end:=True;
J.Nomindex:=I.nameindex;
J.Premlettre:=I.firstletter;
return J;
end addwordtoindex;
------------------------
I use this function to put some words whose letters will be put into an index
- a tree -
They are an other function whose functionnality is to create a new index.
This one (that I show there) works bad.
The tree(with the words phone and phoque) :
p
|
h
|
o
|
n-q
| |
e u
|
e
|
one node: r- right
|
bottom
And the signature:
Package Gestindex is
type index is private;
type cellword is private;
type ptrword is access cellword;
function addwordtoindex (I:Index;M:word) return index;
private
type cellword is record
word: character;
bottom: ptrlettre;
right: ptrlettre;
end: Boolean;
end record;
type index is record
nameindex:Mot;
firstletter:ptrword;
end record;
end Gestindex;
>
> > All my greetings if you have some ideas. And forgive me for my bad
> > english.
>
> Pas de probleme.
Thank you. All my greetings.
> > --
> > Le Vif Z�phyr Jubile Sur Les Kumquats Du Clown Gracieux.
> The quick brown fox jumps over the lazy dog.
Where did you read this sentence ? On some Macintosh ? ;-)
next prev parent reply other threads:[~2001-06-07 4:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-07 2:18 Some problems with string type Valdes
2001-06-06 16:34 ` Philip Anderson
2001-06-06 20:29 ` Some problems with string type(Exact String?) McDoobie
2001-06-06 21:30 ` tmoran
2001-06-07 8:07 ` Jean-Pierre Rosen
2001-06-06 22:08 ` Marin David Condic
2001-06-07 6:48 ` Ada.Strings.Fixed procedure Move Petter Fryklund
2001-06-07 4:06 ` Valdes [this message]
2001-06-07 13:20 ` Some problems with string type Valdes Laurent
2001-06-06 17:49 ` tmoran
2001-06-07 4:07 ` Valdes
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox