Author Topic: *.INI files  (Read 311 times)


  • Moderator
  • Member
  • *****
  • Posts: 13284
  • Assembly is fun ;-)
    • MasmBasic
*.INI files
« on: June 10, 2022, 10:11:19 AM »
include \masm32\MasmBasic\
  .if !Ini$()                           ; no ini file found, let's create one
        SetIni$ "crtDate", fDate$()
        SetIni$ "crtTime", fTime$()
  PrintLine "Created  ", Ini$("crtDate"), ", ", Ini$("crtTime")
  SetIni$ "modTime", Cat$(fDate$()+", "+fTime$())
  PrintLine "Modified ",  Ini$("modTime")

Output (12 minutes later):
Code: [Select]
Created  10.06.2022, 01:56:41
Modified 10.06.2022, 02:09:00

Building the attached source requires MasmBasic of 10 June 2022

P.S.: This is meant for settings, i.e. short names and values in the format name=value. There is a limit of 100 kBytes. Names and values can be Unicode, encoded as Utf8 (i.e. Chinese or Russian are not a problem, see below).

Be careful with embedded CrLf - not impossible, but you need a workaround with Replace$():
Code: [Select]
  Let edi=FileRead$("\Masm32\menus.ini") ; qEditor's menus
  SetIni$ "меню редактора", Replace$(edi, CrLf$, "[CrLf$]")
  PrintLine cfm$("\nqEditor menus:\n"),  Replace$(Left$(Ini$("меню редактора"), 200), "[CrLf$]", CrLf$), "..."
Masm32 Tips, Tricks and Traps

Some members can't live without insulting others. It tells us a lot about them.