RosettaCodeData/Task/Read-a-configuration-file/Vedit-macro-language/read-a-configuration-file.vedit
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

35 lines
1 KiB
Text

#11 = 0 // needspeeling = FALSE
#12 = 0 // seedsremoved = FALSE
Reg_Empty(21) // fullname
Reg_Empty(22) // favouritefruit
Reg_Empty(23) // otherfamily
File_Open("|(PATH_ONLY)\example.cfg")
if (Search("|<FULLNAME|s", BEGIN+ADVANCE+NOERR)) {
Match("=", ADVANCE) // skip optional '='
Reg_Copy_Block(21, CP, EOL_pos)
}
if (Search("|<FAVOURITEFRUIT|s", BEGIN+ADVANCE+NOERR)) {
Match("=", ADVANCE)
Reg_Copy_Block(22, CP, EOL_pos)
}
if (Search("|<OTHERFAMILY|s", BEGIN+ADVANCE+NOERR)) {
Match("=", ADVANCE)
Reg_Copy_Block(23, CP, EOL_pos)
}
if (Search("|<NEEDSPEELING|s", BEGIN+ADVANCE+NOERR)) {
#11 = 1
}
if (Search("|<SEEDSREMOVED|s", BEGIN+ADVANCE+NOERR)) {
#12 = 1
}
Buf_Quit(OK) // close .cfg file
// Display the variables
Message("needspeeling = ") Num_Type(#11, LEFT)
Message("seedsremoved = ") Num_Type(#12, LEFT)
Message("fullname = ") Reg_Type(21) TN
Message("favouritefruit = ") Reg_Type(22) TN
Message("otherfamily = ") Reg_Type(23) TN