none
@papalapub @litdev - why this program does not run properly ? RRS feed

  • Question

  •  

    this beautiful program by tryhest,  does not work properly on my computer ?

    JPT045

    i have SB v1.2 and latest LD extension update v 1.2.12

    The program start , so no errors regarding some missing statements,

    but instead of drawing this:

    it do this on my computer , any idea ?? and on your computer ?

    Sunday, October 30, 2016 8:57 PM
    Answerer

Answers

  • Both run fine: Here's a cleaner version of JPT045 -> ID: JPT045-0

    Do you have set as system default a comma ',' as decimal separator ??  I remember, i had massive problems running some progams with comma as decimal separator years ago. No more problems since i changed my settings.

    You should set point '.' as separator eg. 123.456  (under control panel - language/region settings) as your system default. Or look at "LDUtilities.GetCultureInvariantNumber"  for numbers.

    PS-Edit: see image here (at the bottom) LDControls Slider, can you...

    and look for LDUtilities.GetCultureInvariantNumber


    Sunday, October 30, 2016 11:52 PM
    Answerer
  • I'm sure Papa is right.  That's why I suggested replacing Convert2Cartesian with SB native code as it could be this with the , deliminator.

    So try this first, if it is Convert2Cartesian that is the problem then I can probably fix.  If not I would still like to diagnose which it is to fix.

    The code to test with is the orginal with Convert2Cartesian replaced (the 1 sec delay was just to see the first set of reseults easily).

    Sub tmov
      'mm=LDMath.Convert2Cartesian(tx ty dd tang-90)
      mm[1] = tx+dd*Math.Cos((tang-90)*Math.Pi/180)
      mm[2] = ty+dd*Math.Sin((tang-90)*Math.Pi/180)
      'TextWindow.WriteLine("FROM "+tx+" : "+ty)
      'TextWindow.WriteLine("TO   "+mm[1]+" : "+mm[2])
      GraphicsWindow.DrawLine (tx ty mm[1] mm[2])
      tx=mm[1]
      ty=mm[2]
      'Program.Delay(1000)
    EndSub 


    Test beta version uploaded to fix potential culture invariance for Convert2Cartesian.
    Monday, October 31, 2016 7:22 PM
    Moderator

