Hello Phil,
I have found an bug in the write_filex() function. The problem is as follows: when you try to create a filex with more than 99 levels of a treatment, the write function cuts the treatment levels to two digits.
In the example below, I modified the last treatment of a WHX file to set a cultivar treatment to 999. While the functions writes the level 999 in the treatment's level section of the filex, it cuts the level 999 to 99 in the CULTIVARS section of the filex. I think this problem has to do with the column width set in the function. However, note that DSSAT allows to have 3 digits levels in the CULTIVARS section (for example).
library(tidyverse)
library(DSSAT)
options(DSSAT.CSM = "/DSSAT48/dscsm048")
file.copy("/DSSAT48/Wheat/KSAS8101.WHX", ".")
fileX <- read_filex("KSAS8101.WHX")
fileX$`TREATMENTS -------------FACTOR LEVELS------------` <-
fileX$`TREATMENTS -------------FACTOR LEVELS------------` %>%
mutate(CU = ifelse(N == 6, 999, CU))
fileX$CULTIVARS <-
fileX$CULTIVARS %>%
mutate(C = list(c(1, 999)))
# write the fileX
write_filex(fileX, "KSAS8102.WHX")
# run the treatment six
run_dssat("C", "KSAS8102.WHX 6") # it won't run unless you manually add the missing 9 in line 29 of the created fileX
The result:

How the right fileX should look like:

Hello Phil,
I have found an bug in the write_filex() function. The problem is as follows: when you try to create a filex with more than 99 levels of a treatment, the write function cuts the treatment levels to two digits.
In the example below, I modified the last treatment of a WHX file to set a cultivar treatment to 999. While the functions writes the level 999 in the treatment's level section of the filex, it cuts the level 999 to 99 in the CULTIVARS section of the filex. I think this problem has to do with the column width set in the function. However, note that DSSAT allows to have 3 digits levels in the CULTIVARS section (for example).
The result:

How the right fileX should look like:
