The amount of code necessary to check errors and iterate the map obscures the actual purpose of the function.

The error checks on IsMap and MapKeys are redundant: Either you do not receive a map in $mMap and IsMap fails or you do receive a map and MapKeys will never fail. So in practice, to write good code, you either have to have MapKeys (which can error) not error-checked, or you're going to omit the type-checking code. Either solution isn't really very good because it's not consistent with other data types.

Share this post

Link to post

Share on other sites

Performance seems to drop-off fairly quickly when the map grows in size. To add the first 1000 elements to a map it takes approximately 8ms, but when the map already had 100K elements in it, it took about 3 seconds. This seems to be more-or-less linearly. If it's implemented as a hash table, the insertion performance should be O(1) so something is definitely up.

Here's the script I used to check this. It can't be the lexer/parser so it must be the map.

It does. Though I admit it hadn't crossed my mind because of MapKeys error checking. The main goal was to establish good habit within the community when iterating map key/values and that's been done I think.

Share this post

Link to post

Share on other sites

Is the "Remarks" section in FileSetEnd correct`? Because it has the same content as FileSetPos. There is no "Origin" parameter in FileSetEnd so it looks like a copy/paste error to me.

Remarks
Include Constants.au3 in your script to use the symbolic name in parentheses to specify the origin.
Using FileSetPos() it is possible to both read and write to the same file. When attempting to read and write to the same file, always call FileFlush() between each write and read operation.
Moving the pointer to the middle of the data can be used to overwrite data.

Share this post

Link to post

Share on other sites

"Expected a variable in user function call." - error if you pass a map´s value to a function as byref or const byref:

Passing dot notation by reference isn't implemented yet. For now you need to use map["String"]

The dot notation is proving to be very ambiguous and hard to parse correctly past a single element. Especially trying to work out what works when swapping data types. I might have to seriously limit it to make it work sensibly.

Share this post

Link to post

Share on other sites

#include <FileConstants.au3>#include <MsgBoxConstants.au3>
Example()Func Example(); Create a constant variable in Local scope of the filepath that will be read/written to.LocalConst$sFilePath=@TempDir&"\FileSetEnd.txt"; Open the file for writing (overwrite the file) and store the handle to a variable.Local$hFileOpen=FileOpen($sFilePath,$FO_OVERWRITE)If$hFileOpen=-1ThenMsgBox($MB_SYSTEMMODAL,"","An error occurred when writing the file.")ReturnFalseEndIf; Write data to the file using the handle returned by FileOpen.FileWriteLine($hFileOpen,"Line 1")FileWriteLine($hFileOpen,"Line 2")FileWriteLine($hFileOpen,"Line 3"); Flush the file to disk.FileFlush($hFileOpen); Now, adjust the position to the beginning.FileSetPos($hFileOpen,0,$FILE_BEGIN); Check file position and try to read contents for current position.MsgBox($MB_SYSTEMMODAL,"","Position: "&FileGetPos($hFileOpen)&@CRLF&"Data: "&@CRLF&FileRead($hFileOpen)); Write data to the file using the handle returned by FileOpen.FileWriteLine($hFileOpen,"Line 4")FileWriteLine($hFileOpen,"Line 5")FileWriteLine($hFileOpen,"Line 6"); Now, adjust the position to the beginning.FileSetPos($hFileOpen,0,$FILE_BEGIN); Check file position and try to read contents for current position.MsgBox($MB_SYSTEMMODAL,"","Position: "&FileGetPos($hFileOpen)&@CRLF&"Data: "&@CRLF&FileRead($hFileOpen)); Now, adjust the position to the beginning.FileSetPos($hFileOpen,0,$FILE_BEGIN); Set the end of the file at the current position.FileSetEnd($hFileOpen); Check file position and try to read contents for current position. The contents have been destroyed.MsgBox($MB_SYSTEMMODAL,"","Position: "&FileGetPos($hFileOpen)&@CRLF&"Data: "&@CRLF&FileRead($hFileOpen)); Close the handle returned by FileOpen.FileClose($hFileOpen); Delete the temporary file.FileDelete($sFilePath)EndFunc;==>Example

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)