Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Stephen Wonfor-3
I am running this in the data viewer in FMPA 15.
Pardon the rather lame approach but this was done in a rush that has consumed far too much time.
The point is to take the string value left of the “/“ char and then reverse its order.
The pair of “t”s puzzle me.

………………………<Code>………………………
Let([
x = "tsrqponmlkjihfgedcba/356";
l = Length(x);
m = Position(x;"/";1;1);
n = Middle(x; m + 1;3);
r = Left(x;m - 1);
q = Length(r);
s =
Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
Middle(r;q-16;1) &
Case( q ≥ 17; Middle(r;q-17;1)) &
Case( q ≥ 18; Middle(r;q-18;1)) &
Case( q ≥ 19; Middle(r;q-19;1)) &
Case( q ≥ 20; Middle(r;q-20;1)) &
Case( q ≥ 21; Middle(r;q-21;1)) &
Case( q ≥ 22; Middle(r;q-22;1)) &
Case( q ≥ 23; Middle(r;q-23;1))
];
q & ": " & s & " length of \"s\" is " & length(s) & "."
)
………………………<End Code>………………………

when I evaluate it I get this:

20: abcdegfhijklmnopqrstt length of "s" is 21.

I’d prefer this as it is the “right” answer:

20: abcdegfhijklmnopqrst length of "s" is 20.

Stephen

----

“If debugging is the process of removing bugs, then programming must be the process of putting them in.” --- Edsger W. Dijkstra

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Beverly Voth-3
there IS an additional 't' in the result, 20+1 = 21
there are custom functions to reverse a string. :)

beverly

> On Apr 7, 2017, at 1:18 PM, Stephen Wonfor <[hidden email]> wrote:
>
> Let([
> x = "tsrqponmlkjihfgedcba/356";
> l = Length(x);
> m = Position(x;"/";1;1);
> n = Middle(x; m + 1;3);
> r = Left(x;m - 1);
> q = Length(r);
> s =
> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
> Middle(r;q-16;1) &
> Case( q ≥ 17; Middle(r;q-17;1)) &
> Case( q ≥ 18; Middle(r;q-18;1)) &
> Case( q ≥ 19; Middle(r;q-19;1)) &
> Case( q ≥ 20; Middle(r;q-20;1)) &
> Case( q ≥ 21; Middle(r;q-21;1)) &
> Case( q ≥ 22; Middle(r;q-22;1)) &
> Case( q ≥ 23; Middle(r;q-23;1))
> ];
> q & ": " & s & " length of \"s\" is " & length(s) & "."
> )

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Darren Terry-3
In reply to this post by Stephen Wonfor-3
Hi Stephen: Don’t use ≥ in those Case statements. Use >.

> On Apr 7,2017, at 10:18 AM, Stephen Wonfor <[hidden email]> wrote:
>
> I am running this in the data viewer in FMPA 15.
> Pardon the rather lame approach but this was done in a rush that has consumed far too much time.
> The point is to take the string value left of the “/“ char and then reverse its order.
> The pair of “t”s puzzle me.
>
> ………………………<Code>………………………
> Let([
> x = "tsrqponmlkjihfgedcba/356";
> l = Length(x);
> m = Position(x;"/";1;1);
> n = Middle(x; m + 1;3);
> r = Left(x;m - 1);
> q = Length(r);
> s =
> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
> Middle(r;q-16;1) &
> Case( q ≥ 17; Middle(r;q-17;1)) &
> Case( q ≥ 18; Middle(r;q-18;1)) &
> Case( q ≥ 19; Middle(r;q-19;1)) &
> Case( q ≥ 20; Middle(r;q-20;1)) &
> Case( q ≥ 21; Middle(r;q-21;1)) &
> Case( q ≥ 22; Middle(r;q-22;1)) &
> Case( q ≥ 23; Middle(r;q-23;1))
> ];
> q & ": " & s & " length of \"s\" is " & length(s) & "."
> )
> ………………………<End Code>………………………
>
> when I evaluate it I get this:
>
> 20: abcdegfhijklmnopqrstt length of "s" is 21.
>
> I’d prefer this as it is the “right” answer:
>
> 20: abcdegfhijklmnopqrst length of "s" is 20.
>
> Stephen
>
> ----
>
> “If debugging is the process of removing bugs, then programming must be the process of putting them in.” --- Edsger W. Dijkstra
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au



