May 09, 2024, 03:55:52 AM

News:

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


Passing ISTRING into function

Started by TexasPete, February 05, 2009, 01:00:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TexasPete

February 05, 2009, 01:00:30 PM Last Edit: February 05, 2009, 01:06:04 PM by Paul Turley
THE COMPILER TOOK THE FOLLOWIN WITH NO PROBLEM.
CHANGEFUNCTION (TEXT1:STRING)

IT WOULD NOT TAKE:
CHANGEFUNCTION(TEXT1:ISTRING)

What would the correct Form be for passing a string 12,000 character long. or is it not possible

Thanks
Texas Pete
Ps should I make the sting global


Ionic Wind Support Team

the ISTRING keyword is only for defining the variable.

As indicated by the users guide STRING's are passed by reference, if you don't know what that means then ask.

SUB mysub( text1 as string)

Will accept any length, because strings are passed by reference, and not value.

Paul.

PS.  Please don't type things in all caps, it makes it hard to read.
Ionic Wind Support Team

TexasPete

Paul ,
Should not the following have worked?

changepath(text1:string)

If so I must def text1 string and follows:
def text1[2000] :istring

If so the compiler sees "text1" string as text1 whether or not it is 255 characters or 2000.
I hope I have this right.
Thanks Texas Pete

Ionic Wind Support Team

Pete,
Yes.

Think of it this way

def text1 as STRING

is the same as

def text1[255] as ISTRING

The 'default' length of a string is 255 characters.  The ISTRING keyword just lets you override the default, and has nothing to do with how subroutine parameters are defined.  ISTRING is not a type.

Again if you don't understand the difference between passing parameters by value or by reference then you need to study up a bit on the subject. 

Paul.
Ionic Wind Support Team

TexasPete

Thanks Paul sometimes I make things more complicated than they are.
Texas Pete