Interactive PowerBasic Forum

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Frank BrĂ¼bach on May 30, 2024, 03:24:03 PM

Title: Type question
Post by: Frank BrĂ¼bach on May 30, 2024, 03:24:03 PM
Hello Charles,

Can I add a value and a String with a Type in a function?

type aStruct
    a as long
    b as zstring
end type

function one_add(long a,b) as long
dim st as aStruct

st.a = 5
st.b = "Thor"
return a+b

end function

function two_add(long a,b) as long
dim st as aStruct

st.a = 5
st.b = "Thor"
return st.a+str(st.b)

end function

print "one_add: " + one_add(2,4) ' result 6
print "two_add: " + two_add(2,4) ' result 50 ' ???

Title: Re: Type question
Post by: Charles Pegge on May 30, 2024, 04:42:28 PM
Hi Frank,

I could not make sense of your example but in any case, you will need to specify the allocated char count of the zstring

type aStruct
    a as long
    b[16] as zstring
end type