regards,
Darren

******************************
 Darren Terry
 Pacific Data Management, Inc.
 FileMaker Certified Developer
 Phone: (408) 283-5900 x7003
 Fax: (408) 283-5903
 [hidden email]
 http://www.pdm-inc.com/

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Stephen Wonfor-3
In reply to this post by Beverly Voth-3
Beverly

As noted I was in a rush.  Friday is not a good time to be in a rush;-)

Stephen

---

"What ended in 1896?"
"1895."

> On Apr 7, 2017, at 11:27 AM, BEVERLY VOTH <[hidden email]> wrote:
>
> there IS an additional 't' in the result, 20+1 = 21
> there are custom functions to reverse a string. :)
>
> beverly
>> On Apr 7, 2017, at 1:18 PM, Stephen Wonfor <[hidden email]> wrote:
>>
>> Let([
>> x = "tsrqponmlkjihfgedcba/356";
>> l = Length(x);
>> m = Position(x;"/";1;1);
>> n = Middle(x; m + 1;3);
>> r = Left(x;m - 1);
>> q = Length(r);
>> s =
>> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
>> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
>> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
>> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
>> Middle(r;q-16;1) &
>> Case( q ≥ 17; Middle(r;q-17;1)) &
>> Case( q ≥ 18; Middle(r;q-18;1)) &
>> Case( q ≥ 19; Middle(r;q-19;1)) &
>> Case( q ≥ 20; Middle(r;q-20;1)) &
>> Case( q ≥ 21; Middle(r;q-21;1)) &
>> Case( q ≥ 22; Middle(r;q-22;1)) &
>> Case( q ≥ 23; Middle(r;q-23;1))
>> ];
>> q & ": " & s & " length of \"s\" is " & length(s) & "."
>> )
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Stephen Wonfor-3
In reply to this post by Darren Terry-3
Hi

Found this one.

// Reverse
// by JT Hughes aka -Queue-

Case ( Length ( Alpha ) ;
    Right ( Alpha ; 1 ) &
    Reverse ( Left ( Alpha ; Length ( Alpha ) - 1 ) )
)

Needless to say it works.  Though my puzzlement remains on my desperate and inelegant solution.

Stephen



"Reality is what refuses to go away when I stop believing in it." — Philip K. Dick

