'======================================= 'Ray Solomon - 7-14-2019 '======================================= secondtime = 0 'loop back here to write another output file BigRepeat: path = Program.Directory filename = path+"\abc.txt" retype: TextWindow.Clear() TextWindow.WriteLine("Sisyphus Text Generator") TextWindow.WriteLine("Please type filename to output - without .thr (and hit return)") textline = TextWindow.Read() xy = textline xy = xy + ".thr" TextWindow.Clear() TextWindow.Write("Your output file will be called: ") TextWindow.Write(xy) TextWindow.WriteLine(" ") TextWindow.WriteLine(" ") TextWindow.WriteLine("if correct please type Y (and hit return) ") textline = TextWindow.Read() If(textline = "Y" Or textline = "y") Then Goto rety endif Goto retype rety: xy = "\"+ xy filePath = path+xy 'zero output file a = File.WriteContents(filePath,"0,0") TextWindow.WriteLine(a) If(a = "FAILED") Then TextWindow.WriteLine(" ") TextWindow.WriteLine("Problem Writing your file ") TextWindow.WriteLine("Try again by hitting enter") TextWindow.Read() Goto retype endif ' this erases the field before writing letters - can be any of the numbers in green for tighter spiral (but longer) background '============================== linx = 3 'zoffset = 471.2389 'zoffset = 628.318 'zoffset = 235.619449 'zoffset = 706.8583 'zoffset = 0 zoffset =157.0795 File.WriteLine(FilePath,1,"0 0") File.WriteLine(FilePath,2,"157.0795 1") '==================================================== letters = 1 xmul = 2.8 ymul = 1.4 ROTANG = -Math.pi/2 'ROTANG = 0 If(secondtime = 1) then Goto skipreadchr endif TextWindow.Clear() TextWindow.WriteLine("Please Wait - reading data file") '----------------------------------------------------------------------------- ' reads line for line, saves values to csv and shows them '----------------------------------------------------------------------------- line = File.ReadLine(filename, line_number) 'check for proper read of abc.txt data file - exit if it isn't there If(line = "") Then TextWindow.WriteLine("Can't find abc.txt file - please put into same directory") Goto endout endif While line <> "" comma_position1 = Text.GetIndexOf(line, " ") nextblank = Text.GetSubTextToEnd(line, comma_position1+1) comma_position2 = Text.GetIndexOf(nextblank, " ") number[line_number] = Text.GetSubText(line, 1, comma_position1-1) XChr[line_number] = Text.GetSubText(nextblank, 1, comma_position2-1) yChr[line_number] = Text.GetSubTextToEnd(nextblank, comma_position2+1) line_number = line_number + 1 line = File.ReadLine(filename, line_number) EndWhile 'startz = 1 endf = line_number -1 i = 1 ' initialize first letter from position 1 start[letters] = 1 z = i start_x[letters] = xChr[1] start_y[letters] = yChr[1] For i = 2 To endf z= i If (number[i] <>1) then Goto skip2 EndIf ends[letters] = i-1 end_x[letters] = xChr[i-1] end_y[letters] = yChr[i-1] letters = letters + 1 start[letters] = i start_x[letters] = xChr[i] start_y[letters] = yChr[i] skip2: EndFor ends[letters] = endf end_x[letters] = xChr[endf] end_y[letters] = yChr[endf] xy = Text.Append("number of data points read ",endf) TextWindow.WriteLine(xy) xy = Text.Append("number of characters in data ",letters) TextWindow.WriteLine(xy) For i = 1 To endf count = i zz = Text.GetLength(xChr[i]) If (zz> 9) Then zz = 9 EndIf x1 = Text.getsubtext(xChr[i],1,zz) xChr[i] = x1 zz = Text.GetLength(yChr[i]) If (zz> 9) Then zz = 9 EndIf y1 = Text.getsubtext(yChr[i],1,zz) yChr[i] = y1 If (Math.Abs(xChr[i]) < .00001) Then xChr[i] = 0 EndIf If (Math.Abs(yChr[i]) < .00001) Then yChr[i] = 0 EndIf endfor skipreadchr: writepos = 0 ydisp = .22 ' baseline is y disp +.1*ymul for .22 it equals .36 line2 = 0 linelen = 1.56 bigloop: loopback: ' get the line of text TextWindow.Clear() loop: If (line2 =2) then TextWindow.WriteLine("Write third text line") endif If (line2 = 1) then TextWindow.WriteLine("Write second text line") EndIf If (line2 = 0) then TextWindow.WriteLine("Write first text line") endif textline = TextWindow.Read() ab = Text.GetLength(textline) For i = 1 To ab chr = Text.getSubText(textline,i,1) ac[i] = Text.GetCharacterCode(chr) 'space If(ac[i] = 32) Then Goto skip4 endif ' less than numbers If (ac[i] <48) Then TextWindow.WriteLine("illegal character in string") Goto loop EndIf 'between numbers and capital letters If ( ac[i] > 57 And ac[i] < 65) Then TextWindow.WriteLine("illegal character in string") Goto loop EndIf ' between capital and small If ( ac[i] > 90 And ac[i] < 97) Then TextWindow.WriteLine("illegal character in string") Goto loop EndIf If (ac[i] >122) Then TextWindow.WriteLine("illegal character in string") Goto loop EndIf skip4: endfor ' now make a data output of the text line xstart = 0 outline = 1 'first character is lower start point - do separate 'space If(ac[1] = 32) Then disp = 1 endif If (ac[1] >47 And ac[1] <58) Then disp = ac[1] -46 EndIf If ( ac[1] > 64 And ac[1] < 91) Then disp = ac[1] -53 EndIf If ( ac[1] > 96 And ac[1] < 123) Then disp = ac[1] -59 EndIf stz = start[disp] enz = ends[disp] For j = stz To enz xstr[outline] = xChr[j]*xmul + xstart ystr[outline] = yChr[j]*ymul ' outline = outline +1 EndFor xstart = xChr[enz]*xmul For i = 2 to ab If(ac[i] = 32) Then disp = 1 endif If (ac[i] >47 And ac[i] <58) Then disp = ac[i] -46 EndIf If ( ac[i] > 64 And ac[i] < 91) Then disp = ac[i] -53 EndIf If ( ac[i] > 96 And ac[i] < 123) Then disp = ac[i] -59 EndIf last = ac[i-1] ' b o, v, w , trigger upper If (last = 98) Then disp = disp +27 EndIf If (last = 111) Then disp = disp +27 EndIf If (last = 118) Then disp = disp +27 EndIf If (last = 119) Then disp = disp +27 EndIf stz = start[disp] enz = ends[disp] stz = stz +1 For j = stz To enz xstr[outline] = xChr[j]*xmul +xstart ystr[outline] = yChr[j]*ymul outline = outline +1 EndFor xstart = xstr[outline-1] endfor xlen = xstart xy = Text.Append("your line length is ",xlen) xy = Text.Append(xy," of a maximum ") xy = Text.Append(xy,linelen) TextWindow.WriteLine(xy) Program.Delay(1500) If (xlen > linelen) then TextWindow.WriteLine("text too long") Goto loopback endif centtext = (2 - xlen)/2 -1.0 ' center it 'now generate a line to start point y1 = ydisp + .1 *ymul linest = -(Math.Squareroot(1 - y1*y1) -.02) x1 = linest ' keep the start point of this line startwrite = writepos +1 loopsz: If(Math.Abs(centtext) < Math.Abs(x1)) Then writepos = writepos +1 xpic[writepos] = x1 ypic[writepos] = y1 x1 = x1 + .005 Goto loopsz endif ' go to the outside 'reverse sides of table For line on other side linest = - linest For i = 1 to outline -1 xstr[i] = xstr[i] + centtext ystr[i] = ystr[i] + ydisp xpic[i+writepos] = xstr[i] ypic[i+writepos] = ystr[i] endfor writepos = writepos + outline -1 ' now generate a line on the other side from the end of the text x1 = Math.Abs(centtext) y1 = ydisp + .1*ymul loop2sz: If(Math.Abs(x1) >= Math.Abs(linest)) Then Goto loopout EndIf writepos = writepos +1 x1 = x1 + .005 xpic[writepos] = x1 ypic[writepos] = y1 Goto loop2sz 'write last x point at linest, y1 loopout: writepos = writepos +1 x1 = linest xpic[writepos] = x1 ypic[writepos] = y1 ' save the end point for the side drop points to the next line oldlinest = linest endwrite = writepos ' start position for line 2 in outlet file If ( line2 = 2) then Goto finish endif line2 = line2 +1 If (line2 = 1) then ydisp = -.2 linelen = 1.9 EndIf If (line2 = 2) then ydisp = -.62 linelen = 1.56 endif '========================================= Goto loopback finish: ' write it alll out TextWindow.WriteLine("Working hard here") For i = 1 To writepos ' rotate and mirror and set up final value as x[i], y[i] for polar conversion 'mirror it If(xpic[i] < 0) Then xpic[i] = Math.Abs(xpic[i]) else xpic[i] = -xpic[i] EndIf 'rotate it x1 = xpic[i] *Math.cos(ROTANG) - ypic[i] *Math.sin(ROTANG) y1 = xpic[i] *MAth.sin(ROTANG) + ypic[i] *Math.cos(ROTANG) '================================ zz = Text.GetLength(x1) If (zz> 9) Then zz = 9 EndIf x1 = Text.getsubtext(x1,1,zz) zz = Text.GetLength(y1) If (zz> 9) Then zz = 9 EndIf y1 = Text.getsubtext(y1,1,zz) 'check limits If (Math.SquareRoot(x1*x1+y1*y1)>1) Then TextWindow.WriteLine("values out of range") Goto endout endif x[i] = x1 y[i] = y1 endfor direct[1] = 1 counter = writepos line_number = 1 For i = 1 To counter Quadrant() endfor line_number = 1 ' convert x y to polar For j = 1 to counter z= x[j]*x[j] + y[j]*y[j] rer[j] = Math.SquareRoot(z) If rer[j] = 0 Then reang[j] = 0 else z = x[j]/rer[j] reang[j] = Math.ArcCos(z) endif rxang[j] = reang[j] i = j Normalize() endfor line_number = 1 'now do Thet sum up diff[1] = reang[1] sum[1] = diff[1] sm[1] = sum[1] x1 = sm[1] +zoffset y1 = rer[1] zz = Text.GetLength(x1) If (zz> 9) Then zz = 9 EndIf x1 = Text.getsubtext(x1,1,zz) zz = Text.GetLength(y1) If (zz> 9) Then zz = 9 EndIf y1 = Text.getsubtext(y1,1,zz) xy = "" xy = Text.Append(xy,x1) xy = Text.Append(xy," ") xy = Text.Append(xy,y1) File.WriteLine(FilePath,linx,xy) linx = linx+1 For i = 2 to counter diff[1] = reang[1] sum[1] = diff[1] If Pos[i-1] = 0 Then diff[i] = reang[i] sum[i] = diff[i] + sum[i-1] Goto dfg endif diff[i] = reang[i]-reang[i-1] sum[i] = diff[i] + sum[i-1] dfg: sm[i] = sum[i] endfor '===============last cleanup smx[1] = sm[1] adder = 0 For i = 2 To counter neg = 0 If(sm[i-1] < 0 ) Then neg = 1 endif s1abs = Math.abs(sm[i-1]/(Math.Pi*2)) s2abs = Math.abs(sm[i]/(Math.Pi*2)) s1flor = Math.Floor(s1abs) s2flor = Math.Floor(s2abs) s1dec = s1abs - s1flor s2dec = s2abs - s2flor as = Math.Abs(s1dec-s2dec) If (as > .85) Then adder = (s1flor +1) *2*Math.Pi +adder If(neg = 1) then adder = -(s1flor +1) *2*Math.Pi +adder EndIf endif smx[i] = sm[i] +adder endfor For i = 2 To counter x1 =smx[i] +zoffset y1 = rer[i] zz = Text.GetLength(x1) If (zz> 9) Then zz = 9 EndIf x1 = Text.getsubtext(x1,1,zz) zz = Text.GetLength(y1) If (zz> 9) Then zz = 9 EndIf y1 = Text.getsubtext(y1,1,zz) xy = "" xy = Text.Append(xy,x1) xy = Text.Append(xy," ") xy = Text.Append(xy,y1) File.WriteLine(FilePath,linx,xy) linx = linx+1 endfor x1 = x1+.01 xz = Text.Append(x1," 1") File.WriteLine(FilePath,linx,xz) TextWindow.WriteLine("Conversion complete - File Written") secondtime = 1 TextWindow.WriteLine(" ") TextWindow.WriteLine(" ") TextWindow.Write("Do you want to write another text output file?") TextWindow.WriteLine(" ") TextWindow.WriteLine("if yes then please type Y (and hit return) ") textline = TextWindow.Read() If(textline = "Y" Or textline = "y") Then Goto BigRepeat endif endout: 'program exits here '========================SUBROUTINES ================ sub Quadrant If Math.Abs(x[i]) < .0001 Then x[i] = 0 Goto Xzero EndIf If Math.Abs(y[i]) < .0001 Then y[i] = 0 Goto Yzero EndIf If x[i]>0 Then Goto quad14 Else Goto quad23 EndIf '=============== Xzero: If y[i] = 0 Then Pos[i] = 0 Else If y[i] >0 Then Pos[i] =1.5 Else Pos[i] = 3.5 EndIf EndIf Goto done '=============== Yzero: If x[i] = 0 Then Pos[i] = 0 Else If x[i] >0 Then Pos[i] = 0 Else Pos[i] = 2.5 EndIf EndIf Goto done '=============== quad14: If y[i] = 0 Then Pos[i] = 0 Goto done endif If y[i] >0 Then Pos[i] = 1 Else Pos[i] = 4 EndIf Goto done '=============== quad23: If y[i] = 0 Then Pos[i] = 2.5 Goto done EndIf If y[i] >0 Then Pos[i] = 2 Else Pos[i] = 3 EndIf '=============== done: If i = 1 Then Goto done1 endif direct[i] = direct[i-1] If Pos[i] = 1 Then If Pos[i-1] = 0 then direct[i] = 1 EndIf endif If Pos[i] = 1 Then If Pos[i-1] = 4 then direct[i] = 1 EndIf EndIf If Pos[i] = 4 Then If Pos[i-1] = 0 then direct[i] = -1 EndIf endif If Pos[i] = 4 Then If Pos[i-1] = 1 then direct[i] = -1 EndIf EndIf done1: endsub '================================================================== Sub Normalize ac = reang[i] If direct[i] = 1 then If Pos[i] = 0 Then If counter = 1 then reang[i] = 0 Else If Math.Abs(reang[i-1]) > Math.Pi then reang[i] = 2*Math.pi Else reang[i] = 0 EndIf EndIf Goto finp EndIf If Pos[i] = 1.5 then reang[i] = Math.pi/2 Goto finp endif If Pos[i] = 2.5 then reang[i] = Math.pi Goto finp endif If Pos[i] = 3.5 Then reang[i] = 1.5 * Math.pi Goto finp Endif If Pos[i] = 1 then reang[i] = ac Goto finp endif If Pos[i] = 2 then reang[i] = ac Goto finp endif If Pos[i] = 3 then reang[i] = 2*Math.pi- ac Goto finp EndIf If Pos[i] = 4 then reang[i] = 2*Math.pi- ac Goto finp EndIf endif If direct[i] = -1 then If Pos[i] = 0 Then If counter = 1 then reang[i] = 0 Else If math.Abs(reang[i-1]) > Math.Pi then reang[i] = -2*Math.pi Else reang[i] = 0 EndIf EndIf Goto finp EndIf If Pos[i] = 1.5 then reang[i] = -1.5 * Math.pi Goto finp EndIf If Pos[i] = 2.5 then reang[i] = -Math.pi Goto finp EndIf If Pos[i] = 3.5 Then reang[i] = -0.5 * Math.pi Goto finp EndIf If Pos[i] = 1 then reang[i] = ac - 2* Math.pi Goto finp endif If Pos[i] = 2 then reang[i] = ac - 2* Math.pi Goto finp endif If Pos[i] = 3 then reang[i] = - ac Goto finp EndIf If Pos[i] = 4 then reang[i] = - ac Goto finp EndIf endif finp: endsub '=====================================================