Page 1 of 1

Problem with Mid$

Posted: Thu Jul 09, 2015 3:17 pm
by gtc
According to the documentation:
Mid$(string,start,size)

Retrieves a substring from the string, starting at position start of size characters.
However, when I use Mid$ in Flowcode 6.0.2.1, as follows, where string A[20] has the value "123456789" :
Result = Mid$ (A,X,1)
Result[20] string receives the substring at position start+1, instead of position start.

That is, when index X =1, Result =2; when X = 2, Result =3; etc.

Simple demo program attached.

Re: Problem with Mid$

Posted: Fri Jul 10, 2015 1:21 pm
by DavidA
Hi gtc,

Can you please try using the latest version of Flowcode, 6.1.2, i seem to recall an issue with some string functions were rectified in a later patch.

Re: Problem with Mid$

Posted: Fri Jul 10, 2015 1:29 pm
by gtc
Hi,

Seems I was a tad dyslexic when I typed the above. In fact I am using version 6.1.2.0 (11.5.2015).

If you run my sample program under debug and step through the loop while watching the variables in the simulation window, you'll see what I mean.

Re: Problem with Mid$

Posted: Fri Jul 10, 2015 3:12 pm
by medelec35
Hi gtc,
Since arrays start at 0 and not 1 you will need to retrieve the first character by Mid$(StringVar,0,size).

Mid$(StringVar,1,size) will start at the second char.

If you have a look at wiki help (Via Flowcode Help, Index) you will see that:
Wiki string.png
(8.51 KiB) Downloaded 3005 times

Martin

Re: Problem with Mid$

Posted: Fri Jul 10, 2015 3:58 pm
by gtc
medelec35 wrote:Since arrays start at 0 and not 1 ...
Hi Martin,

Thanks. I had missed that point hidden in the example.

Matrix: please update that Wiki text entry to make clear the specific point that string arrays commence at position zero.

Re: Problem with Mid$

Posted: Fri Jul 10, 2015 4:18 pm
by kersing
Wiki has been updated.