"model.rats"
<- function()
# Check that OpenBUGS model is sytaxticaly correct
{
command <- paste("BugsEmbed.SetFilePath('Examples/ratsmodel.txt')",
";BugsEmbed.ParseGuard;BugsEmbed.Parse",
";BugsEmbed.SetFilePath('Examples/ratsdata.txt')",
";BugsEmbed.LoadDataGuard;BugsEmbed.LoadData",
";BugsEmbed.CompileGuard;BugsEmbed.Compile(1)",
";SamplesEmbed.firstChain := 1",
";SamplesEmbed.lastChain := 1",
" ;BugsEmbed.SetFilePath('Examples/ratsinits.txt')",
";BugsEmbed.LoadInitsGuard;BugsEmbed.chain := 1;BugsEmbed.LoadInits",
";BugsEmbed.UpdateGuard;BugsEmbed.Update(1000)",
";SamplesEmbed.SetVariable(alpha0)",
";SamplesEmbed.SetGuard;SamplesEmbed.Set",
";SamplesEmbed.SetVariable(beta.c)",
";SamplesEmbed.SetGuard;SamplesEmbed.Set",
";SamplesEmbed.SetVariable(sigma)",
";SamplesEmbed.SetGuard;SamplesEmbed.Set",
";BugsEmbed.UpdateGuard;BugsEmbed.Update(10000)",
";SamplesEmbed.SetVariable('*')",
";SamplesEmbed.StatsGuard;SamplesEmbed.Stats",
sep = "")
len <- nchar(command)
.C("CmdInterpreter", as.character(command), as.integer(len), integer(1))
buffer <- paste(tempDir, "/buffer.txt", sep = "")
len <- length(readLines(buffer))
if (len > 1)
read.table(buffer)
else
cat(readLines(buffer), "\n")
}