Hi Mark0,
this can be done very easily, Eros explained it in one post: please read here
Good luck with your module !
Bye,
Petr
One thing that's not immediately clear to me how I can change the content of vars passed as a parameter calling a module defined Sub/Function.
That is, what I want to do is something like:
[code=thinbasic]DIM x, y, r, g, b as LONG
x = 10
y = 15
TBDOG_PGET(x, y, r, g, b)[/code]
So in the PB defined sub I want to be able to alter those r, g and b var with the actual pixel values.
I think I have to get the token id while parsing the parameters, but a small example as a guideline will be much appreciated.
Thanks,
Bye!
Hi Mark0,
this can be done very easily, Eros explained it in one post: please read here
Good luck with your module !
Bye,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Perfect!
Many thanks,
Bye!
Thanks Petr.
Maybe worth to repeat here again.
In case you need variables passed by reference, here it is an little Power Basic example on which functions to use from thinCore.dll interface to be able to change one or more variable passed byref like "dialog get client hWnd to x, y":
[code=thinbasic]
'---Declare needed variables. To change a variable we need
'---a reference pointer and an aboslute position (in case of arrays)
LOCAL lVariablePtr1 AS LONG
LOCAL lVariableAbsPos1 AS LONG
LOCAL eResult1 AS EXT
LOCAL lVariablePtr2 AS LONG
LOCAL lVariableAbsPos2 AS LONG
LOCAL eResult2 AS EXT
'---Check if any error
IF thinBasic_ErrorFree THEN
'---Get reference of first variable
thinBasic_VariableParse(lVariablePtr1, lVariableAbsPos1)
'---Check if comma
IF thinBasic_CheckComma() AND thinBasic_ErrorFree THEN
'---Get reference of second variable
thinBasic_VariableParse(lVariablePtr2, lVariableAbsPos2)
IF thinBasic_ErrorFree THEN
'---Here do what you need to do
'---Now assign values to referenced variables
thinBasic_ChangeVariableNumberDirect (lVariablePtr1, lVariableAbsPos1, eResult1)
thinBasic_ChangeVariableNumberDirect (lVariablePtr2, lVariableAbsPos2, eResult2)
END IF
END IF
END IF
[/code]
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
???
TBDOG...
What's that?
;D
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Let's say it's just a code name! TBDW will probably be a better prefix, yeah!
BTW, I'm having some problems getting the thinBasic_VariableParse working.
I have noticed from the thinCore.INC that the parameters have changed, but I'm getting nothing as the var name and 1 for both the other two parameters. I'm surely doing something wrong...
Bye!
I'm surely doing something silly, so I'll appreciate if someone can point out what I'm doing wrong:
Here's the a thinBasic test source:
[code=thinbasic]MODULE "tBDW"
dim res as long
dim u as ext
TBDW_Test(u)
res = Msgbox(0, "U:" & str$(u))
[/code]
Here's PowerBASIC symbol loading:
[code=qbasic]thinBasic_LoadSymbol "TBDW_Test", %thinBasic_ReturnNone, CODEPTR(Exec_tBDW_Test ), %thinBasic_ForceOverWrite
[/code]
And the actual procedure:
[code=qbasic]SUB Exec_tBDW_Test()
LOCAL VName AS STRING
LOCAL VPTR AS LONG
LOCAL VAbsPos AS LONG
LOCAL myValue AS EXT
IF thinBasic_CheckOpenParens() THEN
thinBasic_VariableParse(VName, VPtr, VAbsPos)
IF thinBasic_CheckCloseParens() THEN
MSGBOX STR$(VPtr) & "," & STR$(VAbsPos) & ", [" & VName$ & "]", , "PowerBASIC"
MyValue = 117
thinBasic_ChangeVariableNumberDirect (VPtr, VAbsPos, MyValue)
END IF
END IF
END SUB
[/code]
The PB's MSGBOX show VPTR = 1, VAbsPos = 0 and VName as large empty string, and obviously it then GPF ???
Thanks,
Bye!
Marco,
the syntax you are using for thinBasic_VariableParse is an old one.
Current one has no VariableName to be passed:
[code=freebasic]
DECLARE FUNCTION thinBasic_VariableParse _
LIB "thinCore.DLL" _
ALIAS "thinBasic_VariableParse" _
( _
BYREF VariablePtr AS LONG , _ '---ATTENTION: parameter passed BYREF will return info
BYREF VariableAbsPos AS LONG _ '---ATTENTION: parameter passed BYREF will return info
) AS LONG
[/code]
So change your function to
[code=thinbasic] SUB Exec_tBDW_Test
LOCAL VPTR AS LONG
LOCAL VAbsPos AS LONG
LOCAL myValue AS EXT
IF thinBasic_CheckOpenParens( ) THEN
thinBasic_VariableParse(VPtr, VAbsPos) '---<<<<<<<<<Change here. No more var name
IF thinBasic_CheckCloseParens( ) THEN
MSGBOX STR$ (VPtr) & "," & STR$ (VAbsPos) & ", [" & "]", , "PowerBASIC"
MyValue = 117
thinBasic_ChangeVariableNumberDirect (VPtr, VAbsPos, MyValue)
END IF
END IF
END SUB
[/code]
Just in case, please find attached latest thinCore.inc file interface.
Let me know.
Ciao
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
OK, now it work perfectly!
Thanks,
Bye!
Here is the first release.
tBDW - thinBasic Project Dogwaffle scriptable interface
The API implemented is minimal at the moment, but it's just what's needed to access the pixels and do a variety of filters, for example.
Is there a more appropriate section in the forum to make a post? I looked around but I'm a bit confused about what me the better!
Bye!
Bookmarks