Hi all,
In pb how i can create structure in runtime like array ?
Create Structure Runtime
-
- Addict
- Posts: 1265
- Joined: Wed Feb 28, 2007 9:13 am
- Location: London
Off the top of my head, I think it's:
Code: Select all
DIM variablename.structurename(arraysize)
thanks but this is'nt my mean.Seymour Clufley wrote:Off the top of my head, I think it's:Code: Select all
DIM variablename.structurename(arraysize)
i want create structure on runtime, something like this :
http://www.autoitscript.com/autoit3/doc ... Create.htm
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
PB is a compiler language, no script, not interpreted.
a structure does only exist while compiling.
it's nothing more than a descriptive kind of offset, to make access easier for the programmer.
at runtime, the structure itself does no longer exist but only the offsets.
Coordinate.POINT\Y will become (adress of Coordinate + 4)
so, there is not only no way but also no use in creating a structure at runtime.
a structure does only exist while compiling.
it's nothing more than a descriptive kind of offset, to make access easier for the programmer.
at runtime, the structure itself does no longer exist but only the offsets.
Coordinate.POINT\Y will become (adress of Coordinate + 4)
so, there is not only no way but also no use in creating a structure at runtime.
oh... and have a nice day.
thanks Kaeru Gaman, i know PB is a compiler Autoit & ... created in c++ and execute codes on runtime like a interpreter, How they do it ?
c++ is a compiler. do you have any info about structure, i want know more about it.
And another question i want create dllcall or load library like http://www.autoitscript.com/autoit3/doc ... llCall.htm, how can i do this nobody have any idea.
Thanks for help.
c++ is a compiler. do you have any info about structure, i want know more about it.
And another question i want create dllcall or load library like http://www.autoitscript.com/autoit3/doc ... llCall.htm, how can i do this nobody have any idea.
Thanks for help.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

thanks ts-soft, but my mean is aanother dllcall like dllcall dynamic.
i create a examp but i know my algo isnt good for dllcall please see my code and give me an idea for create it
i create a examp but i know my algo isnt good for dllcall please see my code and give me an idea for create it
Code: Select all
Structure Variable
long.l
name.s
EndStructure
Structure ReturnVar
long.l
str.s
name.s
EndStructure
Global mem = AllocateMemory(1024)
Macro calling(call_type, return_type, func, arg)
If return_type = "str"
If call_type = "cdecl"
ret1.s = PeekS(CallCFunctionFast(func, arg))
Else
ret1.s = PeekS(CallFunctionFast(func, arg))
EndIf
ElseIf return_type = "long"
If call_type = "cdecl"
ret2.l = CallCFunctionFast(func, arg)
Else
ret2.l = CallFunctionFast(func, arg)
EndIf
EndIf
EndMacro
Procedure DllCall(lpFileName.s, lpProcName.s, List Parameters.s(), OutPut.s)
Protected DLL.l
mem = AllocateMemory(1024)
DLL = LoadLibrary_(@lpFileName)
If DLL
calling_func = GetProcAddress_(DLL, @lpProcName)
If calling_func
Dim Param.Variable(ListSize(Parameters()) - 1)
i = 0
ForEach Parameters()
Param(i)\name = Mid(Parameters(), 1, FindString(Parameters(), ":", 1) - 1)
Select Param(i)\name
Case "long" : Param(i)\long = Val(Mid(Parameters(), FindString(Parameters(), ":", 1) + 1))
EndSelect
i = i + 1
Next
call_type.s = Mid(OutPut, 1, FindString(OutPut, ":", 1) - 1)
ret_type.s = Mid(OutPut, FindString(OutPut, ":", 1) + 1)
If Param(0)\name = "long"
calling(call_type, ret_type, calling_func, Param(0)\long)
If ret_type = "str"
PokeS(mem, ret1)
ProcedureReturn
Else
PokeL(mem, ret2)
ProcedureReturn
EndIf
EndIf
EndIf
FreeLibrary_(DLL)
EndIf
EndProcedure
NewList par.s()
NewList par2.s()
AddElement(par())
par() = "long:0" ; #SM_CXSCREEN
AddElement(par2())
par2() = "long:1" ; #SM_CYSCREEN
DllCall("user32.dll", "GetSystemMetrics", par(), "stdcall:long")
Debug PeekL(mem)
DllCall("user32.dll", "GetSystemMetrics", par2(), "stdcall:long")
Debug PeekL(mem)