Open main menu

UESPWiki β

Daggerfall Mod:DFRemake/DarkBasic Tips

< Mod / Daggerfall: Daggerfall Mod: DFRemake(Redirected from Daggerfall:DFRemake/DarkBasic Tips)

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

GeneralEdit

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


FunctionsEdit

  • 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 TypesEdit

  • 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/ListsEdit

  • 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.