Brightsign BrightScript 3.0 Reference Manual Bedienungsanleitung

Stöbern Sie online oder laden Sie Bedienungsanleitung nach Software Brightsign BrightScript 3.0 Reference Manual herunter. BrightSign BrightScript 3.0 Reference Manual User Manual Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken

Inhaltsverzeichnis

Seite 1 - BRIGHTSCRIPT REFERENCE

BRIGHTSCRIPT REFERENCE MANUAL BrightScript version 3.0 Compatible with firmware versions 3.8.x and later BrightSign, LLC. 16780 Lark Ave., Suite B

Seite 2 - TABLE OF CONTENTS

5 BrightScript Micro Debugger. Enter any BrightScript statement, debug commands, or HELP. BrightScript>

Seite 3

6 BrightScript> ?type(d) String BrightScript> d=1 BrightScript> ?type(d) Integer BrightScript> d=1.0 BrightScript> ?type(d) Float T

Seite 4

7 • Type Float: A number with a decimal (e.g. 2.01), in scientific notation (e.g. 1.23456E+30), or with a Float type designator (e.g. 2!) • Type D

Seite 5

8 Invalid Object Return Many methods (i.e. functions) that return objects can also return Invalid (for example, in cases where there is no object to

Seite 6 - INTRODUCTION

9 Division (/) operates using the same rules as above, except that it can never be carried out at the Integer level: When both operators are Integer

Seite 7

10 OPERATORS Operations in the innermost level of parentheses are performed first. Evaluation then proceeds according to the precedence in the follo

Seite 8 - Identifiers

11 if a=c and not(b>40) then print "success" On the other hand, if the arguments for these operators are numeric, they will perform bit

Seite 9

12 Associative Arrays When the "." Dot Operator is used on an Associative Array, it is the same as calling the Lookup() or AddReplace() me

Seite 10

13 array=CreateObject("roArray", 10, true) array[2]="two" print array[2] fivevar=five print fivevar() array[1]=fivevar print

Seite 11 - Literals (Constants)

14 a=5 If a=5 then print "a is 5" Unlike the C language, BrightScript does not support use of the = assignment operator inside an expressi

Seite 12 - Assoiative Array Literals

TABLE OF CONTENTS Introduction ...

Seite 13 - Number Type Conversion

15 OBJECTS, INTERFACES, AND LANGUAGE INTEGRATION BrightScript Objects Though BrightScript operates independently of its object architecture and libr

Seite 14 - Type Conversion and Accuracy

16 (-5).tostr() if type(5.tostr())<> "String" then stop if (-5).tostr()<>"-5" then stop if (1+2).tostr()<>&qu

Seite 15 - OPERATORS

17 Interfaces Interfaces in BrightScript operate similarly to Java or Microsoft COM: An interface is a known set of member functions that implement

Seite 16 - Dot Operator

18 Expression Parsing Any expression that expects a certain type of variable—including Integer, Float, Double, Boolean, or String—can accept an obje

Seite 17

19 • When applied to XML, which is technically case sensitive, the Dot Operator is still case insensitive. If you wish to perform a case-sensitive

Seite 18 - Equals Operator

20 The following will return an roXMLElement reference to the first photo (id="3131875696"): ? rsp.photos.photo[0] The following will retu

Seite 19

21 Function GetInterestingnessPhotoList(http as Object, page=1 As Integer) As Object print "page=";page http.SetUrl("http://a

Seite 20 - Wrapper Objects

22 End Function REM REM newPhotoFromXML REM REM Takes an roXMLElement Object that is an <photo> ... </photo> REM Returns an brs

Seite 21

23 if m.owner<>invalid return m.owner return m.xml@owner End Function Function pGetURL() As String a=m.xml.GetAttributes() url="

Seite 22 - Interfaces

24 GARBAGE COLLECTION BrightScript automatically frees strings when they are no longer used, and it will free objects when their reference count goe

Seite 24

25 EVENTS Events in BrightScript center around an event loop and the roMessagePort object. Most BrightScript objects can post to a message port in t

Seite 25

26 end while Note that these two lines, while true msg=wait(0, p) Can be replaced using the following (and substituting end while with end for):

Seite 26

27 THREADING MODEL BrightScript runs in a single thread. In general, BrightScript object calls are synchronous if they return quickly, and asynchron

Seite 27

28 SCOPE BrightScript uses the following scoping rules: • Global variables are not supported; however, there is a single hard-coded global variable

Seite 28

29 INTRINSIC OBJECTS In general, this manual uses the term “object” to refer to “BrightScript components”, which are C or C++ components with interf

Seite 29 - GARBAGE COLLECTION

30 PROGRAM STATEMENTS BrightScript supports the following statement types. The syntax of each statement is documented in more detail later in this c

Seite 30

31 cavemen.push("betty") for each caveman in cavemen print caveman end for End Function Statement Syntax Each line may contain

Seite 31

32 Example: The first statement will include a library in the same folder as the script, while the second will include a library in a sub-folder. L

Seite 32 - THREADING MODEL

33 For x = 1 To 5 For y = 1 To 4 For z = 1 To 6 c[x, y, z] = k k = k + 1 End for End for End for k=0 Fo

Seite 33

34 Example: In each of the following lines, the variable on the left side of the equals operator is assigned the value of the constant or expression

Seite 35 - PROGRAM STATEMENTS

35 RETURN RETURN expression The RETURN statement returns from a function back to its caller. If the function is not type Void, RETURN can also retu

Seite 36 - LIBRARY

36 Example: > x=5:print 25; "is equal to"; x ^2 > run 25 is equal to 25 Example: > a$="string" > print a$;a$,a$;&q

Seite 37

37 A trailing semicolon overrides the cursor-return so that the next PRINT statement begins where the last left off. If no trailing punctuation is u

Seite 38 - Assignment (“=”)

38 POS(x) This statement returns an integer that indicates the current cursor position from 0 to the maximum width of the window. This statement req

Seite 39

39 When program flow reaches the END FOR statement, the counter is incremented by the specified increment amount (or decremented if increment is a

Seite 40

40 For each n in aa Print n;aa[n] aa.delete[n] end for WHILE / EXIT WHILE WHILE expression / EXIT WHILE A WHILE loop executes until the speci

Seite 41

41 Note: This is the single-line form of the IF THEN ELSE statement; see the next section for more details about the block form of the IF THEN ELSE

Seite 42

42 ElseIf BooleanExpression [ Then ] [ Block ] ElseStatement ::= Else [ Block ] Example: vp_msg_loop: msg=wait(tiut, p)

Seite 43 - FOR / END FOR

43 endif goto vp_msg_loop Function() As Type / End Function Function name(parameter As Type, …) As Type Note: Each function has it

Seite 44 - FOR EACH IN / END FOR

44 • Integer • Float • Double • String • Object • Dynamic Example: Function cat(a, b) Return a+b 'a, b could be numbers or strings E

Seite 45 - IF / THEN / ELSE

Appendix B – Reserved Words ... 58 Appendix C – Example Script

Seite 46

45 End Function “m” Identifier If a function is called from an associative array, then the local variable m is set to the associative array in which

Seite 47

46 Anonymous Functions A function without a name declaration is considered anonymous. Example: The following is a simple anonymous function declara

Seite 48

47 q.starring(myobj, myxml)

Seite 49

48 BUILT-IN FUNCTIONS BrightScript features a set of built-in, module-scope, intrinsic functions. A number of file I/O, string, mathematics, and sys

Seite 50

49 Note: The Rnd() functions utilize a pseudo-random seed number that is generated internally and not accessible to the user. Box() Box(type As Dyna

Seite 51

50 Print Run("test2.brs", "arg 1", "arg 2") if Run(["file1.brs","file2.brs"])<>4 then st

Seite 52

51 Eval() Eval(code_snippet As String) As Dynamic This function runs the passed code snippet in the context of the current function. The function c

Seite 53 - BUILT-IN FUNCTIONS

52 GetLastRunRuntimeError() GetLastRunRuntimeError() As Integer This function returns the error code that resulted from the last Run() function. T

Seite 54

53 BRIGHTSCRIPT CORE LIBRARY EXTENSION There are a number of built-in functions that are not part of the BrightScript Core Library. You can use the

Seite 55

54 BRIGHTSCRIPT DEBUG CONSOLE If, while a script is running, a runtime error occurs or a STOP statement is encountered, the BrightSign application w

Seite 56 - GetLastRunCompileError()

1 INTRODUCTION BrightScript is a powerful scripting language for building media and networked applications for embedded devices. This language featu

Seite 57 - GetLastRunRuntimeError()

55 ld Show line data (source records) next Show the next line to execute. bsc List all allocated BrightScript Component instances. stats Show statis

Seite 58

56 APPENDIX A – BRIGHTSCRIPT VERSIONS BrightScript Version Matrix January 9, 2009 HD20000 1.3 Branch HD2000 2.0 Branch Compact Main Line

Seite 59 - BRIGHTSCRIPT DEBUG CONSOLE

57 Type() Change: Now matches declaration names (eg. Integer not roINT32) X Added roBoolean X Added dynamic Type; Type now optional on Sub/F

Seite 60

58 APPENDIX B – RESERVED WORDS AND ENDSUB LINE_NUM RND CREATEOBJECT ENDWHILE M* STEP DIM EXIT NEXT STOP EACH EXITWHILE NOT SUB EACH FALSE OBJF

Seite 61

59 APPENDIX C – EXAMPLE SCRIPT The following code uses GPIO buttons 1, 2, 3, 4 for controls. It will work on any BrightSign model that has a video o

Seite 62

60 REM ******************************************************* REM *************** ********************* REM *************** GAME

Seite 63 - APPENDIX B – RESERVED WORDS

61 End Function REM REM gbInit() is a member function of the game_board BrightScript Object. REM When it is called, the "this" pointer

Seite 64 - APPENDIX C – EXAMPLE SCRIPT

62 if h>MAXHI then h=MAXHI xpix = cint((vidmode.GetResX() - w*CELLWID)/2) ' center game board on screen ypix = cint((vidmod

Seite 65

63 Function gbStartX() As Integer return cint(m.text_field.GetWidth()/2) End Function Function gbStartY() As Integer return cint(m.text_f

Seite 66

64 if m.snake.MoveForward(m.text_field) then return endif endif end while End Function Sub gbDraw() R

Seite 67

2 BrightScript and its component architecture are written in 100% C for speed, efficiency, and portability. Since many embedded processors do not h

Seite 68

65 End Sub Function gbGameOver() As Boolean msg$= " G A M E O V E R " msg0$=" " width = m.tex

Seite 69

66 REM REM construct a new snake BrightScript object REM Function newSnake(x As Integer, y As Integer) As Object ' Create AA BrightScript Comp

Seite 70

67 snake.snake_X=x snake.snake_Y=y snake.body=191 ' use asc("*") if graphics not enabled. snake.dx=1 ' de

Seite 71

68 x=m.snake_X y=m.snake_Y for each seg in m.seg_list x=x+seg.Len*seg.xDelta y=y+seg.Len*seg.yDelta end for tex

Seite 72

69 return m.MakeLonger(text_field) End Function Function snkMakeLonger(text_field As Object) As Boolean m.snake_X=m.snake_X+m.dx m.sn

Seite 73

70 if m.dx<>0 or m.dy<>-1 then m.dx=0:m.dy=-1:m.AddSegment(m.dx, m.dy, 0) 'north End Sub Sub snkTurnSouth() if m.dx&

Seite 74

3 VARIABLES, LITERALS, AND TYPES Identifiers Identifiers are names of variables, functions, and labels. They also apply to BrightScript object metho

Seite 75

4 A variable that does not end in a type declaration may change its type dynamically. For example, the statement a=4 will create an integer, while a

Kommentare zu diesen Handbüchern

Keine Kommentare