
-----------------------------------
gayden
Mon Mar 02, 2015 10:17 am

&quot;Substring index is greater than length of string&quot; (error)
-----------------------------------
Task is to write a program that writes a wedge of stars. So, if you input a 7 into get x it'd look like this:
*******
******
*****
****
***
**
*

Here is my code:
[code]var x : int
put "Please enter the initial number of stars: " ..
get x
loop
    for i : 1 .. x
        put "*" (i) ..

    end for
    x := x - 1
    put ""
    exit when (x = 0)
end loop
[/code]

When I run it I get an error on line 6. 

I have no clue what a substring index is.

-----------------------------------
Insectoid
Mon Mar 02, 2015 11:24 am

RE:&quot;Substring index is greater than length of string&quot; (error)
-----------------------------------
What is line 6 supposed to do? What does the (i) part mean?

-----------------------------------
gayden
Mon Mar 02, 2015 3:28 pm

Re: RE:&quot;Substring index is greater than length of string&quot; (error)
-----------------------------------
What is line 6 supposed to do? What does the (i) part mean?
I believe it was Einstein that said something like: "We cannot solve our problems with the same thinking we used when we created them."

I think he's right because looking back at that line, I have no clue what I thought that should do.

Turns out all I had to do was remove the (i)..embarrassing.
