Hey all,
I am in the process of creating a personal application to help me in the workshop. This part of the app is giving me the most agro as I do not know where to start. (very new to Xojo). What I am trying to build is a fret calculator to help me calculate exactly where to saw slots into a fretboard to accommodate frets.
Here is an online example of a Fret Calculator.
https://manchesterguitartech.co.uk/fret-and-nut-calculators/fret-calculator/
Bellow is the code I found online for a fret calculator.
CLS
A = 0
X = 0
INPUT "Scale length? ",S
INPUT "# of frets ",N
PRINT "Fret distances from the nut"
PRINT
PRINT "Scale length: ";S;" mm"
PRINT
FOR B = 1 TO N
L = S - A
X = L / 17.817
A = A + X
PRINT "Distance to fret ";B;": ";A;" mm"
NEXT B
END
It is labelled as BASIC code but being new to xojo I’m not too sure if it is or what I am meant to do with it.
Above code was found here BuildYourGuitar.com :: Guitar Building Tips
Any help or guidance is greatly appreciated.
Create a new project
Add a text area to a window, called TextArea1
Add an Open event to the window
Put this code in it, and change the values for frets and neck length, then run it
textarea1.text = "" //like CLS
dim A as double = 0
dim X as double = 0
dim s as integer = 400 // change this to scale length in mm
dim N as integer = 22 // change this to number of frets
textarea1.text = "Fret distances from the nut" + endofline
textarea1.text =textarea1.text + "Scale length: " + format(s,"0") + " mm"+ endofline
textarea1.text =textarea1.text + endofline
dim L as double
FOR B as integer = 1 TO N
L = S - A
X = L / 17.817
A = A + X
textarea1.text =textarea1.text + "Distance to fret " + format(B,"0") + ": " + format (A,"0.00") + " mm" + endofline
NEXT
2 Likes
Jeff, I cannot thank you enough! using your code, I was able to figure out how to do it using x2 textfields and a button so I can input the number of frets and scale manually (Depending on what guitar I am making)
I put your code into the action event of a button, entering the Frets and scale in the TextFields and pressing the button, output the calculation in the textarea.
dim A as double = 0
dim X as double = 0
dim s as integer = Val(ScaleInput.text)
dim N as integer = val(FretInput.text)
textarea1.text = "Fret distances from the nut" + endofline
textarea1.text =textarea1.text + "Scale length: " + format(s,"0") + " mm"+ endofline
textarea1.text =textarea1.text + endofline
dim L as double
FOR B as integer = 1 TO N
L = S - A
X = L / 17.817
A = A + X
textarea1.text =textarea1.text + "Distance to fret " + format(B,"0") + ": " + format (A,"0.00") + " mm" + endofline
NEXT
Again thank you so so much!
3 Likes