About split function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

About split function

Luis Isaac Ramos Garcia
    Dear community;

    I would like to split into an array a list of 58 numbers that appear
in a line in the Image Info. In the line the numbers are joint by "\",
for example:

 -15\-15\-15\-15\-15\-15\-15\-45\-45\-45\-55\-55\-25\-55\-75\-75\-65\-65\-65\-55\-35\-35\-5\-5\-5\-5\-5\-5\-5\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5

    The problem is that in use the following sentence in macro language:

    a=split(TxT,"\");

    I receive an error.
    The problem is in the "\", because if I use or example "5", I have
no problem to split the line, obviously getting incorrect results.

    What is wrong in the use of "\"?

    Many thanks,


   

--
Dr Luis Isaac Ramos Garcia
Departamento de Oncologia
Clinica Universidad de Navarra
Facultad de Medicina,Universidad de Navarra
Av. Pio XII nº36, 31008 Pamplona, Spain
Fax: +34 948255500
TEL: +34 948255400 (Ext. 4924)
E-mail: [hidden email]
Web Page: http://www.cun.es
Reply | Threaded
Open this post in threaded view
|

Re: About split function

lechristophe
Dear Luis,

\ is used for reserved characters, such that \n is for a line break, etc.
so \ by itself is a reserved character, so you have double it in a
string ("\\").
In other terms, the character "\" has to be written "\\" when using strings.

Christophe

2010/8/9 Luis Isaac Ramos Garcia <[hidden email]>:

>   Dear community;
>
>   I would like to split into an array a list of 58 numbers that appear in a
> line in the Image Info. In the line the numbers are joint by "\", for
> example:
>
> -15\-15\-15\-15\-15\-15\-15\-45\-45\-45\-55\-55\-25\-55\-75\-75\-65\-65\-65\-55\-35\-35\-5\-5\-5\-5\-5\-5\-5\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5
>
>   The problem is that in use the following sentence in macro language:
>
>   a=split(TxT,"\");
>
>   I receive an error.
>   The problem is in the "\", because if I use or example "5", I have no
> problem to split the line, obviously getting incorrect results.
>
>   What is wrong in the use of "\"?
>
>   Many thanks,
>
>
>
> --
> Dr Luis Isaac Ramos Garcia
> Departamento de Oncologia
> Clinica Universidad de Navarra
> Facultad de Medicina,Universidad de Navarra
> Av. Pio XII nº36, 31008 Pamplona, Spain
> Fax: +34 948255500
> TEL: +34 948255400 (Ext. 4924)
> E-mail: [hidden email]
> Web Page: http://www.cun.es
>
Reply | Threaded
Open this post in threaded view
|

Re: About split function

Luis Isaac Ramos Garcia
    Many thanks, Christophe;

    I have another basic question.

    If I would like to divide this array in two, i. e.:

 Line=-15\-15\-15\-15\-15\-15\-15\-45\-45\-45\-55\-55\-25\-55\-75\-75\-65\-65\-65\-55\-35\-35\-5\-5\-5\-5\-5\-5\-5\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5
 AA=split(Line,"\\");
 for (i=1;i<=29;i++){
        A1[i]=AA[29-i];                  //...
        A2[i]=AA[59-i];
  }

    The debugger says that "Undefined Identifier in line ..."; I thought
that there is no need to define variables like A1, A2. And In this case
how can I define the identifiers?

    Thanks again,
   
Christophe Leterrier escribió:

> Dear Luis,
>
> \ is used for reserved characters, such that \n is for a line break, etc.
> so \ by itself is a reserved character, so you have double it in a
> string ("\\").
> In other terms, the character "\" has to be written "\\" when using strings.
>
> Christophe
>
> 2010/8/9 Luis Isaac Ramos Garcia <[hidden email]>:
>  
>>   Dear community;
>>
>>   I would like to split into an array a list of 58 numbers that appear in a
>> line in the Image Info. In the line the numbers are joint by "\", for
>> example:
>>
>> -15\-15\-15\-15\-15\-15\-15\-45\-45\-45\-55\-55\-25\-55\-75\-75\-65\-65\-65\-55\-35\-35\-5\-5\-5\-5\-5\-5\-5\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-15\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5\-5
>>
>>   The problem is that in use the following sentence in macro language:
>>
>>   a=split(TxT,"\");
>>
>>   I receive an error.
>>   The problem is in the "\", because if I use or example "5", I have no
>> problem to split the line, obviously getting incorrect results.
>>
>>   What is wrong in the use of "\"?
>>
>>   Many thanks,
>>
>>
>>
>> --
>> Dr Luis Isaac Ramos Garcia
>> Departamento de Oncologia
>> Clinica Universidad de Navarra
>> Facultad de Medicina,Universidad de Navarra
>> Av. Pio XII nº36, 31008 Pamplona, Spain
>> Fax: +34 948255500
>> TEL: +34 948255400 (Ext. 4924)
>> E-mail: [hidden email]
>> Web Page: http://www.cun.es
>>
>>    
>
>  

--
Dr Luis Isaac Ramos Garcia
Departamento de Oncologia
Clinica Universidad de Navarra
Facultad de Medicina,Universidad de Navarra
Av. Pio XII nº36, 31008 Pamplona, Spain
Fax: +34 948255500
TEL: +34 948255400 (Ext. 4924)
E-mail: [hidden email]
Web Page: http://www.cun.es