@ all: Thanks for the feedback :)
@Roland:
if you finish your input with return, then StringGagdet sends a normal GADGETMESSAGE, that you can verify.
both methods of changing the text are working: SetString() ist the encapsuled version of "TO_SetLineContent+UpdateGadget"
Dont forget the 6. Parameter of AddStringGadet.Its a char limitation: 0=all >asc(31), 1=integer, 2=float, 3=binary, 4=hexadecimal, 5=IPAddresses ;)
Code: Select all
#include "sGUI\sGUI.bas"
#include once "sGUI\SimpleGadget.bas"
#include once "sGUI\StringGadget.bas"
screenres 145,225,32
width 145\8,225\16
InitGFX
windowtitle ""
dim as EventHandle ptr event
event=CreateEventHandle
dim as Gadget ptr textedit1,textedit2
textedit1=AddStringGadget(event,10,10,10,"11111111")
textedit2=AddStringGadget(event,10,42,4,"")
GadgetOn (textedit1)
GadgetOn (textedit2)
'GadgetSleep (textedit2)
declare function two_power(n as ubyte) as uinteger
declare function octet_to_ubyte(octet as string) as ubyte
dim s as string
do
event->xSleep(1)
if event->GADGETMESSAGE then
select case event->GADGETMESSAGE
case textedit1
SetString(textedit2 , str( octet_to_ubyte( GetString(textedit1) ) ) )
case textedit2
'may be... reverse convert?????
'SetString(textedit1,ubyte_to_octet(GetString(textedit2))
end select
end if
loop until event->EXITEVENT
DestroyEventHandle (event)
end
function two_power(n as ubyte) as uinteger
dim i as ubyte
dim tmp as uinteger
if n=0 then return 1
if n=1 then return 2
tmp=2
for i=2 to n
tmp=tmp*2
next i
return tmp
end function
function octet_to_ubyte(octet as string) as ubyte
dim i as ubyte
dim tmp as ubyte=0
for i=1 to len(octet)
if octet[len(octet)-i]=asc("1") then tmp+=two_power(i-1)
next i
return tmp
end function
Mutton