REBOL Essentials
Total Page:16
File Type:pdf, Size:1020Kb
1 Creating lightweight cross-platform Applications Viktor Pavlu 9-Jan-2003 2 FOREWORD ........................................................................................................................................................ 5 RESOURCES AND EXAMPLES ....................................................................................................................... 5 PART I. REBOL LANGUAGE TUTORIAL..................................................................................................... 6 WHAT IS REBOL?.............................................................................................................................................. 7 CARL SASSENRATH ABOUT REBOL ...................................................................................................................8 WHAT OTHERS SAY.............................................................................................................................................8 VERSIONS............................................................................................................................................................ 9 RUNNING YOUR FIRST PROGRAM............................................................................................................ 10 SETUP ...............................................................................................................................................................10 GET THE USER GUIDE .......................................................................................................................................10 TRY THIS...........................................................................................................................................................10 REBOL BASICS................................................................................................................................................. 12 VALUES ............................................................................................................................................................12 Datatypes ....................................................................................................................................................12 WORDS .............................................................................................................................................................13 Types of Words............................................................................................................................................13 Unsetting a Word ........................................................................................................................................15 Protecting a Word .......................................................................................................................................16 BLOCKS ............................................................................................................................................................16 CONCLUSION ....................................................................................................................................................17 CONTROL STRUCTURES .............................................................................................................................. 18 WHAT IS TRUE?.................................................................................................................................................19 SIMPLE MATH ................................................................................................................................................. 20 Mathematical Words ...................................................................................................................................20 Comparison Functions ................................................................................................................................21 STRINGS............................................................................................................................................................. 21 SPECIAL CHARACTERS......................................................................................................................................21 EXERCISE PROGRAMS I ............................................................................................................................... 22 USEFUL FUNCTIONS..........................................................................................................................................22 WORKING WITH REBOL .............................................................................................................................. 22 INTERPRETER STARTUP.....................................................................................................................................23 INFORMATION PASSED TO SCRIPT .....................................................................................................................24 SERIES! .............................................................................................................................................................. 24 CREATING SERIES .............................................................................................................................................25 RETRIEVING ELEMENTS ....................................................................................................................................25 MODIFYING ELEMENTS.....................................................................................................................................26 TRAVERSING SERIES .........................................................................................................................................27 OTHER SERIES! FUNCTIONS ..............................................................................................................................28 FUNCTION! ....................................................................................................................................................... 29 INTERFACE SPECIFICATION BLOCK ...................................................................................................................29 Restricting Types.........................................................................................................................................30 Adding Documentation................................................................................................................................30 Refinements .................................................................................................................................................31 INTERACTION WITH THE OUTSIDE.....................................................................................................................32 Literal Arguments........................................................................................................................................32 Get Arguments.............................................................................................................................................32 Scope...........................................................................................................................................................33 Returning Values.........................................................................................................................................33 3 Function Attributes......................................................................................................................................34 ERRORS ............................................................................................................................................................34 Error Object................................................................................................................................................34 Generating Errors.......................................................................................................................................34 EXERCISE PROGRAMS II.............................................................................................................................. 36 TINY REFERENCE........................................................................................................................................... 37 Console I/O .................................................................................................................................................37 Files & Directories......................................................................................................................................37 Help & Debug .............................................................................................................................................37 Evaluation ...................................................................................................................................................37 Loops...........................................................................................................................................................37 Stopping evaluation.....................................................................................................................................37 Series...........................................................................................................................................................37