efgee
03-09-2010, 01:46
Sorry to bother again... :)
How can a asciiz be used inside a class method?
Tried to return a string or a ascciiz but nothing seems to work.
Outside of a class - no problem...
Thanks
efgee
Below some generic test code I used:
' asciiz2string.bas
'
' how to use asciiz inside a class
' as oop
' efgee
; =======
; imports
; =======
dim as long kernel32 = LoadLibrary ("kernel32.dll")
bind kernel32 (
GetCommandLine GetCommandLineA : @0
GetModuleHandle GetModuleHandleA : @4
ExitProcess ExitProcess : @4
)
; =========
; constants
; =========
def true 1
def false 0
def fail -1
; =====
; CLASS
; =====
class test
private
static byref classcmdline as asciiz
public method SetCmdLine()
&this.classcmdline = GetCommandLine ()
; this prints out wrong!
print this.classcmdline
end method
public method GetCmdLine() as string
method = this.classcmdline
end method
end class
; =========
; variables
; =========
dim byref cmdline as asciiz, inst as long
dim commandline as string
dim p as test
; =====
; ENTRY
; =====
; normal way of doing it
&cmdline = GetCommandLine ()
; printing works
print cmdline
; get string value
commandline = cmdline
; check if the string type contains the
; correct value - works
print commandline
; ----------------------------
; now do the same with a class
; load the string into the asciiz class member
p.SetCmdLine()
; try to print it... crash!
print p.GetCmdLine() ; buggy!
freelibrary (kernel32)
ExitProcess ()
terminate
How can a asciiz be used inside a class method?
Tried to return a string or a ascciiz but nothing seems to work.
Outside of a class - no problem...
Thanks
efgee
Below some generic test code I used:
' asciiz2string.bas
'
' how to use asciiz inside a class
' as oop
' efgee
; =======
; imports
; =======
dim as long kernel32 = LoadLibrary ("kernel32.dll")
bind kernel32 (
GetCommandLine GetCommandLineA : @0
GetModuleHandle GetModuleHandleA : @4
ExitProcess ExitProcess : @4
)
; =========
; constants
; =========
def true 1
def false 0
def fail -1
; =====
; CLASS
; =====
class test
private
static byref classcmdline as asciiz
public method SetCmdLine()
&this.classcmdline = GetCommandLine ()
; this prints out wrong!
print this.classcmdline
end method
public method GetCmdLine() as string
method = this.classcmdline
end method
end class
; =========
; variables
; =========
dim byref cmdline as asciiz, inst as long
dim commandline as string
dim p as test
; =====
; ENTRY
; =====
; normal way of doing it
&cmdline = GetCommandLine ()
; printing works
print cmdline
; get string value
commandline = cmdline
; check if the string type contains the
; correct value - works
print commandline
; ----------------------------
; now do the same with a class
; load the string into the asciiz class member
p.SetCmdLine()
; try to print it... crash!
print p.GetCmdLine() ; buggy!
freelibrary (kernel32)
ExitProcess ()
terminate