'---------------------------------------------------------------------------------------- ' Name: SCAN_OR_SKIP_FLASH.TIG ' Type: TIGER-BASIC(tm) Source Code ' ' Purpose: Short demo for the SCAN_OR_SKIP function searching or skipping certain ' characters in strings by Flash table. ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '---------------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ideas ' or special needs, please contact your next distributor or the Tiger support team ' and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9068 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '---------------------------------------------------------------------------------------- ' ' This program may be executed on a Plug & Play Lab and be compiled with Tiger-BASIC ' Version 5 or later, TAC system 1.16g or later. ' ' Demo on how to use the SCAN_OR_SKIP function to find the next position of a character ' belonging to a group of characters in a source string (SCAN) or the next position of ' any character not belonging to that group of characters (SKIP). ' ' ' NEW_POS = SCAN_OR_SKIP ( SOURCE$, CHARSET, POS, +=Scan or -=Skip ) ' ! ! ! ! ' ! ! ! !<--- positive --> SCAN ' ! ! ! negative --> SKIP ' ! ! ! ' ! ! !<--- Start position in SOURCE$ ' ! ! ' ! !<--- Character Set Flag-Tab in Flash: ' ! 00 = not a member of this charset ' ! XX = IS member of this charset ' ! ' !<--- Source string with text, data or whatever ' ' ' Charset$ = Flag-table in Flash, always 256 bytes long. Position in table ' determines the code that it represents. ' ' 00 = not a member of this charset ' XX = IS member of this charset ' ' +=Scan or -=Skip = 0 ... nn ==> SCAN function chosen. We l o o k for the first ' character from CHARSET$ ' ' -nn ... -1 ==> SKIP characters of CHARSET$ in SOURCE$ until you ' find the first NON-character of CHARSET$ ' ' So, SKIP is the INVERSE function to SCAN. ' SKIP charset <==> SCAN NON-charset. ' ' Result: NEW_POS = 0 ... nnn ==> new POS of the first found char ' -1 ==> not found, end of string reached ' -2 ==> Error, empty string or POS outside SOURCE$ ' '---------------------------------------------------------------------------------------- USER_VAR_STRICT ' variables must be declared TASK MAIN ' begin task MAIN STRING SOURCE$ ' declare variables LONG POS DATALABEL SEPERATOR_FLASH INSTALL_DEVICE #1, "LCD1.TDD" ' install LCD driver ' ' build set of separator chars (FF = separator chars, 00 = other chars) ' only "." and " " (blank) are separator characters here ' SEPERATOR_FLASH:: DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 00..0F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 10..1F DATA BYTE 0FFH, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 0FFH, 000H ' 20..2F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 30..3F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 40..4F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 50..5F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 60..6F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 70..7F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 80..8F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' 90..9F DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' A0..AF DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' B0..BF DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' C0..CF DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' D0..DF DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' E0..EF DATA BYTE 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H ' F0..FF SOURCE$ = "The quick.brown.fox jumps over.the lazy.dog" ' source string POS = 0 ' start scanning at position 0 PRINT #1, "<1>Separators found at positions:"; ' print start text on LCD WHILE POS >= 0 ' while no error flag POS = SCAN_OR_SKIP (SOURCE$, SEPERATOR_FLASH, POS, 1)' Scan for next separator char IF POS >= 0 THEN ' if valid position PRINT #1, POS; ' print position on LCD POS = POS + 1 ' increase position ENDIF ' ENDWHILE ' PRINT #1, " end" ' print "end-of-string" WAIT_DURATION 5000 ' wait 5 seconds SOURCE$ = ".. ..- .... . + ... .-+ . ... -.." ' new source string POS = 0 ' start scanning at position 0 PRINT #1, "<1>Non separator chars found at:"; ' print start text on LCD WHILE POS >= 0 ' while no error flag POS = SCAN_OR_SKIP (SOURCE$, SEPERATOR_FLASH, POS, -1)' Skip all separator chars IF POS >= 0 THEN ' if valid position PRINT #1, POS; ' print position on LCD POS = POS + 1 ' increase position ENDIF ' ENDWHILE ' PRINT #1, " end" ' print "end-of-string" END ' end of task MAIN