I'll try the attachments again with txt extensions -----Original Message----- From: Kessler CTR Mark J [mailto:mark.kessler....@usmc.mil] Sent: Monday, August 27, 2012 14:09 To: flex-dev@incubator.apache.org Subject: RE: Getting Mustella to work.
Gonna play a game of see if the exchange server strips my attachments... ----- Ok I've worked on it a bit here and there. I rolled it up to a class to make it easier to implement. By far the regex was the longest pieces. For those who want to know, the Regex in actioscript is the same flavor as javascript. Can use this website to fiddle with it without having to complile http://jsfiddle.net/ //Create an instance of the class. var oArgs:ArgManage = new ArgManage(); //Toss in the argument string. oArgs.StringArugments = sMyExistingArgumentsString; //Run any of the stock functions to add/update/remove arguments. //The AddStaticArg is for strange things like "-debug" having no value assignment. public function AddArg(sName:String, sValue:String):void; public function AddStaticArg(sName:String):void; public function RemoveArg(sName:String):void; public function UpdateArg(sName:String, sValue:String):Boolean; //Get your new combined string back out. sMyExistingArgumentsString = oArgs.StringArugments; Possible things left to do: -Change arraylists to vectors. -Take a little redundancy out of the code. -Change variable/function naming convention to some actionscript standard. - -----Original Message----- From: Peter Ent [mailto:p...@adobe.com] Sent: Monday, August 27, 2012 13:30 To: flex-dev@incubator.apache.org Subject: Re: Getting Mustella to work. Sure, I can work it in and give it a try. Thanks. --peter On 8/27/12 1:26 PM, "Kessler CTR Mark J" <mark.kessler....@usmc.mil> wrote: >Peter, did you want to test the argument handler test code today? > >-----Original Message----- >From: Peter Ent [mailto:p...@adobe.com] >Sent: Thursday, August 23, 2012 11:56 >To: flex-dev@incubator.apache.org >Subject: Re: Getting Mustella to work. > >Certainly appreciate the help. Here's a typical one when running Mustella: > >-debug -define=CONFIG::skaha,false >-compiler.fonts.managers=flash.fonts.JREFontManager,flash.fonts.AFEFont >Man >a >ger,flash.fonts.BatikFontManager,flash.fonts.CFFFontManager >-source-path=/Users/pent/apache/flex/mustella/Assets >-includes=ExcludeFileLocation -includes=SetShowRTE >-includes=SaveBitmapFailures >-includes=datagrid_properties_lockedColumnCount_mxml >-source-path=/Users/pent/apache/flex/mustella/tests/components/DataGrid >/Da >t >aGrid_SparkSkin/Properties --allow-source-path-overlap=true >-includes=SendResultsToRunner -includes=ExitWhenDone -source-path=. >-source-path=/Users/pent/apache/flex/mustella/../frameworks/ >-source-path=/Users/pent/apache/flex/mustella/as3/src/mustella > >Try changing my path, "/Users/pent/apache/" to something like >"/Users/pent/apache with spaces/" to get a better example. > >What happens in the code is that groups of these options may be coming >from the environment, so you might find "-debug >-define=CONFIG::skaha,false" being added as a single entity. Then code >turns what it has at the moment into a String[] and passes that to >another function that might add more arguments. If that function does, >it will turn the String[] back into a String, add the arguments, then >turn it back into String[]. > >But if you can make something that will convert the args into an >acceptable String[] it would be super-helpful. > >Thanks! >--peter
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" height="100%" width="100%" creationPolicy="all" initialize="Application_OnInitialize();" > <fx:Script> <![CDATA[ //Import class file. import ArgManage; //////////////////////////////////////// // Variables // //////////////////////////////////////// protected var oArgs:ArgManage = new ArgManage(); [Bindable] protected var sFirstElementCount:String = "0"; [Bindable] protected var sSecondElementCount:String = "0"; protected var sStartingString:String = '-debug -define=CONFIG::skaha,false -compiler.fonts.managers=flash.fonts.JREFontManager,flash.fonts.AFEFontManager,flash.fonts.BatikFontManager,flash.fonts.CFFFontManager -source-path=/Users/pent/apache/flex/mustella/Assets -includes=ExcludeFileLocation -includes=SetShowRTE -includes=SaveBitmapFailures -includes=datagrid_properties_lockedColumnCount_mxml -source-path=/Users/pent/apache/flex/mustella/tests/components/DataGrid/DataGrid_SparkSkin/Properties --allow-source-path-overlap=true -includes=SendResultsToRunner -includes=ExitWhenDone -source-path=. -source-path="/Users/long user name/apache/flex/mustella/../frameworks/" -source-path=/Users/test space/apache/flex/mustella/as3/src/mustella'; //////////////////////////////////////// // Methods // //////////////////////////////////////// //////////////////////////////////////// // Events // //////////////////////////////////////// //The Application OnInitialize event handler. protected function Application_OnInitialize():void { //Set the starting text. txtSource.text = sStartingString; } //Click event handler for the cmdRun Button. protected function cmdRun_OnClick():void { //Set the new string arguments list from the source textarea and have it processed into arrays. oArgs.StringArugments = txtSource.text; //Get a new string argument list back and display it. txtResult.text = oArgs.StringArugments; //Update the first length/count of elements. sFirstElementCount = String(oArgs.Length); //Add a couple new arguments oArgs.AddArg("--my-new-property", "valuemeal"); oArgs.AddArg("-TestItem", "valuemeal"); oArgs.AddStaticArg("-HasNoValue"); oArgs.AddStaticArg("-Keeper"); //Update the argument oArgs.UpdateArg("--my-new-property", "now with auto quotes"); //Delete an argument oArgs.RemoveArg("-HasNoValue"); //Get another copy of the string arguments to display. txtResult2.text = oArgs.StringArugments; //Update the second length/count of elements. sSecondElementCount = String(oArgs.Length); } ]]> </fx:Script> <!-- Layout --> <s:layout> <s:VerticalLayout horizontalAlign="left" verticalAlign="middle" gap="0" /> </s:layout> <!-- Source --> <s:Label text="Source" /> <s:TextArea id="txtSource" width="100%" /> <!-- Spacer--> <s:Rect height="20" /> <!-- Run --> <s:Button id="cmdRun" label="Run" click="cmdRun_OnClick();" /> <!-- Spacer--> <s:Rect height="20" /> <!-- Result --> <s:Label text="Result" /> <s:TextArea id="txtResult" width="100%" /> <!-- Spacer--> <s:Rect height="5" /> <!-- First Element Count --> <s:Label text="First Element Count: {sFirstElementCount}" /> <!-- Spacer--> <s:Rect height="20" /> <!-- Result2 --> <s:Label text="Result2" /> <s:TextArea id="txtResult2" width="100%" /> <!-- Spacer--> <s:Rect height="5" /> <!-- Second Element Count --> <s:Label text="Second Element Count: {sSecondElementCount}" /> </s:Application>
/*************************************** Variables. ---------------------------------------- --no public ones-- Properties. ---------------------------------------- //Gets or sets all the arguments in a single string. StringArugments [get, set] Methods. ---------------------------------------- //Resets the class. public function Reset():void //Adds a new argument and value. public function AddArg(sName:String, sValue:String):void //Adds a new static argument. public function AddStaticArg(sName:String):void //Return the argument static bool at the given index. public function GetStaticAt(nIndex:int):Boolean //Return the argument name at the given index. public function GetNameAt(nIndex:int):String //Return the argument value at the given index. public function GetValueAt(nIndex:int):String //Find the index of an argument by it's name public function IndexOfArg(sName:String):int //Remove an argument by it's name. public function RemoveArg(sName:String):void //Update an argument by it's name. public function UpdateArg(sName:String, sValue:String):Boolean Events. ---------------------------------------- Author: Mark Kessler Last Updated: 2012-08-27 ***************************************/ //Setup the package/namespace package { import mx.collections.ArrayList //Declare class public class ArgManage { //////////////////////////////////////// // Variables // //////////////////////////////////////// protected var saNames:ArrayList = new ArrayList(); protected var saValues:ArrayList = new ArrayList(); protected var baStaticArg:ArrayList = new ArrayList(); protected var sGivenSource:String = ""; //////////////////////////////////////// // Properties // //////////////////////////////////////// //Getter for StringArugments. public function get StringArugments():String { return this.CombineArguments(); } //Setter for StringArugments. public function set StringArugments(sSource:String):void { //Reset the arrays/strings this.Reset(); //Store the new source argument string. this.sGivenSource = sSource; //Seperate the arguments. this.SeperateArguments(); } //Getter for argument array length. public function get Length():int { return this.saNames.length; } //////////////////////////////////////// // Methods // //////////////////////////////////////// //Constructor. public function ArgManage():void { } //Resets the class back to default. public function Reset():void { this.saNames.removeAll(); this.saValues.removeAll(); this.baStaticArg.removeAll(); this.sGivenSource = ""; } //Adds a new argument and value. public function AddArg(sName:String, sValue:String):void { var nIndex:int = -1; //Make sure the name isn't empty. if (sName == "") { return; } //Find the arguments index. nIndex = this.IndexOfArg(sName); //Check if the argument was not found. if (nIndex == -1) { // // Add new item // //Add an element for the current name. this.saNames.addItem(sName); //Check if the given value is empty. if (sValue == "") { //Add an empty value. this.saValues.addItem(""); } else { //Check if the first and last character are double quotes. if (sValue.charAt(0) == "\"" && sValue.charAt(sValue.length-1) == "\"") { //Grab all but a starting and ending characters, trim any outside spaces, and add a new element with it. this.saValues.addItem(this.Trim(sValue.substr(1, sValue.length-2))); } else { //Add an element for the current value and trim any outside spaces. this.saValues.addItem(this.Trim(sValue)); } } //Mark the item as having values. this.baStaticArg.addItem(false); } else { // // Update an existing item // //Update the value for the argument with the givin one and trim any outer spaces. this.saValues.setItemAt(this.Trim(sValue), nIndex); } } //Adds a new static argument. public function AddStaticArg(sName:String):void { var nIndex:int = -1; //Make sure the name isn't empty. if (sName == "") { return; } //Find the arguments index. nIndex = this.IndexOfArg(sName); //Check if the argument exists if (nIndex != -1) { //Already exists nothing to add. return; } //Add an element for the current name. this.saNames.addItem(sName); //Add an empty value. this.saValues.addItem(""); //Mark the item as being static this.baStaticArg.addItem(true); } //Combine the arguments back into a single string. protected function CombineArguments():String { var sCombined:String = ""; var sTempValue:String = ""; var nCount:int = 0; //Loop through all the elements of the names array. for (nCount = 0; nCount < this.saNames.length; nCount++) { //Start the name. sCombined += this.saNames.getItemAt(nCount); //Check if the current item has a varying argument value. if (this.baStaticArg.getItemAt(nCount) == false) { //Get the current value. sTempValue = String(this.saValues.getItemAt(nCount)); //Check if there are spaces in the value. if (sTempValue.indexOf(" ") == -1) { //Append the argument value. sCombined += "=" + sTempValue; } else { //Append the argument value while wrapping it in quotes. sCombined += "=\"" + sTempValue + "\""; } } //Check for the last item to avoid a trailing space on the last item. if (nCount < this.saNames.length -1) { //Add a trailing space. sCombined += " "; } } //Return the combined string. return sCombined; } //Return the argument static bool at the given index. public function GetStaticAt(nIndex:int):Boolean { //Check for out of bounds index. if (nIndex >= this.baStaticArg.length) { //Not sure what to return... but false. return false; } //Return the argument name at the given index. return this.baStaticArg.getItemAt(nIndex); } //Return the argument name at the given index. public function GetNameAt(nIndex:int):String { //Check for out of bounds index. if (nIndex >= this.saNames.length) { //Return null for a psuedo error. return null; } //Return the argument name at the given index. return String(this.saNames.getItemAt(nIndex)); } //Return the argument value at the given index. public function GetValueAt(nIndex:int):String { //Check for out of bounds index. if (nIndex >= this.saValues.length) { //Return null for a psuedo error. return null; } //Return the argument value at the given index. return String(this.saValues.getItemAt(nIndex)); } //Find the index of an argument by it's name public function IndexOfArg(sName:String):int { var nCount:int = 0; //Loop through all the elements of the names string array. for (nCount = 0; nCount < this.saNames.length; nCount++) { //Check if the item matches the if (this.saNames.getItemAt(nCount) == sName) { //Return the current index. return nCount; } } //Return negative one not found. return -1; } //Remove an argument by it's name. public function RemoveArg(sName:String):void { var nIndex:int = -1; //Find the arguments index. nIndex = this.IndexOfArg(sName); //Check if the argument was not found. if (nIndex == -1) { return; } //Remove the argument from all the arrays. this.saNames.removeItemAt(nIndex); this.saValues.removeItemAt(nIndex); this.baStaticArg.removeItemAt(nIndex); } //Update an argument associated by it's name. public function UpdateArg(sName:String, sValue:String):Boolean { var nIndex:int = -1; //Find the arguments index. nIndex = this.IndexOfArg(sName); //Check if the argument was not found. if (nIndex == -1) { //Returning false, not found, unable to update. return false; } //Check if this is a static argument. if (this.baStaticArg.getItemAt(nIndex) == true) { //Returning false, item is a static property with no value/assignment. return false; } //Update the value for the argument with the givin one and trim any outer spaces. this.saValues.setItemAt(this.Trim(sValue), nIndex); //Updated successfully. return true; } //Seperate the arugments. protected function SeperateArguments():void { var saTempArgList:Array = null; var saTempItem:Array = null; var sTemp:String = ""; var nCount:int = 0; //Perform the initial split to create an argument string array. Looks for the " +/-" and retains the characters. saTempArgList = this.sGivenSource.split(/\s(?=[\+\-])/); //Loop through all the temp argument list elements. for (nCount = 0; nCount < saTempArgList.length; nCount++) { //Split out the single argument item and value into a temp array using the "=". would store the equals too, but cannot use lookback. saTempItem = saTempArgList[nCount].split("="); //Add an element for the current name. this.saNames.addItem(String(saTempItem[0])); //Check if there is a value. if (saTempItem.length > 1) { //Convert the the value to a string for processing. sTemp = String(saTempItem[1]); //Check if the first and last character are double quotes. if (sTemp.charAt(0) == "\"" && sTemp.charAt(sTemp.length-1) == "\"") { //Grab all but a starting and ending characters, trim any outside spaces, and add a new element with it. this.saValues.addItem(this.Trim(sTemp.substr(1, sTemp.length-2))); } else { //Add an element for the current value and trim any outside spaces. this.saValues.addItem(this.Trim(sTemp)); } //Mark the item as having values. this.baStaticArg.addItem(false); } else { //Add an empty node. this.saValues.addItem(""); //Mark the item as a static argument this.baStaticArg.addItem(true); } } } //Trim the leading and trailing whitespace characters from the given string. public function Trim(sSource:String):String { //Return the modified string... stripped of leading and trailing whitespace characters. return sSource.replace(/^\s+|\s+$/g, ""); } //////////////////////////////////////// // Events // //////////////////////////////////////// } }