Question: Arrays
Author Message
Question: Arrays

How do i convert an array of characters into an array of integers. Please

Wed, 18 Jun 1902 08:00:00 GMT
Question: Arrays

Quote:
> How do i convert an array of characters into an array of integers. Please
>  answer as soon as possible!

The problem here (so common in these NGs) is that you've asked a very
general and hopelessly vague question - one we can't begin to answer with
any real meaning.  Here are some things we'd need to know:
1. Is the "array of characters" composed just of numeric digit
characters?
2. Is the result meant to be 1 integer for each character, or are there
(sub)strings of characters which must be parsed and converted?
3. If the array is really a series of "substrings" of numeric digits,
what is the separator which separates the substrings?  In other words,
what are the _rules_ and characteristics of the data which is being
processed?
4. What is to be done with characters which don't conform to the
rules?  Does the program continue? Does it abort? What default (or error)
value is returned on any exception?
So, you might see that your failure to provide us adequate information
about the data being processed prevents us from offering _ANY_ meaningful
advice.  There are many possibilities of what _might_ be there, but if we
don't know what _is_ there, how can we possibly help?
An ancient, but altogether pertinent, axiom applies here: "those who
help, help themselves".

Wed, 18 Jun 1902 08:00:00 GMT
Question: Arrays

.

Quote:
>How do i convert an array of characters into an array of integers. Please
> answer as soon as possible!

Program ChToInt;

{I use the ` at start of some lines otherwise
my newsreader will delete the spaces at the start
of lines }

Const ArraySize = 5; {or whatever :)}

Var ca : Array[1..ArraySize] Of Char;
`   ia : Array[1..ArraySize] Of Integer;
`   i  : Integer;

Begin

{ Init array ca here}

` For i := 1 To ArraySize Do
`   If ca[i] = '3' Then
`     ia[i] := 125
`   Else ia[i] := 73;
End.

Now you have converted the array of characters to an
array of integers.
Here the conversion rule was: If the character is '3'
then the integer becomes 125, else 73.
I think you have some other conversion which you want here,
but since you didn't tell it when stating your question,
I assume you will know how to do that yourself.

Chris

Wed, 18 Jun 1902 08:00:00 GMT
Question: Arrays

Have you tried it yourself and it's not working?
A better definition might also help.

Quote:

> How do i convert an array of characters into an array of integers. Please
>  answer as soon as possible!

--
***************************************
!  You've been mailed by the Mad Cow.
http://members.tripod.com/~VacaLoca
My ICQ UIN is 1800067...try it!
http://www.mirabilis.com
***************************************

Wed, 18 Jun 1902 08:00:00 GMT
Question: Arrays

Quote:

> How do i convert an array of characters into an array of integers. Please
>  answer as soon as possible!

1) Start tp.
2) write "val" in the editor
3) place the cursor at the beginning of the word.
4) press CTRL+F1

Should give you a clue :)

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

"How do you shoot the devil in the back?"
"What if you miss?" -Verbal Kint
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Wed, 18 Jun 1902 08:00:00 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages