Process optional #include statment at begining of macro.
(String code)
| 594 | |
| 595 | /** Process optional #include statment at begining of macro. */ |
| 596 | public static String doInclude(String code) { |
| 597 | if (code.startsWith("#include ")||code.startsWith("// include ")) { |
| 598 | if (IJ.isWindows()) |
| 599 | code = code.replaceAll("\r\n", "\n"); |
| 600 | int offset = code.startsWith("#include ")?9:11; |
| 601 | int eol = code.indexOf("\n"); |
| 602 | String path = code.substring(offset, eol); |
| 603 | boolean isURL = path.startsWith("http://") || path.startsWith("https://"); |
| 604 | if (!isURL) { |
| 605 | boolean fullPath = path.startsWith("/") || path.startsWith("\\") || path.indexOf(":\\")==1 || path.indexOf(":/")==1; |
| 606 | if (!fullPath) { |
| 607 | String macrosDir = Menus.getMacrosPath(); |
| 608 | if (macrosDir!=null) |
| 609 | path = Menus.getMacrosPath() + path; |
| 610 | } |
| 611 | File f = new File(path); |
| 612 | if (!f.exists()) |
| 613 | IJ.error("Include file not found:\n"+path); |
| 614 | } |
| 615 | code = code.substring(eol+1,code.length()); |
| 616 | if (isURL) |
| 617 | code = "//\n"+code + IJ.openUrlAsString(path); |
| 618 | else |
| 619 | code = "//\n"+code + IJ.openAsString(path); |
| 620 | } |
| 621 | return code; |
| 622 | } |
| 623 | |
| 624 | void evaluateMacro() { |
| 625 | String title = getTitle(); |
no test coverage detected