<< Click to Display Table of Contents > 

Client Control Interface Manual > Programming Examples > Handle texts

Handle texts
Previous pageReturn to chapter overviewNext page

The following examples shows how to uses the ASCII protocol to modify a text, rotate it by 45° and evaluate its total width. The creation of the socket connection, that is completely operating system and programming environment dependent, is not shown here. Also sending and receiving of the data is not part of that example. Here the assumption is made that the function DoSend() sends the command line while DoReceive() performs the reception of the answer.

 

Handle texts with ASCII protocol

 

// a buffer for the ASCII command lines that have to be sent, the its maximum size is defined in ScCciCommands.h

char msgStr[ SC_CCI_MAX_COMMANDLENGTH ];

 

// open the socket connection here

...

 

// send the initialization string to set up the interface for the ASCII protocol

DoSend( SC_CCI_INITSTRING );

 

// create the command line that has to be sent, that function call results in a command "ScCciChangeTextByName("MyEntity", "NewText")\n" that is stored in msgStr

           sprintf( msgStr, SC_CCI_CMD_CHANGE_TEXT_BY_NAME, "MyEntity", "NewText" );

 

// send the message via the already opened socket

DoSend( msgStr );

 

// receive the answer and display it within a MessageBox

MessageBox( DoReceive() );

 

// creates the command "ScCciRotateEntity("MyEntity", 100, 100, 45)\n"

sprintf( msgStr, SC_CCI_CMD_ROTATE_ENTITY, "MyEntity", 100, 100, 45 );

 

// execute that command...

DoSend( msgStr );

 

// ...and receive the handshake answer

DoReceive();

 

// send the command to get the minimum horizontal position of the entities outline

sprintf( msgStr, SC_CCI_CMD_GET_ENTITY_OUTLINE, "MyEntity", 0 );

DoSend( msgStr );

 

// convert the returned string into a double value; please note: if fetching of the outline value failed, the returned string is "NaN" (=not a number)

outline_min_x = atof( DoReceive() );

 

// an alternative possibility to send a command, here all values are statically so that it is not necessary to "construct" the command using sprintf()

DoSend( "ScCciGetEntityOutline(\"MyEntity\", 3)\n" );

 

// calculate the width of the entity "MyEntity"

outline_max_x = atof( DoReceive() );

width = outline_max_x - outline_min_x;

Table 406: Handle texts with ASCII protocol