Brightsign BrightScript 3.0 Reference Manual Uživatelský manuál

Procházejte online nebo si stáhněte Uživatelský manuál pro Software Brightsign BrightScript 3.0 Reference Manual. BrightSign BrightScript 3.0 Reference Manual User Manual Uživatelská příručka

  • Stažení
  • Přidat do mých příruček
  • Tisk

Shrnutí obsahu

Strany 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

Strany 2 - TABLE OF CONTENTS

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

Strany 3

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

Strany 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

Strany 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

Strany 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

Strany 7

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

Strany 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

Strany 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

Strany 10

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

Strany 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

Strany 12 - Assoiative Array Literals

TABLE OF CONTENTS Introduction ...

Strany 13 - Number Type Conversion

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 19

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

Strany 20 - Wrapper Objects

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

Strany 21

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

Strany 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

Strany 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

Strany 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):

Strany 26

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

Strany 27

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

Strany 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

Strany 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

Strany 30

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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 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

Strany 42

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

Strany 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

Strany 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

Strany 45 - IF / THEN / ELSE

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

Strany 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

Strany 47

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

Strany 48

47 q.starring(myobj, myxml)

Strany 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

Strany 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

Strany 51

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

Strany 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

Strany 53 - BUILT-IN FUNCTIONS

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

Strany 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

Strany 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

Strany 56 - GetLastRunCompileError()

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

Strany 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

Strany 58

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

Strany 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

Strany 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

Strany 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

Strany 62

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

Strany 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

Strany 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

Strany 65

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

Strany 66

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

Strany 67

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

Strany 68

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

Strany 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

Strany 70

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

Strany 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

Strany 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

Strany 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&

Strany 74

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

Strany 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

Komentáře k této Příručce

Žádné komentáře