[C SDK] Reading values from cursor

Olaf Schmidtmann os at brainbits.net
Wed Nov 5 16:12:27 CST 2003


Hey Ruslan,

sorry it took me a little longer to put this together.


> > I create a cursor and do something like this to get these values:
> > 
> > // fRef is my field reference
> > fName = Field_GetName(fRef)
> > fType = Field_GetType(fRef)
> > fValue = Field_GetString(fRef) // Should work for almost 
> everything, 
> > right?
> 
> Please show me more your sources.
> For example how you have declare fName?
>
> Have you declare it as
> 
>     char* fname?
> 
> It looks like you assign char* (in C terms "string pointer") 
> to NUMBER.


I do not have to declar or type the variable in Flash. Flash MX has no
strong typed variables. It will accept everything. And I think that I cannot
declare the variable in the call. I just want the buffer to be filled.

Here is a sample:

[CODE]
valFieldGetString = function (fldRef, targetIndex, targetProp) {
	var args = new Object();
	args.inField = fldRef;
	args.ptr_myBuffer = swInterface.createBuffer(100);
	
	swInterface.callDLLMethod(dllPath, "Field_GetString", args,
dllFldCallback, {propIndex: targetIndex, propProp: targetProp});
}
[/CODE]

fldRef is an integer reference of the field.
The ptr_myBuffer is a buffer with 100 characters - very ugly but that's not
my fault. I sent you the Screenweaver interface before.
The dllFldCallback is a custum function I created to get something back. It
stores the resultcode which passes the references for all other functions.
When it comes to strings I have to do it with the ugly string buffer which
is used as an argument.

[CODE]
dllFldCallback = function (resultCode, resultString, args) {
	swDebug.traceObject(args);
	
	_global.fldList[this.propIndex][this.propProp] = resultCode;
	
	swDebug.trace("=> "+_global.fldList[this.propIndex][this.propProp]);

	this.propIndex = null;
	this.propProp = null;
}
[/CODE]

swDebug.traceObject(args) shows the object which contains the "myBuffer"
string buffer.



Here is a sample that actually works with the user32.dll as a comparison:

[CODE]
swSystem.Version.getPlatform() < 8 ? _global.getTitleMethod =
"GetWindowText" : _global.getTitleMethod = "GetWindowTextA"

// Callback for GetForegroundWindow
_root.onActiveWindow = function( code, msg, returnArgs )
{
	//swDebug.trace(" onActiveWindow ");
	_root.windowHandle_txt.text = code;

	var args = {
		nMaxCount : 50,
		ptr_myBuffer : swInterface.createBuffer(50),
		hWnd : code
	}
	// We have the window handle, now we can ask for it's title
(caption)
	swInterface.callDllMethod( _global.dllpath, _global.getTitleMethod,
args, _root.onGetText, this );
}

// Callback for GetWindowText
_root.onGetText = function(  code, msg, returnArgs )
{
	//swDebug.trace(" onGetText ");
	_root.windowTitle_txt.text = returnArgs.myBuffer;
}

// setup timer
myTimer = new Object();
myTimer.checkActiveWindow = function(){
	swInterface.callDllMethod( _global.dllpath, "GetForegroundWindow",
{}, _root.onActiveWindow, this );
}
setInterval( myTimer, "checkActiveWindow", 1000, "Get ActiveWindow" );
[/CODE]

> ALSO, import "strange" feature of VCSDK is that it return you 
> string pointer...and you need COPY that string to OWN buffer 
> immediately, because any other operation that also return 
> char* will reuse that buffer.

Uuuh, that's bad, because to speed the asynchronous behavior up I wanted to
do this:

- get cursor ref
- get field count
- loop all field and get their references
- loop *all* field references and get their names & types
- loop *all* field references and get their values (with proper method)

Looks like I have to wait for the callback for each field. If that is the
case I think I can forget everything because this is getting much too slow:
:-(

> 
> I still not sure this was good decision...
> C libraries usually not work in this way...
> On the other hand this way IMHO still simpler of its alternatives.

I am about to give it up. I will stick to Flash and XML or Director, Flash
and Valentina. This is very sad beacuse I thought I was so close :-(( I
cannot spent more days on trying this when I do not know wether it works
allright. The worst thing is that there is nobody around who really knows
how cares from the Screenweaver folks (maybe there is nobady who KNOWS how
to do this). I already asked pleople from Northcode (www.northcode.com) if
they could create a plugin for Valentina. They said it should be very easy
with their SDK but I could not do it (at least not in time).

bye
Olaf

-- 
***        http://www.brainbits.net/        ***


More information about the Valentina mailing list