()
| 6775 | } |
| 6776 | |
| 6777 | Variable[] showArray() { |
| 6778 | int maxLength = 0; |
| 6779 | String title = "Arrays"; |
| 6780 | ArrayList arrays = new ArrayList(); |
| 6781 | ArrayList names = new ArrayList(); |
| 6782 | interp.getLeftParen(); |
| 6783 | do { |
| 6784 | if (isStringArg() && !isArrayArg()) |
| 6785 | title = getString(); |
| 6786 | else { |
| 6787 | int symbolTableAddress = pgm.code[interp.pc+1]>>TOK_SHIFT; |
| 6788 | names.add(pgm.table[symbolTableAddress].str); |
| 6789 | Variable[] a = getArray(); |
| 6790 | arrays.add(a); |
| 6791 | if (a.length>maxLength) |
| 6792 | maxLength = a.length; |
| 6793 | } |
| 6794 | interp.getToken(); |
| 6795 | } while (interp.token==','); |
| 6796 | if (interp.token!=')') |
| 6797 | interp.error("')' expected"); |
| 6798 | int n = arrays.size(); |
| 6799 | if (n==1) { |
| 6800 | if (title.equals("Arrays")) |
| 6801 | title = (String)names.get(0); |
| 6802 | names.set(0, "Value"); |
| 6803 | } |
| 6804 | ResultsTable rt = new ResultsTable(); |
| 6805 | //rt.setPrecision(Analyzer.getPrecision()); |
| 6806 | int openParenIndex = title.indexOf("("); |
| 6807 | boolean showRowNumbers = false; |
| 6808 | if (openParenIndex>=0) { |
| 6809 | String options = title.substring(openParenIndex, title.length()); |
| 6810 | title = title.substring(0, openParenIndex); |
| 6811 | title = title.trim(); |
| 6812 | showRowNumbers = options.contains("row") || options.contains("1"); |
| 6813 | if (!showRowNumbers && options.contains("index")) { |
| 6814 | for (int i=0; i<maxLength; i++) |
| 6815 | rt.setValue("Index", i, ""+i); |
| 6816 | } |
| 6817 | } |
| 6818 | if (showRowNumbers) |
| 6819 | rt.showRowNumbers(true); |
| 6820 | for (int arr=0; arr<n; arr++) { |
| 6821 | Variable[] a = (Variable[])arrays.get(arr); |
| 6822 | String heading = (String)names.get(arr); |
| 6823 | for (int i=0; i<maxLength; i++) { |
| 6824 | if (i>=a.length) { |
| 6825 | rt.setValue(heading, i, ""); |
| 6826 | continue; |
| 6827 | } |
| 6828 | String s = a[i].getString(); |
| 6829 | if (s!=null) |
| 6830 | rt.setValue(heading, i, s); |
| 6831 | else |
| 6832 | rt.setValue(heading, i, a[i].getValue()); |
| 6833 | } |
| 6834 | } |
no test coverage detected