> On Apr 7, 2017, at 11:30 AM, Darren Terry <[hidden email]> wrote:
>
> Hi Stephen: Don’t use ≥ in those Case statements. Use >.
>
>> On Apr 7,2017, at 10:18 AM, Stephen Wonfor <[hidden email]> wrote:
>>
>> I am running this in the data viewer in FMPA 15.
>> Pardon the rather lame approach but this was done in a rush that has consumed far too much time.
>> The point is to take the string value left of the “/“ char and then reverse its order.
>> The pair of “t”s puzzle me.
>>
>> ………………………<Code>………………………
>> Let([
>> x = "tsrqponmlkjihfgedcba/356";
>> l = Length(x);
>> m = Position(x;"/";1;1);
>> n = Middle(x; m + 1;3);
>> r = Left(x;m - 1);
>> q = Length(r);
>> s =
>> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
>> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
>> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
>> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
>> Middle(r;q-16;1) &
>> Case( q ≥ 17; Middle(r;q-17;1)) &
>> Case( q ≥ 18; Middle(r;q-18;1)) &
>> Case( q ≥ 19; Middle(r;q-19;1)) &
>> Case( q ≥ 20; Middle(r;q-20;1)) &
>> Case( q ≥ 21; Middle(r;q-21;1)) &
>> Case( q ≥ 22; Middle(r;q-22;1)) &
>> Case( q ≥ 23; Middle(r;q-23;1))
>> ];
>> q & ": " & s & " length of \"s\" is " & length(s) & "."
>> )
>> ………………………<End Code>………………………
>>
>> when I evaluate it I get this:
>>
>> 20: abcdegfhijklmnopqrstt length of "s" is 21.
>>
>> I’d prefer this as it is the “right” answer:
>>
>> 20: abcdegfhijklmnopqrst length of "s" is 20.
>>
>> Stephen
>>
>> ----
>>
>> “If debugging is the process of removing bugs, then programming must be the process of putting them in.” --- Edsger W. Dijkstra
>>
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
>
>
> regards,
> Darren
>
> ******************************
> Darren Terry
> Pacific Data Management, Inc.
> FileMaker Certified Developer
> Phone: (408) 283-5900 x7003
> Fax: (408) 283-5903
> [hidden email]
> http://www.pdm-inc.com/
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Mark Kimbrell
In reply to this post by Stephen Wonfor-3
Hi Stephen,

I sympathize. I think all of us have been in situations where we feel rushed, and abandon our normal methodology in favor of quickly hacking something together. Sometimes we get away with it, but often we end up spending way too much time trying to debug our shortcut. We end up totally stressed out, when a a more considered approach would have actually taken less time.

Time to find this custom function on BrianDunning.com <http://briandunning.com/>: 10 seconds.

// Reverse
// by JT Hughes aka -Queue-

Case ( Length ( Alpha ) ;
    Right ( Alpha ; 1 ) &
    Reverse ( Left ( Alpha ; Length ( Alpha ) - 1 ) )
)

Best,

Mark Kimbrell

Alchemy Consulting Group, LLC
FileMaker 11, 12, 13, 14, 15 Certified Developer
[hidden email]
888 663 6382

> On Apr 7, 2017, at 10:32 AM, Stephen Wonfor <[hidden email]> wrote:
>
> Beverly
>
> As noted I was in a rush.  Friday is not a good time to be in a rush;-)
>
> Stephen
>
> ---
>
> "What ended in 1896?"
> "1895."
>
>> On Apr 7, 2017, at 11:27 AM, BEVERLY VOTH <[hidden email]> wrote:
>>
>> there IS an additional 't' in the result, 20+1 = 21
>> there are custom functions to reverse a string. :)
>>
>> beverly
>>> On Apr 7, 2017, at 1:18 PM, Stephen Wonfor <[hidden email]> wrote:
>>>
>>> Let([
>>> x = "tsrqponmlkjihfgedcba/356";
>>> l = Length(x);
>>> m = Position(x;"/";1;1);
>>> n = Middle(x; m + 1;3);
>>> r = Left(x;m - 1);
>>> q = Length(r);
>>> s =
>>> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
>>> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
>>> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
>>> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
>>> Middle(r;q-16;1) &
>>> Case( q ≥ 17; Middle(r;q-17;1)) &
>>> Case( q ≥ 18; Middle(r;q-18;1)) &
>>> Case( q ≥ 19; Middle(r;q-19;1)) &
>>> Case( q ≥ 20; Middle(r;q-20;1)) &
>>> Case( q ≥ 21; Middle(r;q-21;1)) &
>>> Case( q ≥ 22; Middle(r;q-22;1)) &
>>> Case( q ≥ 23; Middle(r;q-23;1))
>>> ];
>>> q & ": " & s & " length of \"s\" is " & length(s) & "."
>>> )
>>
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Egon
+1

J. Hall
[hidden email]
C/T: 936-443-7653
Twitter: Egonx

