Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Variable Command for getting selected options data
- Loading branch information
1 parent
953e959
commit 8ef93d0
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.uecide.varcmd; | ||
|
||
import org.uecide.*; | ||
|
||
public class vc_option implements VariableCommand { | ||
public String main(Sketch sketch, String args) { | ||
|
||
String[] bits = args.split("\\."); | ||
|
||
if (bits.length != 2) { | ||
return "ERR1"; | ||
} | ||
|
||
String opt = bits[0]; | ||
String key = bits[1]; | ||
String optval = sketch.getOption(opt); | ||
|
||
if (optval == null) { | ||
return "ERR2"; | ||
} | ||
|
||
String val = "options." + opt + "." + optval + "." + key; | ||
PropertyFile props = sketch.mergeAllProperties(); | ||
String retval = props.get(val); | ||
if (retval == null) { | ||
return "ERR3"; | ||
} | ||
return retval; | ||
} | ||
} |