Moderators: hgm, Andres Valverde
H.G.Muller wrote:Indeed, the engines are volatile options.
People that want to redefine some volatile options compared to their system's defaults, can use the settings-file dederection recursively, though. E.g. if /usr/local/etc wouuld redirect the settings file to ~/.xboardrc in your home directory, you could put the commands
/fcp="..."
/settingsFile="~/xboard.ini"
/saveSettingsFile="~/xboard.ini"
in the latter, so that the file xboard.ini is used for storing and loading the settings, and the engine will by default be set to the value specified in ~/.xboardrc. This way each user can specify his own default engine.
Darklord42 wrote:Well rather than make the file /.xboardrc and stick it in the home folder, i just told the master .ini to name it xboard.ini and put it in the /Applications/Xboard folder. This way it is visible, and mac users don't have to go looking for it in places they wont necessarily expect.
global theFile, theList, thePath, theCount, theFileContents, myOptions, mySelectedOptions, thePrompt, startFolder, theFolder, theEng, theFirstEng, theSecondEng, myFirstEng, mySecondEng, txt
set startFolder to "/Applications/Xboard/Engines/"
set theFile to "/Applications/Xboard/xboard.conf"
readFile(theFile)
if txt is "" then
display dialog "File not found" & return & return & "install xboard.conf in /Applications/Xboard" & return & return & "This program will close now" buttons {"OK"} default button 1 with icon caution
quit
end if
set theList to every paragraph of text of txt
set theCount to (count of theList)
set theVariant to DefaultValues("variant")
set theMode to DefaultValues("Mode")
set theFirstEng to DefaultValues("firstChessProgram")
set theSecondEng to DefaultValues("secondChessProgram")
set theChoice to display dialog "The mode of operation is : " & theVariant & return & return & theMode & return & return & "The first engine : " & theFirstEng & return & return & "The second engine : " & theSecondEng buttons {"Accept Defaults", "Change Defaults"}
set theAnswer to button returned of theChoice
if theAnswer is equal to "Accept Defaults" then
display dialog "Nothing will be changed !" & return & return & "This program will close now" buttons {"OK"}
quit
else
set myOptions to {"Chess_engines", "Variant"}
set mySelectedOptions to {}
setOptions()
set myChange to mySelectedOptions
end if
if myChange contains "Variant" then
set myOptions to {"normal", "wildcastle", "nocastle", "fischerandom", "bughouse", "crazyhouse", "losers", "suicide", "giveaway", "twokings", "kriegspiel", "atomic", "3check", "shatranj", "xiangqi", "shogi", "capablanca", "gothic", "caparandom", "janus", "courier", "falcon", "berolina", "cylinder", "knightmate", "super", "makruk", "fairy"}
set mySelectedOptions to {}
setOptions()
set var to mySelectedOptions
set myVariant to "-variant " & var
set txt to my Replace(txt, theVariant, myVariant)
end if
if myChange contains "Chess_engines" then
set theEng to false
set thePrompt to ""
set theFile to ""
set thePath to ""
set theFolder to ""
set thePrompt to "Select the first chess engine"
SelectEng() -- select first engine
set myFirstEng to "-firstChessProgram " & thePath
set txt to my Replace(txt, theFirstEng, myFirstEng)
set thePrompt to "Select the second chess engine"
SelectEng() --select the second engine
set mySecondEng to "-secondChessProgram " & thePath
set txt to my Replace(txt, theSecondEng, mySecondEng)
end if
set bootDisk to (path to startup disk) as Unicode text
set theConf to (bootDisk & "Applications:Xboard:xboard.conf")
set theFile to open for access file theConf with write permission
write txt to theFile
close access theFile
on Replace(txt, srch, rpl)
set oldtid to AppleScript's text item delimiters
set AppleScript's text item delimiters to {srch}
set txt to text items of txt
set AppleScript's text item delimiters to {rpl}
set txt to "" & txt
set AppleScript's text item delimiters to oldtid
return txt
end Replace
on readFile(unixPath)
set foo to (open for access (POSIX file unixPath))
set txt to (read foo for (get eof foo))
close access foo
return txt
end readFile
on DefaultValues(theValue)
repeat with i from 1 to theCount
set theWord to item i of theList
if theWord contains theValue then
set theMode to theWord as string
end if
end repeat
set AppleScript's text item delimiters to "\""
set theModePath to (text items of theMode)
set AppleScript's text item delimiters to ""
set theModePath to (theModePath as string)
return theModePath
end DefaultValues
on setOptions()
set optionsTemp to (choose from list myOptions with prompt "Select the settings to change" default items mySelectedOptions OK button name "Select" with multiple selections allowed)
if (optionsTemp ≠ false) then
set mySelectedOptions to optionsTemp
end if
end setOptions
on SelectEng() --main handle for engine selection
set theRept to false
repeat until theRept is true
fileSelect(thePrompt)
if theFile contains "." then
checkFolder()
else if theFolder is not "Engines" then
checkFolder()
else
checkEngine()
if theEng is true then
set theRept to true
end if
end if
end repeat
end SelectEng
on checkEngine() --make sure that the user is happy with the selection and stop the handle SelectEng
display dialog "The selected engine is " & theFile & return & return & "Is this correct ?" buttons {"Yes", "No"} default button 1
set theAnswer to button returned of result
if theAnswer is equal to "Yes" then
set theEng to true
else
return
end if
end checkEngine
on checkFolder() --Inform the user that the selection is wrong and continue
display dialog "This is not an engine or the selected engine is not in a sub folder of Engines" & return & return & "install chess engines in a sub folder of Xboard/Engines" buttons {"OK"} default button 1 with icon caution
return
end checkFolder
on fileSelect(thePrompt) --Engine selection handle
set PathFile to choose file with prompt thePrompt default location startFolder
--return PathFile
set thePath to (the POSIX path of PathFile)
set AppleScript's text item delimiters to "/"
set theFilename to text items of thePath
set AppleScript's text item delimiters to {""}
set theFile to item -1 of theFilename
set theFolder to item -3 of theFilename
end fileSelect
Return to WinBoard development and bugfixing
Users browsing this forum: No registered users and 5 guests