> On Apr 7, 2017, at 1:17 PM, Mark Kimbrell <[hidden email]> wrote:
>
> Hi Stephen,
>
> I sympathize. I think all of us have been in situations where we feel rushed, and abandon our normal methodology in favor of quickly hacking something together. Sometimes we get away with it, but often we end up spending way too much time trying to debug our shortcut. We end up totally stressed out, when a a more considered approach would have actually taken less time.
>
> Time to find this custom function on BrianDunning.com <http://briandunning.com/>: 10 seconds.
>
> // Reverse
> // by JT Hughes aka -Queue-
>
> Case ( Length ( Alpha ) ;
>    Right ( Alpha ; 1 ) &
>    Reverse ( Left ( Alpha ; Length ( Alpha ) - 1 ) )
> )
>
> Best,
>
> Mark Kimbrell
>
> Alchemy Consulting Group, LLC
> FileMaker 11, 12, 13, 14, 15 Certified Developer
> [hidden email]
> 888 663 6382
>
>> On Apr 7, 2017, at 10:32 AM, Stephen Wonfor <[hidden email]> wrote:
>>
>> Beverly
>>
>> As noted I was in a rush.  Friday is not a good time to be in a rush;-)
>>
>> Stephen
>>
>> ---
>>
>> "What ended in 1896?"
>> "1895."
>>
>>> On Apr 7, 2017, at 11:27 AM, BEVERLY VOTH <[hidden email]> wrote:
>>>
>>> there IS an additional 't' in the result, 20+1 = 21
>>> there are custom functions to reverse a string. :)
>>>
>>> beverly
>>>> On Apr 7, 2017, at 1:18 PM, Stephen Wonfor <[hidden email]> wrote:
>>>>
>>>> Let([
>>>> x = "tsrqponmlkjihfgedcba/356";
>>>> l = Length(x);
>>>> m = Position(x;"/";1;1);
>>>> n = Middle(x; m + 1;3);
>>>> r = Left(x;m - 1);
>>>> q = Length(r);
>>>> s =
>>>> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
>>>> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
>>>> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
>>>> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
>>>> Middle(r;q-16;1) &
>>>> Case( q ≥ 17; Middle(r;q-17;1)) &
>>>> Case( q ≥ 18; Middle(r;q-18;1)) &
>>>> Case( q ≥ 19; Middle(r;q-19;1)) &
>>>> Case( q ≥ 20; Middle(r;q-20;1)) &
>>>> Case( q ≥ 21; Middle(r;q-21;1)) &
>>>> Case( q ≥ 22; Middle(r;q-22;1)) &
>>>> Case( q ≥ 23; Middle(r;q-23;1))
>>>> ];
>>>> q & ": " & s & " length of \"s\" is " & length(s) & "."
>>>> )
>>>
>>> _______________________________________________
>>> FMPexperts mailing list
>>> [hidden email]
>>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>>
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Richard DeShong
In reply to this post by Stephen Wonfor-3
Stephen, re: "puzzlement"

Darren's post, just below yours, is the fix for your code - change to
greater-than >

When q=23, your last line,
    Case( q ≥ 23; Middle(r;q-23;1))

calculates:
    Middle( r ; 0 ; 1 )

A zero for the Start is changed to 1 by FM client.  Thus:
    Middle( r ; 0 ; 1 )  returns the 1st char, "t"


On 4/7/2017 11:15 AM, Stephen Wonfor wrote:

