Skip to content

ShortArrayToString

ShortArrayToString

It copies part of array into a returned string.

string  ShortArrayToString(
   ushort  array[],      // array
   int     start=0,      // starting position in the array
   int     count=-1      // number of symbols
   );

Parameters

array[]

[in] Array of ushort type (analog of wchar_t type).

start=0

[in] Position, from which copying starts, Default - 0.

count=-1

[in] Number of array elements to copy. Defines the length of a resulting string. Default value is -1, which means copying up to the array end, or till terminal 0.

Return Value

String.

Example:

#define ROW_SIZE 16

ushort ExtShortArray[]={0x2190,0x2191,0x2192,0x2193,0x2194,0x2195,0x2196,0x2197,0x2198,0x2199,0x219A,0x219B,0x219C,0x219D,0x219E,0x219F,
                        0x21A0,0x21A1,0x21A2,0x21A3,0x21A4,0x21A5,0x21A6,0x21A7,0x21A8,0x21A9,0x21AA,0x21AB,0x21AC,0x21AD,0x21AE,0x21AF,
                        0x21B0,0x21B1,0x21B2,0x21B3,0x21B4,0x21B5,0x21B6,0x21B7,0x21B8,0x21B9,0x21BA,0x21BB,0x21BC,0x21BD,0x21BE,0x21BF,
                        0x21C0,0x21C1,0x21C2,0x21C3,0x21C4,0x21C5,0x21C6,0x21C7,0x21C8,0x21C9,0x21CA,0x21CB,0x21CC,0x21CD,0x21CE,0x21CF,
                        0x21D0,0x21D1,0x21D2,0x21D3,0x21D4,0x21D5,0x21D6,0x21D7,0x21D8,0x21D9,0x21DA,0x21DB,0x21DC,0x21DD,0x21DE,0x21DF,
                        0x21E0,0x21E1,0x21E2,0x21E3,0x21E4,0x21E5,0x21E6,0x21E7,0x21E8,0x21E9,0x21EA,0x21EB,0x21EC,0x21ED,0x21EE,0x21EF,
                        0x21F0,0x21F1,0x21F2,0x21F3,0x21F4,0x21F5,0x21F6,0x21F7,0x21F8,0x21F9,0x21FA,0x21FB,0x21FC,0x21FD,0x21FE,0x21FF};

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- calculate the number of strings in the symbol table of 7x16
   int total=(int)ExtShortArray.Size()/ROW_SIZE;
//--- in a loop by the table rows, display 7 sets of arrows, 16 pieces in each row in Unicode characters, to the journal row by row
   for(int i=0; i<total; i++)
     {
      int row=i*ROW_SIZE;
      PrintFormat("Arrow set %u: %s",i+1,ShortArrayToString(ExtShortArray,row,ROW_SIZE));
     }
   /*
   result:
   Arrow set 1: &#8592;&#8593;&#8594;&#8595;&#8596;&#8597;&#8598;&#8599;&#8600;&#8601;&#8602;&#8603;&#8604;&#8605;&#8606;&#8607;
   Arrow set 2: &#8608;&#8609;&#8610;&#8611;&#8612;&#8613;&#8614;&#8615;&#8616;&#8617;&#8618;&#8619;&#8620;&#8621;&#8622;&#8623;
   Arrow set 3: &#8624;&#8625;&#8626;&#8627;&#8628;&#8629;&#8630;&#8631;&#8632;&#8633;&#8634;&#8635;&#8636;&#8637;&#8638;&#8639;
   Arrow set 4: &#8640;&#8641;&#8642;&#8643;&#8644;&#8645;&#8646;&#8647;&#8648;&#8649;&#8650;&#8651;&#8652;&#8653;&#8654;&#8655;
   Arrow set 5: &#8656;&#8657;&#8658;&#8659;&#8660;&#8661;&#8662;&#8663;&#8664;&#8665;&#8666;&#8667;&#8668;&#8669;&#8670;&#8671;
   Arrow set 6: &#8672;&#8673;&#8674;&#8675;&#8676;&#8677;&#8678;&#8679;&#8680;&#8681;&#8682;&#8683;&#8684;&#8685;&#8686;&#8687;
   Arrow set 7: &#8688;&#8689;&#8690;&#8691;&#8692;&#8693;&#8694;&#8695;&#8696;&#8697;&#8698;&#8699;&#8700;&#8701;&#8702;&#8703;
   */
  }

See also

StringToShortArray, CharArrayToString, Use of a Codepage

Last updated on