Hi Kristoffer, Thanks very much! Removing 'parse' works. I've learnt
something new. :) Thanks.
On Tuesday, 12 January 2016 20:59:46 UTC+8, Kristoffer Carlsson wrote:
>
> Why do you run "parse" on input()? This will parse a string to give a
> expression which in this case just gives you a symbol.
>
> Removing the parse call makes thing work for me.
>
> On Tuesday, January 12, 2016 at 1:51:59 PM UTC+1, Jose Pereira wrote:
>>
>> Hi,
>> I need to use Julia's string functions to manipulate a string from a user
>> input. Julia keeps giving an error. Strings defined directly in the code
>> seem to work fine with Julia's string functions.
>>
>> From the code snippet below, the string defined for "b" gives the correct
>> output.
>>
>> For "c", code fails at line 19 with the following error message:
>>
>> ERROR: LoadError: MethodError: 'get index' has no method matching
>> getindex(::Symbol, ::Int64)
>> in include at boot.jl:261
>> in include_from_node1 at loading.jl:304
>>
>> If line 19 is commented out, it fails at line 20 with the following error
>> message:
>>
>> ERROR: LoadError: MethodError: 'length' has no method matching
>> length(::Symbol)
>> in include at boot.jl:261
>> in include_from_node1 at loading.jl:304
>>
>> Need suggestions on what is wrong/missing in my code.
>>
>> Thanks,
>> Jose
>>
>> 1 b=string();
>> 2 c=string();
>> 3
>> 4 b="CGAT";
>> 5
>> 6 #Input
>> 7 function input(prompt::AbstractString="")
>> 8 print("Enter first string\n")
>> 9 chomp(readline())
>> 10 end
>> 11 c=parse(input());
>> 12 println("You entered, ",c)
>> 13
>> 14 println("string b = ",b)
>> 15 println("1st char in string b = ",b[1])
>> 16 println("Length of string b = ",length(b))
>> 17
>> 18 println("string c = ",c)
>> 19 println("1st char in string c = ",c[1])
>> 20 println("Length of string c = ",length(c))
>>
>