> Hi
>
> Found this one.
>
> // Reverse
> // by JT Hughes aka -Queue-
>
> Case ( Length ( Alpha ) ;
>      Right ( Alpha ; 1 ) &
>      Reverse ( Left ( Alpha ; Length ( Alpha ) - 1 ) )
> )
>
> Needless to say it works.  Though my puzzlement remains on my desperate and inelegant solution.
>
> Stephen
>
> —
>
> "Reality is what refuses to go away when I stop believing in it." — Philip K. Dick
>
>> On Apr 7, 2017, at 11:30 AM, Darren Terry <[hidden email]> wrote:
>>
>> Hi Stephen: Don’t use ≥ in those Case statements. Use >.
>>
>>> On Apr 7,2017, at 10:18 AM, Stephen Wonfor <[hidden email]> wrote:
>>>
>>> I am running this in the data viewer in FMPA 15.
>>> Pardon the rather lame approach but this was done in a rush that has consumed far too much time.
>>> The point is to take the string value left of the “/“ char and then reverse its order.
>>> The pair of “t”s puzzle me.
>>>
>>> ………………………<Code>………………………
>>> Let([
>>> x = "tsrqponmlkjihfgedcba/356";
>>> l = Length(x);
>>> m = Position(x;"/";1;1);
>>> n = Middle(x; m + 1;3);
>>> r = Left(x;m - 1);
>>> q = Length(r);
>>> s =
>>> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
>>> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
>>> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
>>> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
>>> Middle(r;q-16;1) &
>>> Case( q ≥ 17; Middle(r;q-17;1)) &
>>> Case( q ≥ 18; Middle(r;q-18;1)) &
>>> Case( q ≥ 19; Middle(r;q-19;1)) &
>>> Case( q ≥ 20; Middle(r;q-20;1)) &
>>> Case( q ≥ 21; Middle(r;q-21;1)) &
>>> Case( q ≥ 22; Middle(r;q-22;1)) &
>>> Case( q ≥ 23; Middle(r;q-23;1))
>>> ];
>>> q & ": " & s & " length of \"s\" is " & length(s) & "."
>>> )
>>> ………………………<End Code>………………………
>>>
>>> when I evaluate it I get this:
>>>
>>> 20: abcdegfhijklmnopqrstt length of "s" is 21.
>>>
>>> I’d prefer this as it is the “right” answer:
>>>
>>> 20: abcdegfhijklmnopqrst length of "s" is 20.
>>>
>>> Stephen
>>>
>>> ----
>>>
>>> “If debugging is the process of removing bugs, then programming must be the process of putting them in.” --- Edsger W. Dijkstra
>>>
>>> _______________________________________________
>>> FMPexperts mailing list
>>> [hidden email]
>>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>>
>>
>> regards,
>> Darren
>>
>> ******************************
>> Darren Terry
>> Pacific Data Management, Inc.
>> FileMaker Certified Developer
>> Phone: (408) 283-5900 x7003
>> Fax: (408) 283-5903
>> [hidden email]
>> http://www.pdm-inc.com/
>>
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

--
Richard DeShong
Logic Tools
510-642-5123 office
925-285-1088 cell

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|

Re: Code Conundrum. It's always on a Friday. Can you spot the error? I can't.

Stephen Wonfor-3
Thanks to all for the sympathy and tips.

This was pretty interesting, thanks Richard:

A zero for the Start is changed to 1 by FM client.  Thus:
  Middle( r ; 0 ; 1 )  returns the 1st char, “t"

Reminds me of Date(12;0;2017) to get 11/30/2017

Stephen

---

"Rise Up Lights" = "Razor Blades" in Australian

