matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016
01:11 PM
Re: Brightscript Sub and Function Routine
So with 'Sub' I can declare a value to Something without having to return that value back out of the routine like I would have to do with a 'Function'? or are you meaning something different?
Something = Door
Somthing = Sub() or Somthing = Function()
Sub()
Change Something to = "Window"
End Sub
Function()
Change Something to = "Window"
return window
End Function
Something = Door
Somthing = Sub() or Somthing = Function()
Sub()
Change Something to = "Window"
End Sub
Function()
Change Something to = "Window"
return window
End Function

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016
01:25 PM
Re: Brightscript Sub and Function Routine
"matrixebiz" wrote:
So with 'Sub' I can declare a value to Something without having to return that value back out of the routine like I would have to do with a 'Function'? or are you meaning something different?
You are not required to return something from a function.
Kinetics Screensavers
matrixebiz
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2016
01:27 PM
Re: Brightscript Sub and Function Routine
Okay, thank you

Komag
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016
09:56 AM
Re: Brightscript Sub and Function Routine
sometimes I want to conditionally cancel a function with an empty RETURN, and if I plan to do that, I just have to add the AS VOID to the FUNCTION at the top or else I'll get a Return error.
Ex:
Ex:
FUNCTION mapScrollOne(dir) AS VOID
map = m.drAA.map
IF NOT m.mAA.flL[map.mapFl][ 1] THEN RETURN
IF map.mInvert THEN dir = oppFace(dir)
moveY = 0
moveX = 0
mSYp = map.mapScrollY
mSXp = map.mapScrollX
d = m.sy.sett.scrollSz
IF dir = 0: moveY = - d: mSYp = mSYp - d
ELSEIF dir = 1: moveX = d: mSXp = mSXp + d
ELSEIF dir = 2: moveY = d: mSYp = mSYp + d
ELSEIF dir = 3: moveX = - d: mSXp = mSXp - d
END IF
IF checkMapRoom(dir, mSYp, mSXp)
map.mapScrollY = mSYp
map.mapScrollX = mSXp
offsetMap(moveY, moveX)
playSound("menuForw", 0, 0, 0, FALSE, 1, 1)
END IF
END FUNCTION

squirreltown
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016
10:21 AM
Re: Brightscript Sub and Function Routine
"Komag" wrote:
sometimes I want to conditionally cancel a function with an empty RETURN, and if I plan to do that, I just have to add the AS VOID to the FUNCTION at the top or else I'll get a Return error.
Or you could return 0
Kinetics Screensavers

marcelo_cabral
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016
12:28 PM
Re: Brightscript Sub and Function Routine
"Komag" wrote:
sometimes I want to conditionally cancel a function with an empty RETURN, and if I plan to do that, I just have to add the AS VOID to the FUNCTION at the top or else I'll get a Return error.
You can also use Return from a Sub the same way.

Komag
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016
02:54 PM
Re: Brightscript Sub and Function Routine
"squirreltown" wrote:"Komag" wrote:
sometimes I want to conditionally cancel a function with an empty RETURN, and if I plan to do that, I just have to add the AS VOID to the FUNCTION at the top or else I'll get a Return error.
Or you could return 0
Functions are Integers by default? If I have to declare AS INTEGER then it's easier to type AS VOID and save myself the trouble later on of typing that 0. But if you can do 0 by default without the AS VOID that's nice to know.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016
03:18 PM
Re: Brightscript Sub and Function Routine
"Komag" wrote:
Functions are Integers by default?
Functions and variables in B/S are "as Dynamic", unless otherwise explicitly declared. That means you can return ANY of The Types.

Komag
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2016
07:52 PM
Re: Brightscript Sub and Function Routine
Ah yes, if I would have applied my noggin a little harder I might have realized/remembered that! At least, I knew it regarding variables.
- « Previous
-
- 1
- 2
- Next »