I am a spaghetti coder. I know I could keep scripting in one (Sub/End Sub) but I am trying to learn why I may need functions within the script and how it may help, or if there is good reason to try and find potential functions within the sub. I have tried to create a functions enclosing the math but I am missing something as they are overlooked/skipped when debugged.
In a nutshell would finding and creating functions within the attached script help or is it acceptable without functions.
Just trying to learn
indent preformatted text by 4 spacesOption Explicit
'Script written by
'Script copyrighted by
'Script version Sunday, September 06, 2015 8:17:28 AM
Dim scaleLength : scaleLength = Rhino.GetReal("Enter scaleLength ") Dim numberFrets : numberFrets = Rhino.GetReal("Enter numberFrets") Dim lastFretDistance : lastFretDistance = scaleLength - (scaleLength / (2 ^ (numberFrets / 12))) Dim Yend : Yend = 2 'Y Work in progress 2" for gui representation. Taper math next Dim Zend : Zend = 0 'Work in Progress Dim Xstart : Xstart = 0 'G54 zero Dim Ystart : Ystart = 0 'G54 zero Dim Zstart : Zstart = 0 'G54 zero Dim fretSlot : fretSlot = 0 'Fret location counter 'Var fret @ fretSlot #0 == nut location and will need To be offset by half the mill kerf In the opposite direction of last fret Dim currPoint : currPoint = scaleLength - fret ' resets scale length math for the next fret during loop Dim fret : fret = 0 'X recursive location of the next fret by adding Var nextPoint to itself X location during loop Dim nextPoint : nextPoint = 0 'Math for each frets Location X Position during loop Dim divMath : divMath = 17.817'Scale length constant (fret 1 =(scale / 17.817) & (fret 2 = (scale - fret 1)/ 18.817)etc.. Rhino.MessageBox("Your G54 location will be = " & "X" & Xstart & " Y" & Ystart & " Z" & Zstart) 'Verify G54 location Dim nutToLast : nutToLast = Rhino.AddLine(Array(fret, Ystart, Zstart), Array(fret, Yend, Zend)) Do Until fretSlot = numberFrets nextPoint = currPoint / divMath nutToLast = Rhino.AddLine(Array(fret, yStart, zStart), Array(fret, yEnd, zEnd)) fret = fret + nextPoint currPoint = scaleLength - fret ' Math for each frets Location X Position fretSlot = fretSlot + 1 Rhino.Print(fret) Rhino.Print("Fret" & "#" & fretSlot) Loop 'nutToLast = Rhino.AddLine(Array(fret, yStart, zStart), Array(fret, yEnd, zEnd))'Last fret