Character strings are imported in a SicVar instance as any other SIC variable:
>>> Sic.comm('DEFINE CHARACTER G*8') >>> Sic.comm('LET G "ABCDEFGH"') >>> g 'ABCDEFGH' >>> print g <SicVar instance> array('ABCDEFGH', dtype='|S8') >>> len(g) 8 |
Remember that numpy.ndarray's provide the .tostring() method which returns a Python string resulting of the concatenation of elements of a character array ('|S*' dtypes). This can be useful to handle SIC strings in Python. Nevertheless string concatenation and multiplication is already implemented in SicVar instances:
>>> h = 'xyz' + g + 'ijk' >>> h 'xyzABCDEFGHijk' >>> type(h) <type 'str'> # A standard Python string >>> h = 2*g >>> h 'ABCDEFGHABCDEFGH' |
These SicVar strings can also be easily modified11:
>>> g[0] = "qwerty" >>> g 'qwerty ' # note 'g' has been automatically blank filled >>> Sic.comm('EXA G') G = qwerty ! Character* 8 GLOBAL |