> On Apr 7, 2017, at 1:03 PM, Richard DeShong <[hidden email]> wrote:
>
> Stephen, re: "puzzlement"
>
> Darren's post, just below yours, is the fix for your code - change to greater-than >
>
> When q=23, your last line,
>   Case( q ≥ 23; Middle(r;q-23;1))
>
> calculates:
>   Middle( r ; 0 ; 1 )
>
> A zero for the Start is changed to 1 by FM client.  Thus:
>   Middle( r ; 0 ; 1 )  returns the 1st char, "t"
>
>
> On 4/7/2017 11:15 AM, Stephen Wonfor wrote:
>> Hi
>>
>> Found this one.
>>
>> // Reverse
>> // by JT Hughes aka -Queue-
>>
>> Case ( Length ( Alpha ) ;
>>     Right ( Alpha ; 1 ) &
>>     Reverse ( Left ( Alpha ; Length ( Alpha ) - 1 ) )
>> )
>>
>> Needless to say it works.  Though my puzzlement remains on my desperate and inelegant solution.
>>
>> Stephen
>>
>> —
>>
>> "Reality is what refuses to go away when I stop believing in it." — Philip K. Dick
>>
>>> On Apr 7, 2017, at 11:30 AM, Darren Terry <[hidden email]> wrote:
>>>
>>> Hi Stephen: Don’t use ≥ in those Case statements. Use >.
>>>
>>>> On Apr 7,2017, at 10:18 AM, Stephen Wonfor <[hidden email]> wrote:
>>>>
>>>> I am running this in the data viewer in FMPA 15.
>>>> Pardon the rather lame approach but this was done in a rush that has consumed far too much time.
>>>> The point is to take the string value left of the “/“ char and then reverse its order.
>>>> The pair of “t”s puzzle me.
>>>>
>>>> ………………………<Code>………………………
>>>> Let([
>>>> x = "tsrqponmlkjihfgedcba/356";
>>>> l = Length(x);
>>>> m = Position(x;"/";1;1);
>>>> n = Middle(x; m + 1;3);
>>>> r = Left(x;m - 1);
>>>> q = Length(r);
>>>> s =
>>>> Middle(r;q;1 ) & Middle(r;q-1;1 ) & Middle(r;q-2;1) & Middle(r;q-3;1) &
>>>> Middle(r;q-4;1) & Middle(r;q-5;1) & Middle(r;q-6;1) & Middle(r;q-7;1) &
>>>> Middle(r;q-8;1) & Middle(r;q-9;1) & Middle(r;q-10;1) & Middle(r;q-11;1) &
>>>> Middle(r;q-12;1) & Middle(r;q-13;1) & Middle(r;q-14;1) & Middle(r;q-15;1) &
>>>> Middle(r;q-16;1) &
>>>> Case( q ≥ 17; Middle(r;q-17;1)) &
>>>> Case( q ≥ 18; Middle(r;q-18;1)) &
>>>> Case( q ≥ 19; Middle(r;q-19;1)) &
>>>> Case( q ≥ 20; Middle(r;q-20;1)) &
>>>> Case( q ≥ 21; Middle(r;q-21;1)) &
>>>> Case( q ≥ 22; Middle(r;q-22;1)) &
>>>> Case( q ≥ 23; Middle(r;q-23;1))
>>>> ];
>>>> q & ": " & s & " length of \"s\" is " & length(s) & "."
>>>> )
>>>> ………………………<End Code>………………………
>>>>
>>>> when I evaluate it I get this:
>>>>
>>>> 20: abcdegfhijklmnopqrstt length of "s" is 21.
>>>>
>>>> I’d prefer this as it is the “right” answer:
>>>>
>>>> 20: abcdegfhijklmnopqrst length of "s" is 20.
>>>>
>>>> Stephen
>>>>
>>>> ----
>>>>
>>>> “If debugging is the process of removing bugs, then programming must be the process of putting them in.” --- Edsger W. Dijkstra
>>>>
>>>> _______________________________________________
>>>> FMPexperts mailing list
>>>> [hidden email]
>>>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>>>
>>>
>>> regards,
>>> Darren
>>>
>>> ******************************
>>> Darren Terry
>>> Pacific Data Management, Inc.
>>> FileMaker Certified Developer
>>> Phone: (408) 283-5900 x7003
>>> Fax: (408) 283-5903
>>> [hidden email]
>>> http://www.pdm-inc.com/
>>>
>>> _______________________________________________
>>> FMPexperts mailing list
>>> [hidden email]
>>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> --
> Richard DeShong
> Logic Tools
> 510-642-5123 office
> 925-285-1088 cell
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au