[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

966.0. "How do I translate a compound string to an ascii string." by ASDS::WALSH () Fri Jun 16 1989 11:23

T.RTitleUserPersonal
Name
DateLines
966.1Not easySX4GTO::ROSEFri Jun 16 1989 13:3917
    A compound string is made up of a bunch of segments, each potentially
    in a different character set. You need to use DwtGetNextSegment to
    retrieve each segment as a sequence of bytes, and then (based on the
    character set) translate that sequence of bytes to ascii. The latter
    part is quite tricky...
    
    Suppose the compound string segment is in Cyrillic. You have various
    choices for how to express it in ascii. For example the Cyrillic letter
    that looks like an x can be transcribed h or kh. You can ignore the
    soft sign or represent it as ', etc.
    
    If the compound string segment is in kanji, then you're in for more
    fun. Not only do you have to choose a romanization system, let's say
    Hepburn with the macrons omitted, but you also have to figure out from
    context what the right reading is for each character. (Lots and lots of
    characters have three or four or more...)

966.2here's an exampleNEURON::NICHOLSONA belly as big as an oil spillFri Jun 16 1989 18:1638
    In the simple case where your compound string is a single segment
    and your character set is Latin1, you can use a routine similar to
    the following (which I hacked together from some code of Dave
    Burleigh's).

#include <stdio.h>
#include <decw$include:DwtAppl.h>

char	*ascii_from_cmp ( DwtCompString value )

{
    DwtCompStringContext context;
    char    *ascii_string;

    /* First get the compound string context */

    if ( DwtInitGetSegment ( &context, value ) == DwtSuccess ) 
    {
	int charset, direction, language, rendition;

	/* Then get the next (first) text segment */

	if ( DwtGetNextSegment ( &context, &ascii_string, &charset,
			    &direction, &language, &rendition ) == DwtSuccess )
	    return ascii_string;
	else
	{
	    fprintf ( stderr, "Can't get next segment\n" );
	    return NULL;
	}
    }
    else 
    {
	fprintf ( stderr, "Can't create string context\n" );
	return NULL;
    }
}

966.3make sure you free the string when you're finishedNEURON::NICHOLSONA belly as big as an oil spillSun Jun 18 1989 18:105
    I might add that the storage for the string returned by
    DwtGetNextSegment is allocated in that routine (if you use the C
    format) so you should XtFree the string my routine returns to you
    when you are finished with it.

966.4How to get multiple segments from a list boxASIMOV::KENYONThe Foundation of Science (fiction)Wed Jul 26 1989 10:4014
I am working with a CMP who needs to get the text from the selections 
made in a list box.  If one selection is made his routine works fine
(as in .2), but if more than one entry is selected only the first is 
returned.

How can he get an unknown number of selected entries returned as text?

The reason he would like to do this is he needs to use the text(s) as
input to other processing the application does.

thanks for any assistance,

-jeff

966.5only last selected item per callbackCB750C::BOLGATZWed Jul 26 1989 12:5213
    listbox only returns in the last selected item in its callback.
    In other words, your application will get a callback every time
    an item is selected.  The reason field - single or extend - will
    indicate whether other items are selected as well.  Therefore,
    its fairly easy to track the selected items yourself.  (see pp. 8 - 82-84 
    in the V1 VMS DECwindows Toolkit Routines Ref Manual).
    
    You can also obtain the entire list of selected items using GetValues on 
    DwtNselectedItems and DwtNselectedItemsCount.  SelectedItems points to an 
    array of cs strings comprising the current selected item list...
    
    Jay

966.6QUARK::LIONELFree advice is worth every centWed Jul 26 1989 13:047
Just make sure you use something like DwtCStrcpy to copy the string
value from the callback structure and not just save away the value
from the structure.  I fixed DECBURGER so it wouldn't make this mistake
when I noticed it no longer worked in DW V2.

				Steve