none
Exception has been thrown by the target of an invocation RRS feed

  • Question

  • Here is my code: 

    turn=0
    Turtle.Speed=8
    For j=1 To 10
    turn=turn+36
    Turtle.Show()
    Turtle.PenDown()
    Turtle.Angle=360
    Turtle.Move(100)
    For i=1 To 3
    Turtle.Turn(90)
    Turtle.Move(35)
    EndFor
    Turtle.Turn(-90)
    Turtle.Move(65)
    Turtle.Angle=360
    Turtle.Turn(turn)
    EndFor

    And here is the error message:                                                                                                                                           

      at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at Microsoft.SmallBasic.Library.Internal.SmallBasicApplication.<>c__DisplayClass1.<.cctor>b__0()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

    I wasn't able to find anything helpful online and having reviewed my code multiple times, I still can't find any bugs in it.

    I'm running Windows 10 Home on a custom built PC with 8gigs of DDR4 2666MHz RAM, a R5 1600 @3.9GHz and a 1050Ti @1947MHz.

    Any help is appreciated!


    • Edited by edjfkf Tuesday, October 30, 2018 6:14 PM Added a few details
    Tuesday, October 30, 2018 6:10 PM

Answers

  • Hi,

    There is a known bug when Turtle.Show() is called more than once in a row.

    Below also crashes

    Turtle.Show()
    Turtle.Show()

    The following is OK, since the turtle is hidden between successive show commands

    Turtle.Show()
    Turtle.Hide()
    Turtle.Show()
    This bug should be fixed in future versions I hope.

    • Marked as answer by edjfkf Tuesday, October 30, 2018 8:03 PM
    Tuesday, October 30, 2018 6:27 PM
    Moderator
  • You can also move the Turtle.Show outside the for loop. Then the program reaches the end. The program draw the figure ten times in the smae direction. I found the first angle=360 should be removed


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Tuesday, October 30, 2018 6:42 PM added figure
    • Marked as answer by edjfkf Tuesday, October 30, 2018 8:04 PM
    Tuesday, October 30, 2018 6:39 PM
    Answerer

All replies

  • Hi,

    There is a known bug when Turtle.Show() is called more than once in a row.

    Below also crashes

    Turtle.Show()
    Turtle.Show()

    The following is OK, since the turtle is hidden between successive show commands

    Turtle.Show()
    Turtle.Hide()
    Turtle.Show()
    This bug should be fixed in future versions I hope.

    • Marked as answer by edjfkf Tuesday, October 30, 2018 8:03 PM
    Tuesday, October 30, 2018 6:27 PM
    Moderator
  • You can also move the Turtle.Show outside the for loop. Then the program reaches the end. The program draw the figure ten times in the smae direction. I found the first angle=360 should be removed


    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Tuesday, October 30, 2018 6:42 PM added figure
    • Marked as answer by edjfkf Tuesday, October 30, 2018 8:04 PM
    Tuesday, October 30, 2018 6:39 PM
    Answerer
  • It seems you're right. Thanks for your help!
    Tuesday, October 30, 2018 8:03 PM
  • It fixed it. Thanks for helping!
    Tuesday, October 30, 2018 8:03 PM