All replies

  • Works fine for me.

    I would try simplifying and add WriteLine to show coords being drawn - looks like it goes wrong pretty early on - maybe also try LDDebug.

    Also some non standard syntax I would try changing, like:

    GraphicsWindow.title="Tree

    to

    GraphicsWindow.title="Tree" (end quote)

    and

    ldcall.Function ("tree"  330)

    to

    ldcall.Function ("tree",  330) (comma deliminated arguments)

    etc

    Sunday, October 30, 2016 9:07 PM
    Moderator
  • hi litdev !

    it's very interesting challenge to find what's goes wrong !!!

    it put all comas , possible, and " ,

    to follow.....

    Sunday, October 30, 2016 9:20 PM
    Answerer
  • here is what i have done so far:

    put all " and , possibles.

    i add a textwindow.writeline for the DD variable.

    it gives this in the textwindow output, long numbers , woo !!!

    here is the listing :

    _________________________________________________________________________________________

    args=0
    p=0
    GraphicsWindow.title="Tree"
    sub tree   ' :size
      p=p+1
      size[p]=args[1]
      'TextWindow.WriteLine(size[p]) ' data ok
      if size[p] < 5 then
       
        dd=size
        tmov()
        dd=size
        tmov()
      else
        dd= size[p]/3
        tmov()
        tang=tang- 30
       
        ldcall.Function ("tree", size[p]*2/3 )
        p=p-1
        tang=tang+ 30
       ' TextWindow.WriteLine(tang) ' data ok
       
        dd=size[p]/6
        tmov()
        tang=tang+ 25
       ldcall.Function ("tree", size[p]/2)
        p=p-1
        tang=tang - 25
       
        dd= size[p]/3
        tmov()
        tang=tang+ 25
        ldcall.Function ("tree", size[p]/2 )
        p=p-1
        tang=tang - 25
       
        dd=size[p]/6
        tmov()
        dd=-size[p]
        tmov()
       
      EndIf
    EndSub
    GraphicsWindow.left=10
    GraphicsWindow.top=10
    GraphicsWindow.Width =1500
    GraphicsWindow.Height=800
    GraphicsWindow.BackgroundColor ="teal"
    GraphicsWindow.PenWidth =1
    GraphicsWindow.PenColor ="lime"
    tx=600
    ty=600
    tang=-20
    ldcall.Function ("tree" , 330)
    tx=600
    ty=600
    tang=20
    ldcall.Function ("tree" , 330)
    tx=600
    ty=600
    tang=40
    ldcall.Function ("tree", 300)

    Sub tmov
      mm=LDMath.Convert2Cartesian(tx ,ty, dd ,tang-90)
      GraphicsWindow.DrawLine (tx, ty, mm[1], mm[2])
      TextWindow.WriteLine(dd)
      tx=mm[1]
      ty=mm[2]
    EndSub

    ________________________________________________________________________________________

    Sunday, October 30, 2016 9:35 PM
    Answerer
  • Try replacing Convert2Cartesian with, this is all it does:

      mm[1] = tx+dd*Math.Cos((tang-90)*Math.Pi/180)
      mm[2] = ty+dd*Math.Sin((tang-90)*Math.Pi/180)

    And print out tx,ty,mm

    Sub tmov
      'mm=LDMath.Convert2Cartesian(tx ty dd tang-90)
      mm[1] = tx+dd*Math.Cos((tang-90)*Math.Pi/180)
      mm[2] = ty+dd*Math.Sin((tang-90)*Math.Pi/180)
      TextWindow.WriteLine("FROM "+tx+" : "+ty)
      TextWindow.WriteLine("TO   "+mm[1]+" : "+mm[2])
      GraphicsWindow.DrawLine (tx ty mm[1] mm[2])
      tx=mm[1]
      ty=mm[2]
      Program.Delay(1000)
    EndSub 

    Sunday, October 30, 2016 9:50 PM
    Moderator
  • Ok we are getting closer !!

    retouched program:  CLG849

    i have copy and paste this part :  sub tmov

    Here is what is look like after  4 minutes of running ( tree began to draw )

    here is a print out  for : tx, ty, mm



    • Edited by YLedEditor Sunday, October 30, 2016 11:18 PM
    Sunday, October 30, 2016 11:09 PM
    Answerer
  • Both run fine: Here's a cleaner version of JPT045 -> ID: JPT045-0

    Do you have set as system default a comma ',' as decimal separator ??  I remember, i had massive problems running some progams with comma as decimal separator years ago. No more problems since i changed my settings.

    You should set point '.' as separator eg. 123.456  (under control panel - language/region settings) as your system default. Or look at "LDUtilities.GetCultureInvariantNumber"  for numbers.

    PS-Edit: see image here (at the bottom) LDControls Slider, can you...

    and look for LDUtilities.GetCultureInvariantNumber


    Sunday, October 30, 2016 11:52 PM
    Answerer
  • Hi Papa !

    Do you have set as system default a comma ',' as decimal separator ?? 

    yes i have , it's regional setting for my country,

    so ok , you find why  there is some programs that will or won't work for my computer.

    Thnaks for you answer :)

    but i will leave my coma decimal separator as my regional default setting.

    • Marked as answer by YLedEditor Monday, October 31, 2016 1:03 AM
    • Unmarked as answer by YLedEditor Monday, October 31, 2016 1:03 AM
    Monday, October 31, 2016 1:03 AM
    Answerer
  • I'm sure Papa is right.  That's why I suggested replacing Convert2Cartesian with SB native code as it could be this with the , deliminator.

    So try this first, if it is Convert2Cartesian that is the problem then I can probably fix.  If not I would still like to diagnose which it is to fix.

    The code to test with is the orginal with Convert2Cartesian replaced (the 1 sec delay was just to see the first set of reseults easily).

    Sub tmov
      'mm=LDMath.Convert2Cartesian(tx ty dd tang-90)
      mm[1] = tx+dd*Math.Cos((tang-90)*Math.Pi/180)
      mm[2] = ty+dd*Math.Sin((tang-90)*Math.Pi/180)
      'TextWindow.WriteLine("FROM "+tx+" : "+ty)
      'TextWindow.WriteLine("TO   "+mm[1]+" : "+mm[2])
      GraphicsWindow.DrawLine (tx ty mm[1] mm[2])
      tx=mm[1]
      ty=mm[2]
      'Program.Delay(1000)
    EndSub 


    Test beta version uploaded to fix potential culture invariance for Convert2Cartesian.
    Monday, October 31, 2016 7:22 PM
    Moderator
  • Hi Litdev !

    you'r Genius, you find it , wow !! wonderful !!!!!!!!

    and without to have to change my regional settings., so comma is my decimal default separator.

    here is the program wth a bit of colors re-design by myself.

    and it takes only 10 seconds to draw to entire tree., thanks !!!

    program: BZW527

    Monday, October 31, 2016 8:30 PM
    Answerer
  • Good, can you also please check if the new beta version of the extension I uploaded works with the original method.

    Sub tmov 
      mm=LDMath.Convert2Cartesian(tx ty dd tang-90)
      'mm[1] = tx+dd*Math.Cos((tang-90)*Math.Pi/180)
      'mm[2] = ty+dd*Math.Sin((tang-90)*Math.Pi/180)
      'TextWindow.WriteLine("FROM "+tx+" : "+ty)
      'TextWindow.WriteLine("TO   "+mm[1]+" : "+mm[2])
      GraphicsWindow.DrawLine (tx ty mm[1] mm[2])
      tx=mm[1]
      ty=mm[2]
      'Program.Delay(1000)
    EndSub  


    Monday, October 31, 2016 8:39 PM
    Moderator
  • Super Man !!!

    beta LD extension work fine !!

    here is the program:   MSV074

    the output in a couples of seconds, this is a real cool program, fractal i think isn't it ?

    Monday, October 31, 2016 9:02 PM
    Answerer