Re: Bug with str_capital in 6.1.0-beta

From: Ryan Pavlick <ryan.pavlick_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 04 2012 - 06:36:19 MDT

Thanks, Wei.

I had thought of that too. But, it doesn't work because other
identical string variables are still affected by the bug.

I found a solution that works.

newstring = str_right_strip(str_capital(oldstring+" "))

On Tue, Aug 28, 2012 at 5:12 PM, Wei Huang <huangwei@ucar.edu> wrote:
> Ryan,
>
> I'd suggest a work-around like this:
>
> chars = tochar(your_original_strs)
> (generate a char-array from string)
>
> cap_strs = str_capital(your_original_strs)
> (now cap_strs and your_original_strs are both capitalized)
>
> ...
>
> low_strs = tostring(chars)
> (low_strs should be your original string).
>
> For example, we can do:
>
> ;-------------
> strs = "hello world!"
>
> cap_strs = str_capital(strs)
> chars = tochar(strs)
> ori_strs = tostring(chars)
>
> print(cap_strs)
> print(strs)
> print(ori_strs)
> ;-------------------------
>
> Hope this help.
>
> Wei
>
>
>
> huangwei@ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
>
>
>
>
>
>
> On Aug 27, 2012, at 11:51 AM, Ryan Pavlick wrote:
>
>> My workaround actually didn't work. I should have tested it first.
>>
>> It not only affects the input variable but also copies of the input
>> variable. You can see what I mean in the script below.
>>
>> Do you have a suggestion other than the obvious one of reverting back to 6.0?
>>
>>
>> Copyright (C) 1995-2012 - All Rights Reserved
>> University Corporation for Atmospheric Research
>> NCAR Command Language Version 6.1.0-beta
>> The use of this software is governed by a License Agreement.
>> See http://www.ncl.ucar.edu/ for more details.
>> + strs = "hello world!"
>> + strs_copy= strs
>> + strs_copy_copy = strs_copy
>> + strs_not_a_copy = "hello world!"
>> + other_var_name = "hello world!"
>> + other_string = "goodnight moon!"
>> + other_string_plus_strs = other_string + " " +strs
>> + strs_plus_other_string = strs + " " +other_string
>> + strs_plus = "hello world!" + " "
>> +
>> + strs_capital = str_capital(strs)
>> +
>> + print(strs_capital)
>>
>>
>> Variable: strs_capital
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) Hello World!
>> + print(strs)
>>
>>
>> Variable: strs
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) Hello World!
>> + print(strs_copy)
>>
>>
>> Variable: strs_copy
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) Hello World!
>> + print(strs_copy_copy)
>>
>>
>> Variable: strs_copy_copy
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) Hello World!
>> + print(strs_not_a_copy)
>>
>>
>> Variable: strs_not_a_copy
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) Hello World!
>> + print(other_var_name)
>>
>>
>> Variable: other_var_name
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) Hello World!
>> + print(other_string)
>>
>>
>> Variable: other_string
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) goodnight moon!
>> + print(other_string_plus_strs)
>>
>>
>> Variable: other_string_plus_strs
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) goodnight moon! hello world!
>> + print(strs_plus_other_string)
>>
>>
>> Variable: strs_plus_other_string
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) hello world! goodnight moon!
>> + print(strs_plus)
>>
>>
>> Variable: strs_plus
>> Type: string
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>> Coordinates:
>> (0) hello world!
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
------------------------------------------
Ryan Pavlick
Biospheric Theory and Modelling Group
Max Planck Institute for Biogeochemistry
phone: +49.36.41.57.6223
web: http://gaia.mpg.de
------------------------------------------
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 4 06:36:52 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT