11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

174 • Chapter 4: Input and Output> end if;> count := count[1];>> # Read the numbers in the row.> row := [];> while count > 0 do> num := fscanf(fileName,",%e");> if num = 0 then> error "unexpected end of file"> end if;> if num = [] then> error "number expected in file"> end if;> row := [op(row),num[1]];> count := count - 1> end do;>> # Append the row to the accumulated result.> A := [op(A),row]> end do;> A> end proc:Reading Maple StatementsThe readstat command reads a single Maple statement from theterminal input stream. Maple parses and evaluates the statement, andreturns the result. Call the readstat command as follows.readstat( prompt, ditto3, ditto2, ditto1 )The prompt argument specifies the prompt that readstat is to use. If youomit the prompt argument, Maple uses a blank prompt. You can eithersupply or omit all of the three arguments ditto3, ditto2, and ditto1. If yousupply them, they specify the values which Maple uses for %%%, %%, and% in the statement that readstat reads. Specify each of these argumentsas a Maple list containing the actual value for substitution. This allowsfor values that are expression sequences. For example, if % is to have thevalue 2*n+3 and %% is to have the value a,b, then use [2*n+3] for ditto1and [a,b] for ditto2.The response to readstat must be a single Maple expression. Theexpression can span more than one input line, but readstat does notpermit multiple expressions on one line. If the input contains a syntaxerror, readstat returns an error describing the nature of the error, andits position in the input.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!