8 posts in this topic
Hello everyone, I discovered a bug yesterday and I posted it at the bug tracker:
I also made a simple script which can be used to reproduce the bug:
CreateVariable() ConsoleWrite($sGlobalVariable & @CRLF) Func CreateVariable() Global $sGlobalVariable = "Foobar" EndFunc The bug was closed by @BrewManNH:
While I partially agree with the above statement, My code was not practical enough... so @mLipok advised me to create a thread on the forums with practical code (Thanks!). That is the point of this thread, I am going to provide the code where I experience this bug/problem .
I discovered this bug when I was working on one of my projects called "ProxAllium". When the main script finishes execution, Au3Check throws a nasty warning about "variable possibly used before declaration":
As you can see, the variable is indeed being used after calling the function in which the variable is declared... The warning won't appear if I declare the function ABOVE the variable. As @BrewManNH said, Au3Check reads line by line... I think this should be changed, Au3Check should not throw warnings if the interpreter is able to run the code, at least most of the time anyway!
So what do you guys think? Is this a valid bug?... and I request those who participate in the discussion not to discuss the code being "poor", that is another thing/thread in itself
P.S I had already written this once but the forum editor decided to mess up and when I undid (Ctrl + Z) something... This is a poorly written version of that article, I was very frustrated while writing this!
I'm trying to use #OnAutoItStartRegister to modify the Global variable, but it seems it doesn't work, is that on purpose, that those callback functions cannot modify anything except in their own scope?
This is the error message I got: "Cannot make existing variables static."
I'm trying to use static variable as a means to iterate a section of my script.
while 1 global $initial, $constant = 1 $x = $initial + ($constant * SomeFunc()) msgbox(0, '', $x) wend func SomeFunc() global static $counter = -1 $counter += 1 return $counter endfunc
Atom Table UDF
Local and Global Atom Table
Since I've had this collecting dust on my computer, I figured I'd release it to see if anyone can find some use for it.
About Atom Tables - MSDN
Example Global Atom Table Listing
Basically, a bunch of strings can be stored locally (at program level) or globally (at O/S level) with unique numerical identifiers. This UDF lets you add, find, delete, and query these atoms.
Description from the top of the AtomFunctions UDF:
Functions for accesing Local and Global Atom Tables, which contain strings up to 255 characters long
The Atom tables are used for multiple types of Windows data including Window Classes (RegisterClass/Ex), Clipboard formats (RegisterClipboardFormat), Hotkeys (RegisterHotKey), and Dynamic Data Exchange (DDE) which is a form of interprocess communication. (Some of the above may use a Local rather than the Global Atom table)
Other uses can include storing program strings to lookup by a 16-bit value and interprocess communication
"RegisterHotKey function" @ MSDN states this:
"An application must specify an id value in the range 0x0000 through 0xBFFF.
A shared DLL must specify a value in the range 0xC000 through 0xFFFF
(the range returned by the GlobalAddAtom function).
To avoid conflicts with hot-key identifiers defined by other shared DLLs,
a DLL should use the GlobalAddAtom function to obtain the hot-key identifier."
Kernel Note: The Atom Table is a separate entity from Kernel Objects like Events, Mutexes, Files, etc. However, the Atom Table is (separately) accessible from within the Kernel, so its like a Kernish object?
Notes on Atom Tables:
Stringlimit is 255 characters NOT including a null-terminator. This is unfortunately not enough for a MAX_PATH string, which is 259+null-term. However, stripping off root-drive prefix get you within 1 character of the length (259 - 3 ["C:"] = 256] which may be enough - but using IPC, one can store 4 - 6 (8-12 in x64) extra chars in wParam/lParam.. See <AtomExample_IPC.au3> for an implementation of this
There is both a Local and Global Atom Table. The Local one is local to this Process, and the Global one is available/accessible to/from all Processes.
Atoms numbered 0 - 49151 (0xBFFF) are not actually part of the Atom Table. Querying these values will return a string representation of the number as an unsigned integer Example: 1234 is translated to "#1234"
Adding atom strings that start with a "#" will return an unsigned integer if the numbers following "#" are an integer less than 49152 (1 - 49151 [0xBFFF]). Examples: "#1" => 1, "#49151" => 49151
Atoms numbered from 49152 - 65535 (from 0xC000 - 0xFFFF) DO reference the Atom Table strings
Maximum Atom string length is 255 characters (not including a null-terminator)
; Local: ; _AtomTableInit() ; Initializes Local Atom Table. Optional [37 hash buckets allocated by default] ; _AtomAddLocal() ; Adds a string to the Local Atom table, returns # identifier [increments reference if already exists] ; _AtomGetNameLocal() ; Gets the Local Atom string associated with a numerical identifier ; _AtomDeleteLocal() ; Decrements the reference count of Local Atom, deletes when reaches 0 ; _AtomFindLocal() ; Finds # identifier for a string in the Local Atom table ; _AtomGetAllLocal() ; Returns all found Local atoms in an array ; Global: ; _AtomAddGlobal() ; Adds a string to the Global Atom table, returns # identifier [increments reference if already exists] ; _AtomGetNameGlobal() ; Gets the Global Atom string associated with a numerical identifier ; _AtomDeleteGlobal() ; Decrements the reference count of Global Atom, deletes when reaches 0 ; _AtomFindGlobal() ; Finds # identifier for a string in the Global Atom table ; _AtomGetAllGlobal() ; Returns all found Global atoms in an array ; 'Undocumented': ; _AtomGetGlobalTableUD() ; Using 'undocumented' function calls, gets info on all Global Atoms ; _AtomGetInfoUD() ; Returns reference count, pinned status, as well as Atom Name ----------------------------------------------------------------
There are a few 'undocumented' functions used for getting information on the Atom Table included (I can't help myself).
In addition to the core UDF, there's 2 example files:
AtomTableExample.au3 - This demonstrates various use - adding, deleting, and querying information in the Local and Global atom tables. (Extended info comes from 'undocumented' functions)
AtomExample_IPC.au3 - This demonstrates how the Atom Table could be used in InterProcess Communication. A rather rough sketch, but shows how you could squeeze MAX_PATH pathnames into IPC messages combined with Atom tables. It's all a bit light on the documentation, but I just wanted to prevent this thing from collecting more dust Might prove useful to someone!
AtomTablesUDF.zip ~prev Downloads: 29
Using this script (it has a broken link but here are the files) I'm trying to record a short clip 1 second or shorter longer (although you can assume it's always 1 second) and every time I record the clip (mp3 however it's the same on wav) it ends up with an extremely short static sound at the start of each clip even with the highest quality sound. Is there anyway you can trim the file down, also using bass, for example taking the first 100 miliseconds off the start (it has to be mp3 though)? Or on the other hand, does anyone know of another bass recording tool that allows that diversity of options, e.g quality (not essential but preferable), volume and microphone choices (these two are important) which doesn't have this issue?