I'm having some issues with filehandling...Namely having the .txt files generating in the right place and also creating a find maximum algorithm that both works and doesn't crash my program

At the moment my code is looking like this:
Code: Select all
on mouseUp
open file specialFolderPath("./") & "/Score" for write //On mac this syntax worked fine for generating the .txt just outside the applet file, but on windows it goes haywire...
put field "Field" into tData
write myText to file specialFolderPath("./") & "/Score" //...Now it does not generate near the applet at all, usually outside the folder :(
repeat with x= 1 to 10 //...And then there's this, which no matter how many times I rewrite it and make sure no eternal loops are happening, just crashes the program...
put x into tXtemp1
put line x of tData into tXvtemp1
if x > 1 then
add -1 to x
put x into tXtemp2
put line x of tData into tXvtemp2
end if
if tXvtemp2 > line tXvtemp1 of tData then
put tXvtemp2 into line tXtemp1 of tData
put tXvtemp1 into line tXtemp2 of tData
end if
end repeat
end mouseUp
