June 30, 2024, 06:31:02 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Default return value

Started by Techno, November 09, 2013, 02:55:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Techno

Hi all,

1) What is the default return value in a procedure when there is no data type or pointer defined?.

2) Can I return a pointer as a return value, and how do you do that?.

3) What is an ASCII string in Terminal Zero IWBasic?

Kind regards
Stephane

LarryMc

Quote from: Techno on November 09, 2013, 02:55:05 AM
1) What is the default return value in a procedure when there is no data type or pointer defined?.
If you don't declare a return type and value then there is none.

Quote from: Techno on November 09, 2013, 02:55:05 AM
2) Can I return a pointer as a return value, and how do you do that?.
You can return any type you want once you declare it.
sub myproc1(), int
INT x
x=4
return x
endsub

sub myproc2(), string
string x
x="hello"
return x
endsub

sub myproc3(), pointer
pointer x
x= some memory location
return x
endsub


Quote from: Techno on November 09, 2013, 02:55:05 AM
3) What is an ASCII string in Terminal Zero IWBasic?
I'm not sure what you are asking.
In IWBasic this is an ASCII string - "abcd"
In memory it would take up 5 memory locations with the last being 0x00.
All IWBasic strings are terminated with a NULL character internally.  That's why we don't have to ever say how long a string is when we pass it to a function.  In some C type library functions we usually have to tell it how long a string is because strings aren't always null terminated.

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library