Daggerfall Mod:DFRemake/DarkBasic Tips

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

This page contains general tips to help one get the most out of DarkBasic. This includes a number of things in DB that are counterintuitive or different from other common programming languages.

General[edit]

  • Using very large object IDs (10-100 million) results in a very slow execution time as well as greatly increased memory usage.

Functions[edit]

  • All input parameters are passed by value (no such thing as pass-by-reference).
  • Cannot return user defined types.
  • Do accept arrays as input parameters. The syntax Function TestFunc(dim array(100) as dword) does compile but you get an error if you try to access the array in the function.
  • Cannot return arrays.

Variable Types[edit]

  • UDTs cannot be returned by functions
  • UDTs cannot be passed into DLLs (not directly or very easily at any rate)
  • UDTs cannot contain arrays
  • Beware of mixing DWORDs with the ABS() command. For example, Value3 = ABS(Value1 - Value2) may not return what you think it should if all the values are DWORDs.

Arrays/Lists[edit]

  • The time taken to add elements to lists seems to be non-linear and increases dramatically as the list grows. For example, adding 100 elements takes 0.25 ms, 1000 takes 15 ms, 10000 takes 1500 ms. Deleting elements roughly follows the same trend.