Small Basic Searching for ET (Equilateral Triangle) Program Error RRS feed

  • Question

  • I am writing a Small Basic program called Searching for ET (Equilateral Triangles).   The program should find and draw any or all equilateral triangles in a triangle of 66 latice points where 66 numbers or letters are assigned via keyboard entry to a variable array called ET(i).

    I have entered 507 triangle coordinates into the program that will end up with a total of 715 triangle coordinates when completed.  When I run the from Small Basic, the first 482 triangles will display if I put EndSub at the end of the 482nd triangle coordinates.  However, when I put EndSub at the end of the 483rd triangle coordinates (ET-483), I get an error.

    The Sub DrawSolution can be moved anywhere within the list of 507 ETs with EndSub added to test smaller sections of the code.

    I created an online zip folder where image files of the error message and screen shots along with the can be found:!2189&authkey=!ABaF3PeQ52DUwn0&ithint=folder%2czip

    Feel free to access the, but make a copy and if the code can be improved upon, or the error message fixed by modifying the code, please add an updated file with a new name in the ET-Program folder.

    Image1 is a command window where I entered 66 '1's and selected '1' to draw the ET Puzzle shown in Image2.

    Image3 shows EndSub (line 5849) after ET-483 code causes an error (ET-Program_error.gif)  Timeout or program size problem?

    Image4 shows EndSub (line 5835) after ET-482 code that works.  See Image5 and Image6.

    Image7 and Image8 shows actual results of how the program will work if using EndSub after ET-482.  

    I hope the above information is clear.  I do not know programming very well, and will certainly appreciate any assistance from the MSDN developers community.

    Tuesday, August 18, 2015 2:32 AM


  • I solved the problem by splitting the 507 triangle coordinates into two subroutines - Sub DrawSolution() and Sub DrawNextSolution.  Therefore, the timeout issue no longer occurs.  I am removing the online file share.

    Thanks for everyone's support.

    • Marked as answer by Eugenetics Tuesday, August 18, 2015 9:45 PM
    Tuesday, August 18, 2015 9:38 PM

All replies

  • (translated by Google translator)

    I downloaded your archive and I will try to help you.

    Tuesday, August 18, 2015 4:56 AM
  • (translated by Google translator)

    The first mistake that I see - do not place the code of the subroutine inside the main program code. If you moved the keyword "EndSub" on a few lines above, the code that remained outside the routines you must to disable.

    Do it and see how the program will work.

    Tuesday, August 18, 2015 6:07 AM
  • (translated by Google translator)

    TextWindow.Write("Write 66 numbers or letters:")
    ETdata = "123456123456123456123456123456123456123456123456123456123456123456" 'TextWindow.Read()
    For i = 1 To 66 
      et[i] = Text.GetSubText(ETdata, i, 1)

    I changed one line of code, and I checked how the program works with 507 triangles. On my computer, no error occurs.

    I am waiting for your thoughts...

    Tuesday, August 18, 2015 6:55 AM
  • Thanks for your quick response.  I originally hard coded the ETData value of 66 numbers such as your example, but still got the error after ET-482.  Did you get the same error that I got when running the program with keyboard assigned numbers?

    I am running Windows 7 Home Premium w/4.0  Gig Ram on 64 bit OP System HP Laptop, and not sure of the version of Small Basic.  What computer, op system, and version of Small Basic are you using?  How do I check my version of Small Basic and can I get an updated version if needed?

    • Edited by Eugenetics Tuesday, August 18, 2015 1:05 PM
    Tuesday, August 18, 2015 12:59 PM
  • I don't know if you understand fully the Google translation wich AbsoluteBeginner published as first answer.

    You cannot put EndSub at will after part of the program you want test. The part after that EndSub will become part of the main program. You need to have only the EndSub just before  Sub DrawPuzzle and NO  EndSub's between your ET-xxx parts.

    If you want to swith off a big part of the program, you can put  a    "If 0=1 Then"   just before   and a  "EndIf"  just after that part. Then that block will not be executed.

    Jan [ WhTurner ] The Netherlands

    Tuesday, August 18, 2015 1:21 PM
  • I just now downloaded the current version of Small Basic on another HP Laptop w/4.0 Gig Ram on 64 Bit Op System (Windows 8.1) and duplicated the same error as originally mentioned.

    For testing, use 66 '1's or 66 of the same number or letter to check the complete functionality of the program.  By placing EndSub after ET-482 code, the program works fine.

    However, by placing EndSub after ET-483 code or at the end of ET-507, I get the same error.

    Is there a way to get around the timeout issue if that is what it is?  

    I am writing a book called Searching for ET (Equilateral Triangles), and the program will be part of the book.

    Thanks for your help.

    Tuesday, August 18, 2015 1:51 PM
  • (translated by Google translator)

    OK. I'll try again now.

    Tuesday, August 18, 2015 4:42 PM
  • Thanks for your reply and suggestion for blocking parts of code with If / EndIf code.  Do you have any idea why the program gets an error (times out I'm assuming) if the EndSub is just before Sub DrawPuzzle?

    Have you tried running the code to see if it works?

    Tuesday, August 18, 2015 4:46 PM
  • (translated by Google translator)

    I'm sorry. I tried to do everything. But, an error message does not appear.

    I have Windows 8.1 and Small Basic 1.1...

    Tuesday, August 18, 2015 5:31 PM
  • I tried you program with then Endsub after ET-482. after ET-483 and after ET-407. I got no errors.

    I have some additions to your program : put with the GraphicsWindow statements a statement  GraphicsWindow.Height=600, then the triangle fits in the window. To make the entering of the 66 chars handier I changed that part to:

    'Keyboard assigned  variable values 
    TextWindow.WriteLine("Write 66 numbers or letters:")
    TextWindow.WriteLine("123456789 123456789 123456789 123456789 123456789 123456789 123456")
    ETdata = TextWindow.Read()

    Then you can see how many characters to input.

    I run this on Windows 8.1, with Small Basic version 1.1

    Jan [ WhTurner ] The Netherlands

    Tuesday, August 18, 2015 5:33 PM
  • I solved the problem by splitting the 507 triangle coordinates into two subroutines - Sub DrawSolution() and Sub DrawNextSolution.  Therefore, the timeout issue no longer occurs.  I am removing the online file share.

    Thanks for everyone's support.

    • Marked as answer by Eugenetics Tuesday, August 18, 2015 9:45 PM
    Tuesday, August 18, 2015 9:38 PM
  • You can replace the 66 lines of the subroutine DrawPuzzle by using the floowing 16 lines:

    For i=1 To 66
    For v=0 To N
      For h=-v To v Step 2

    Jan [ WhTurner ] The Netherlands

    Wednesday, August 19, 2015 9:15 AM
  • Jan, I have not been back to this MSDN site for quite a while since my code was working.  However, I noticed that you provided some excellent code ideas and optimizations that will help my future code projects.  Thanks so much for helping me.  You can see the first of ten new books on Amazon that will soon be published based on the Search for E.T. (Equilateral Triangle) code.  Look for all the new puzzle books coming out shortly.

    Once again, thanks!!!!  Also, thanks to the whole MSDN community for supporting and helping novice programmers like myself.

    Thursday, December 17, 2015 5:56 PM