locked
Decimal separator in LDCall () return value RRS feed

  • General discussion

  • I am a fan of the artwork by TRYHEST.

    Unfortunately, they don't always work, like the new ZZH861 program, for example.

    Of the 6 figures, "Bird" does not work properly.

    It is the only figure in which the LDCall function calls are used for the calculation.

    The return value is culture variant and in many countries the decimal separator is a comma ",". The following SmallBasic functions cannot do anything with this, since Small Basic culture invariant always has the decimal point "." used.

    This can be corrected with LDText.Replace (xxx, ",", ".")
    Or with
    LDUtilities.GetCultureInvariantNumber (ldcall.function ("xxx", par)),

    but this increases the size of the program and the clarity suffers.

    Sub cosp
      return =ldmath.cos(180*args[1])
    EndSub
    
    Sub sinp
      return =ldmath.sin(180*args[1])
    EndSub
    
    Sub Yhead
      k=args[1]
      yhead1 = LDUtilities.GetCultureInvariantNumber(ldcall.function("cosp" 0.3*k))
      yhead2 = LDUtilities.GetCultureInvariantNumber(ldcall.function("cosp" 0.9*k))
      yhead3 = LDUtilities.GetCultureInvariantNumber(ldcall.function("cosp" 1.8*k))
      return=-1/3*Math.Power(yhead1*yhead2*yhead3 10)
    EndSub
    
    Sub Yf
      k=args[1]
      yf1 = LDUtilities.GetCultureInvariantNumber(ldcall.function("cosp" 0.5*k))
      yf2 = LDUtilities.GetCultureInvariantNumber(ldcall.function("cosp" 1.5*k))
      return =2/3+math.Power(yf1*yf2 6)
    EndSub
    
    Sub wx
      k=args[1]
      wx1 = ldcall.function("cosp" 41*k)
      wx1 = LDText.Replace(wx1,",", ".")
      wx2 = ldcall.function("sinp" math.Power(k 7)/2)
      wx2 = LDText.Replace(wx2,",", ".")
      return=2/3*Math.Power( wx1  6) * wx2 
      'return=2/3*Math.Power( ldcall.function("cosp" 41*k) 6)* ldcall.function("sinp" math.Power(k 7)/2)
    EndSub
    
    Sub wy
      k=args[1]
      wy1 = ldcall.function("cosp" 41*k)
      wy1 = LDText.Replace(wy1,",", ".")
      wy2 = ldcall.function("cosp" math.Power(k 7)/2)
      wy2 = LDText.Replace(wy2,",", ".")
      return=Math.Power(wy1  6) * wy2 
    EndSub
    
    Sub Xtail
      k=args[1]
      xtail1 = ldcall.function("cosp" 41*k)
      xtail1 = LDText.Replace(xtail1,",", ".")
      xtail2 = ldcall.function("cosp" 0.5*k)
      xtail2 = LDText.Replace(xtail2,",", ".")
      xtail3 = ldcall.function("sinp" 6*k)
      xtail3 = LDText.Replace(xtail3,",", ".")
      return=1/6*Math.Power(xtail1  16)*Math.Power(xtail2 12)* xtail3
      'return=1/6*Math.Power( ldcall.function("cosp" 41*k) 16)*Math.Power(ldcall.function("cosp" 0.5*k) 12)*ldcall.function("sinp" 6*k)
    EndSub
    
    Sub Rtail
      k=args[1]
      rtail1 = ldcall.function("cosp" 41*k)
      rtail1 = LDText.Replace(rtail1,",", ".")
      rtail2 = ldcall.function("cosp" 0.5*k)
      rtail2 = LDText.Replace(rtail2,",", ".")
      return=1/30*Math.Power(rtail1 2)*Math.Power(rtail2 10)
      'return=1/30*Math.Power(ldcall.function("cosp" 41*k) 2)*Math.Power(ldcall.function("cosp" 0.5*k) 10)
    EndSub
    
    Sub Rwing
      k=args[1]
      rwing1 = ldcall.function("sinp" 41*k)
      rwing1 = LDText.Replace(rwing1,",", ".")
      rwing2 = ldcall.function("sinp" 0.9*k)
      rwing2 = LDText.Replace(rwing2,",", ".")
      return=1/15*Math.Power(rwing1 2)*Math.Power(rwing2 2)
    EndSub
    
    Sub Bird
      GraphicsWindow.BackgroundColor="darkblue
      GraphicsWindow.PenColor="cyan
      GraphicsWindow.Clear()
      GraphicsWindow.Title="Eagle
      GraphicsWindow.Width=777
      GraphicsWindow.PenWidth=.2
      GraphicsWindow.Height=655
      f100=200
      d100=360
      f110=540
      For kk=-1 To 1 Step .0001
        
        X1 = ldcall.Function( "wx" kk)
        X1 =LDText.Replace(X1,",", ".")
        X2 = ldcall.Function( "Xtail" kk)
        X2 =LDText.Replace(X2,",", ".")
        'X =kk+ldcall.Function( "wx" kk)+ldcall.Function( "Xtail" kk)
        X =kk + X1 + X2
        X =LDText.Replace(X,",", ".")
        Y1 = ldcall.Function( "Yf" kk)
        Y1 = LDText.Replace(Y1,",", ".")
        Y2 = ldcall.Function( "wy" kk)
        Y2 =LDText.Replace(Y2,",", ".")
        Y3 = ldcall.Function( "Yhead" kk)
        Y3 =LDText.Replace(Y3,",", ".")
        Y =Y1*Y2+Y3
        'Y =ldcall.Function( "Yf" kk)*ldcall.Function( "wy" kk)+ldcall.Function( "Yhead" kk)
        Y =LDText.Replace(Y,",", ".")
        R1 = ldcall.Function( "Rwing" kk)
        R1 = LDText.Replace(R1,",", ".")
        R2 = ldcall.Function( "Rtail" kk)
        R2 =LDText.Replace(R2,",", ".")
        R = 1/75+R1+R2
        'R =1/75+ldcall.Function( "Rwing" kk)+ldcall.Function( "Rtail" kk)
        R =LDText.Replace(R,",", ".")
        GraphicsWindow.DrawEllipse(x*f100+d100-r*f110/2 d100+f100*Y-r*f110/2 r*f110 r*f110)
      EndFor
    EndSub
    From my point of view, it would be best if the return from LDCall () were culture invariant since Small Basic uses this internally. The culture can still be used for I / O, but I see LDCall () more as an internal function.
    Maybe someone has a better idea too.



    Friday, October 23, 2020 8:29 PM

All replies

  • As I said in your other topic: put
    LDUtilities.CurrentCulture="en-US"
    as the first line. This is the easiest way.

    Jan [ WhTurner ] The Netherlands


    • Edited by WhTurner33Editor Monday, October 26, 2020 2:39 PM added "en-" in command
    Monday, October 26, 2020 1:17 PM
    Answerer
  • Thank you Jan,

    that is the solution. Embarrassingly, I've even used it once in tryhest's Julia Set ZRG510.

    I think this is also the best solution as no further intervention is necessary.
    The culture definition "US" runs into an error for me. I have to enter the following:


    Monday, October 26, 2020 2:14 PM