Re: newbie: mapping CHARACTER*2 to INTEGER*2



On May 21, 10:48 am, m...@xxxxxxxxxxxxxxx wrote:
In a previous article, axtens <Bruce.Axt...@xxxxxxxxx> wrote:

G'day everyone

Context: Compaq Visual Fortran 6.6c on Windows XP Professional

I'm trying to work out how to convert a BSTR to an array of INTEGER*2.
I'd convert to CHARACTER*1 using the BSTR to String conversion but
that destroys the Chinese characters in my input. So what I'd like to
do is convert the BSTR to an array of 16 bit integers and then do my
comparisons (for QSORT) on them.

What I have coming into the routine is an array of variants. The
variants are strings and I want to sort them using QSORT. If I convert
my incomings from UTF16 to UTF8 then ConvertBSTRToString (or whatever
it's called -- I'm miles away from my own computer at the moment)
copes. However, I'd like to save myself the hassle of moving between
the different Unicode encodings and just have the comparison function
in the QSORT operate on the strings as if they were made up of short
ints.

I can see possibilities in the manual with respect to MAP, but
actually making it happen is well beyond me at this early stage.

Any ideas?

Kind regards,

Bruce M. Axtens
Software Engineer
The Protium Project

I would use equivalence (if that's still available,)
i.e. not deleted by "progress")
Chris

Chris,

One of the joys of fortran is that it doesn't delete anything:) Try
that from the compiler write/maintainer's point of view.

However, "progress" has brought the TRANSFER intrinsic and this can
effect the conversion required. From the Compaq fortran online
reference manual, which you should have access t:

TRANSFER (SOURCE, MOLD [, SIZE])
Description: Converts the bit pattern of SOURCE according to the
type and kind parameters of MOLD.
Class: Transformational function; Generic
Arguments: SOURCE Must be a scalar or array (of any data type).
MOLD Must be a scalar or array (of any data type). It provides the
type characteristics (not a value) for the result.
SIZE (opt) Must be scalar and of type integer. It provides the
number of elements for the output result.
Results: The result has the same type and type parameters as MOLD.

If MOLD is a scalar and SIZE is omitted, the result is a scalar.

If MOLD is an array and SIZE is omitted, the result is a rank-one
array. Its size is the smallest that is possible to hold all of
SOURCE.

If SIZE is present, the result is a rank-one array of size SIZE.

If the physical representation of the result is larger than SOURCE,
the result contains SOURCE's bit pattern in its right-most bits; the
left-most bits of the result are undefined.

If the physical representation of the result is smaller than SOURCE,
the result contains the right-most bits of SOURCE's bit pattern.

Examples

TRANSFER (1082130432, 0.0) has the value 4.0 (on processors that
represent the values 4.0 and 1082130432 as the string of binary digits
0100 0000 1000 0000 0000 0000 0000 0000).

TRANSFER ((/2.2, 3.3, 4.4/), ((0.0, 0.0))) results in a scalar whose
value is (2.2, 3.3).

TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/)) results in a complex rank-
one array of length 2. Its first element is (2.2,3.3) and its second
element has a real part with the value 4.4 and an undefined imaginary
part.

TRANSFER ((/2.2, 3.3, 4.4/), (/(0.0, 0.0)/), 1) results in a complex
rank-one array having one element with the value (2.2, 3.3).

Character <=> integer examples are not given but it is straight
forward to use TRANSFER for this.

Cheers

Paul
.



Relevant Pages

  • Re: Base36
    ... static string tokens = ... But - I don't think you want all those silly characters in the product key. ... I should be able to recalc the hash at the client ... > conversion to long so I can pass each long to the BaseXX converter to get ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help a beginner - simple lowercase to uppercase and so on function
    ... And then one to loop across the string calling that function ... copying at to a new array. ... are any characters other than lowercase letters */ ...
    (comp.lang.c)
  • Re: fgets question
    ... documentation didn't say if fgets put \0 after a string literal. ... fgets() has nothing at all to do with string literals. ... within the bounds of the array, then it is not a string. ... strlenon an array of characters that is not a string, ...
    (comp.lang.c)
  • Re: Help creating a random string in Perl
    ... can pick one of the 7 characters in my source string) by using "print ... third and fourth characters to and check that the random number hasn't ... shuffling the array ... The idea here is to swap the current cell with some cell ...
    (perl.beginners)
  • Re: Parsing binary values in the registry
    ... how to take a string variable that could concievably be up to 300 ... and split that into either an array or multiple variables for ... every 32 characters within the original varable. ... I am trying to build a file path from a binary value in the ...
    (microsoft.public.scripting.vbscript)