Browse Source

Readme: Updated string retrievement

tags/0.2
Ludwig Frühschütz 3 years ago
parent
commit
670c1f7ff4
1 changed files with 5 additions and 20 deletions
  1. +5
    -20
      README.md

+ 5
- 20
README.md View File

@ -4,7 +4,6 @@ This is a DLL extension for [AutoHotkey](https://www.autohotkey.com/) that enabl
## Work in progress
Currently this project is unfinished, there may be missing functionality and errors may occur!
* After multiple calls of [`getStringData()`](https://files.eleton-audio.de/gitea/Ludwig/OSC2AHK#get-string-data) a heap memory fault occurs. This could also be a error in the calling AHK script (see [`msghandlerString()` in the test script](https://files.eleton-audio.de/gitea/Ludwig/OSC2AHK/src/branch/master/msgtest.ahk#L41)).
* OSC address wildcards are not supported yet
* Documentation could be improved
@ -114,34 +113,20 @@ DllCall("OSC2AHK.dll\removeListener", AStr, "/test1")
```
#### Get string data
__Work in progress, this is not working properly for now__
As string data carried by OSC messages may be of varying length, they cannot directly be passed by system messages. Therefore, the string is buffered in the DLL and the `data` variable of the callback function receives a unique identifier to the stored string. This string then can be retreived later on by the AHK script by calling this function.
As string data carried by OSC messages may be of varying length and cannot directly be passed by system messages. Therefore, the string is buffered in the DLL and the `data` variable of the callback function receives a unique identifier to the stored string. This string then can be retrieved later on from the AHK script by calling this function.
```cpp
char* getStringData(char* targetString, unsigned int targetSize, unsigned int StringID);
```
This function writes the stored string to the `targetString` and also removes it from the buffer inside the DLL.
A example AHK snippet could look like this:
A callback functin in AHK could look like this (also look at the [string example](https://files.eleton-audio.de/gitea/Ludwig/OSC2AHK/src/branch/master/examples/string_example.ahk)):
```
global oscTypeString := 8
DllCall("OSC2AHK.dll\addListener", AStr, "/test2", UInt, 0x1004, UInt, oscTypeString)
OnMessage(0x1004, "msghandlerString")
msghandlerString(oscType, data, msgID, hwnd)
{
if (wParam != oscTypeString)
{ ; not a string!
return
}
; We were notified that a OSC string message with the specified address was received
; and the string payload was stored with the ID passed by 'data'.
; Now we will retrieve this string from the DLL.
VarSetCapacity(theStr, 20)
theStr := DllCall("OSC2AHK.dll\getStringData", AStr, theStr, UInt, 20, UInt, lParam, "Cdecl AStr")
VarSetCapacity(theString, 20)
theString := DllCall("OSC2AHK.dll\getStringData", str, theString, UInt, 20, UInt, data, AStr)
msgbox,%theStr%
msgbox,Got string: %theString%
}
```


Loading…
Cancel
Save