[Grace-core] Proposed Input spec

Kim Bruce kim at cs.pomona.edu
Thu Jul 3 10:04:58 PDT 2014


We were looking for a quick-and-dirty and simple way of doing input from text files, especially given the limitations in Javascript (which neither of us knows much about).  As a result, Femi built a button which allows the user to select a text file.  It converts the contents to  a string (mashing things around enough to retain newlines, etc) and then dumps it in a tab in the UI window as 
def read = "... file contents ..."

The operation in the module then allow you to use them to do the same things you do in the Scanner class in Java, which was put in because people complained about how complex Java I/O was for novices.

We realize that what is there now is unsatisfactory, but we didn't have a deep enough understanding of the Javascript to bring the file contents in via a nicer method.  My hope is that someone else with more expertise can do that bit and then just use Femi's code to perform the (faked) input.

Kim



On Jul 2, 2014, at 9:37 PM, Andrew P. Black <black at cs.pdx.edu> wrote:

> These look like methods on string streams — iterators over strings.    I agree that we need such a module.   These methods don’t seem to have anything to do with input or output.  An I missing something?
> 
> 	Andrew
> 
> 
> On 18 Jun 2014, at 11:27, Kim Bruce <kim at cs.pomona.edu> wrote:
> 
>> Here is the spec that Femi is planning on implementing as a way of handling input.  There would be a class taking a filepath as a parameter that would construct objects of this type.  It is based on a simplified version of the Scanner class of Java and is intended to be very easy to use.
>> 
>> // Handles all types of file input and parsing
>> type graceInput = {
>> 
>>   // Moves to the indicated position in the file
>>   goToPosition(pos:Number)->Done
>> 
>>   // Returns true if the current position is at the end of the file
>>   endOfFile->Boolean
>> 
>>   //Determines if the next token is of the indicated type
>>   hasNextWord->Boolean
>>   hasNextNumber->Boolean
>>   hasNextBoolean->Boolean
>> 
>>   // Returns the next token if it is of the correct type
>>   // Raises an IOException if the token is of the wrong type
>> 
>>   // Returns the next number in the file as a number 
>>   nextNum(s:String)->Number
>> 
>>   // Returns the next line of text excluding the "\n" character
>>   nextLine(s:String)->String
>> 
>>   // Returns the next word in the file excluding white spaces
>>   nextWord(s:String)->String
>> 
>>   // Returns the next Boolean that is found in the file
>>   nextBoolean(s:String)->Boolean
>> 
>> }
>> 
>> Comments/Questions/Suggestions?
>> Kim
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Grace-core mailing list
>> Grace-core at cecs.pdx.edu
>> https://mailhost.cecs.pdx.edu/mailman/listinfo/grace-core
> 




More information about the Grace-core mailing list