// a nonsensical Wilma rbscript displaying the basic concepts // The language reference manual for RealBasic is available in pdf form on the // RealBasic web site (http://realbasic.com) and the section on RBScript details // the functions etc available for the language // // In addition to the RB script functions, Wilma makes available two function calls // that permit access to the Wilma command interface. Both take an array of strings // as one of their arguments and this is filled with the return text normally display // with each element of the array representing one row Dim results() as String // processCommand executes a single command processCommand( "open development", results ) // while the very similar processCommandString allows will process several // commands separated by newlines or semi-colons processCommandString( "find hobo; listresults 5", results ) processCommandString( "find jack", results ) // print the results so far Dim i as integer for i = 0 to UBound( results ) print results( i ) next i // clear the results array of the previous stuff ReDim results( 0 ) processCommand( "listresults 5", results ) print results( 4 ) // print line 4 print NthField( results(4), chr(9), 3 ) // print third field of line 4 ReDim results( 0 ) // clear results again // try processing wordcount results - this could be slow if the index is big processCommand( "wordcount", results ) // try calculating what percentage of files each word appears in // first get the number of files which had contents indexed Dim nFilesResults() as String processCommand( "getvalue numberFileContentsIndexed", nFilesResults ) Dim totalFiles as Double totalFiles = Val( nFilesResults(0)) print "totalFiles = " + Str( totalFiles ) + chr(10) Dim nFiles as Double Dim sWord as String for i = 0 to UBound( results ) - 1 // last record is totals sWord = NthField( results(i), chr(9), 1 ) nFiles = Val( NthField( results(i), chr(9), 2 )) print sWord + " - " + str( nFiles/totalFiles ) next i print "all done" + chr( 10 )