//Track Changes /* A program which counts the number of objects modified between two dates or modified by a specific CR or CRG **NOTE** This program is written to be printed in LANDSCAPE Written By: Josiah Nusbaum Last Modified On: 8/8/2012 */ DB pickDate //Creates the "pickDate" dialog box DBE chooseRadio //Creates a box of radio buttons called "chooseRadio" DBE pick //Creates the "pick" dialog box string mix //Creates a string called "mix" string formats //Creates a string called "formats" int i //Creates an integer called "i" bool checkIt //Creates a boolean called "checkIt" Date startDate //Creates a date called "startDate" Date endDate //Creates a date called "endDate" Object currentObject //Creates an object called "currentObject" Object objectA //Creates an object called "objectA" DBE picker //Creates a dialog box element called "picker" DBE dates //Creates a dialog box element called "dates" DB db = create ("CR/CRG or Date?") //Creates a dialog box called "db"\ Module currentModule = current //Creates a module placeholder "currentModule" and initializes it to be the current module string forms[] = { "CR/CRG", "Dates"} //Creates a string array called "forms" int counter = 0 //Creates an int called "counter" and initializes it to equal 0 string s1 string s2 string file int p int iRow int iCol string test OleAutoObj objExcelSheet OleAutoObj wbs OleAutoObj wb OleAutoObj ws OleAutoObj objCell OleAutoArgs args = create int findEmptyRow (OleAutoObj objExcelSheet) { OleAutoObj objUsedRange, objRows int iRows = 0 1oleGet(objExcelSheet,"UsedRange",objUsedRange) oleGet(objExcelSheet,"Rows",objRows) oleGet(objExcelSheet,"Count",iRows) print iRows return iRows+1 } OleAutoObj excelGetWorksheet(OleAutoObj oleExcel, int iSheetNumber) { objExcelSheet = null string sSheetNumber = "Sheet" iSheetNumber "" OleAutoArgs autoArgs = create put(autoArgs, sSheetNumber) oleGet(oleExcel,"WorkSheets",autoArgs,objExcelSheet) delete autoArgs return objExcelSheet } void openExcel() { string filename = file OleAutoObj ex = oleGetAutoObject("Excel.Application") if(null ex) { ex = oleCreateAutoObject "Excel.Application" olePut(ex,"Visible",true) oleGet(ex,"Workbooks", wbs) put (args,filename"") oleMethod(wbs,"Open",args,wb)} oleGet (ex, "ActiveSheet", ws) objExcelSheet = excelGetWorksheet(ex,1) } void pasteString (int y, int x, string s) { clear args put (args, y) put (args, x) oleGet (ws, "Cells", args, objCell) // select cell clear args put (args, objCell) copyToClipboard s print oleMethod (ws, "Paste",args) } void deleteFilter(DB display) //Creates a method called "deleteFilter" { current = currentModule filtering off //turns the filtering off hide display //hides the "display" dialog box } void displayResults(int counter) //Creates the "displayResults" dialog box { openExcel() test = counter "" p = findEmptyRow(objExcelSheet) print p if(i == 0) { pasteString(p,1,mix) pasteString(p,3,test) } else { s1 = stringOf(startDate, "dd MMMM, yyyy") //creates a string s1 which is equal to the startDate s2 = stringOf(endDate, "dd MMMM, yyyy") pasteString(p,1,s1) pasteString(p,2,s2) pasteString(p,3,test) } DB display = create "Number of changes" //Creates a dialog box called "display" if(i == 0) //If i equals 0, the following label is shown { if(counter == 1) { label(display, "There was " counter " change in " mix ".") } else { label(display, "There are " counter " changes in " mix ".") //Creates a label that discusses the number of changes within a CR or CRG } } else //If i does not equal 0, the follwing label is shown { if(counter == 1) { label(display, "There was " counter " change between " stringOf(startDate, "MMMM d, yyyy") " and " stringOf(endDate, "MMMM d, yyyy") ".") } else { label(display, "There were " counter " changes between " stringOf(startDate, "MMMM d, yyyy") " and " stringOf(endDate, "MMMM d, yyyy") ".") //Creates a label that discusses the number of changes between two dates } } DBE buttonA = ok(display, "Ok", deleteFilter) //Creates a button called buttonA which runs the deleteFilter method when it is clicked show display //shows the dialog box "display" } void counter(Module currentModule) //Creates the "counter" method { objectA = current //Sets objectA to be the current object for objectA in currentModule do //loops through all objects in the module { counter++ //increment "counter" by 1 } displayResults(counter) //runs the "displayResults" method on counter } void selector(int i, string formats) //Creates the "selector" method { if(i == 0) //if i equals zero, run the following lines { void filterer(Module currentModule, string mix) //creates the method "filterer" { Filter f4 = contains(attribute "CR", mix, false) //Creates the filter f4, which filters through the CR attribute set f4 //sets the filter f4 to the current module filtering on //Turns filtering on counter(currentModule) //Runs the "counter" method on currentModule } DB chooseCR = create "Choose your CR" //creates the dialog box "chooseCR" string types[] = { "CR", "CRG"} //Creates the array of strings called "types" chooseRadio = radioBox(chooseCR, "What kind of CR is it?", types, 2) //makes chooseRadio into a radio box which allows the user to choose if they want to look at a CR or a CRG pick = field(chooseCR, "Enter number here:", null, 40) //Creates a text field into which the user can enter the CR/CRG number void getType(DB chooseCR) //Creates a method called "getType" { string types[2] = { "CR", "CRG"} //Creates a string array called "types" hide chooseCR //hides the chooseCR dialog box int i = get chooseRadio //sets the integer i to the number of the box which was chosen in the chooseRadio dialog box string forms = types[i] //creates the string "forms" and sets it to the label of the button which was chosen in the chooseRadio box string jo = get pick //sets the string "jo" to the number entered in the "pick" text field int j = intOf(jo) //sets the integer "j" to the integer representation of "jo" mix = forms jo //sets "mix" to be the combination of "forms" and "jo" bool check = confirm(chooseCR, "You want to look inside " mix ". Is this correct?", msgQuery) //Creates a boolean dialog box called "check" which checks to ensure that the user entered the correct number if(check) //if check is "true", the next lines are operated on { hide chooseCR //hides the "chooseCR" dialog box filterer(currentModule, mix) //runs the "filterer" method on currentModule and mix } else //if check is "false" { show chooseCR //shows the "chooseCR" dialog box } } apply(chooseCR, "Ok", getType) //Creates an "Ok" button in the chooseCR dialog box show chooseCR //shows the "chooseCR" dialog box } else //if i does not equal 0 { void filter(Date startDate, Date endDate) //Creates the "filter" method { current = currentModule s1 = stringOf(startDate, "dd MMMM, yyyy") //creates a string s1 which is equal to the startDate s2 = stringOf(endDate, "dd MMMM, yyyy") filtering on //turns filtering on Filter f1 = attribute "Last Modified On" >= s1 //Creates the filter f1, which filters for all objects which were last modified after the start date Filter f2 = attribute "Last Modified On" <= s2 //Creates the filter f2, which filters for all objects which were last modified before the end date Filter f3 = f1 && f2 //Creates the filter f3, which combines f1 and f2 set(currentModule, f3) //sets the filter f3 to currentMdule applyFiltering(currentModule) //applies filtering to currentModule counter(currentModule) //performs the "counter" method on currentModule } pickDate = create "Date Chooser" //creates the dialog box "pickDate" Date init = dateOnly(today) //sets the date "init" to equal the current date label(pickDate,"Start Date:") //creates the label "Start Date:" for the start date selector beside pickDate picker = date(pickDate, 30, init, true) //Creates the date chooser called "picker" label(pickDate,"End Date:") //Creates the label beside the "End Date" chooser beside pickDate dates = date(pickDate, 30, init, true) //Creates the date chooser called "dates" checkIt = false //Makes checkIt false string typeStr = "a" //Makes a string "typeStr" and initializes it to "a" string forms[] //Creates a string array called "forms" void check(Date startDate, Date endDate) //Creates the "check" method { if(startDate > endDate) //If the startDate happened after the endDate, the next lines are run { errorBox "End date must have occurred after start date!" //Error box which says that the End date must have occurred after the start date appears show pickDate //shows the pickDate dialog box } else //If the startDate happend before or on the endDate { checkIt = true //Make checkIt equal to true hide pickDate //Hides the pickDate dialog box } } void confirm(DB dbs) //Creates the "confirm" method { hide dbs //Hides the dbs dialog box hide db //Hides the db dialog box check(startDate , endDate) //runs the "check" method on startDate and endDate if(checkIt == true) //If checkIt is true, run the following lines { currentObject = current //Make currentObject equal the current object filter(startDate, endDate) //Run the filter method on startDate and endDate } } void wrong(DB dbs) //Creates the "wrong" method { hide dbs //Hides the dbs dialog box } void unzip(DB pickDate) //Creates the "unzip" method { startDate = getDate(picker) //gets the date from picker and puts it in startDate endDate = getDate(dates) //gets the date from dates and puts it in endDate DB dbs = create "Confirm?" //creates the dialog box dbs label(dbs, "The start date is " stringOf(startDate, "MMMM d, yyyy") ", and the end date is " stringOf(endDate, "MMMM d, yyyy") ". Is this correct?") //creates a label for the dialog box dbs DBE buttonA = ok(dbs, "Yes", confirm) //creates a button "buttonA" which runs the "confirm" method when it is clicked DBE buttonB = ok(dbs, "No", wrong) //creates a button "buttonB" which runs the "wrong" method when it is clicked show dbs //Shows the dialog box dbs } apply(pickDate, "Ok", unzip) //creates an "Ok" button in the PickDate dialog box which runs "unzip" when it is clicked show pickDate //shows the pickDate dialog box } } DBE kindRadio = verticalRadioBox(db, "Would you like to count the number of changes within a CR/CRG or between two dates?", forms, 0) //Creates a vertical radio box for the dialog box "db" void findKind(DB db) //Creates the "findKind" method { string forms[] = { "CR/CRG", "Dates"} //Creates an array of strings called "forms" hide db //hides the dialog box db i = get kindRadio //finds which radio button was selected formats = forms[i] //finds the label of the radio button that was selected and put it into "formats" selector(i, formats) //runs the "selector" method on i and formats } apply(db, "Select", findKind) //Creates a "Select" button for db which runs the "findKind" method when it is clicked void fileSelect { DB dbSelect = create "Select File" DBE dbeBrowse = fileName(dbSelect, "") void selectFile(DB dbSelect) { file = get dbeBrowse show db } DBE applyButton = ok(dbSelect, "Load", selectFile) show dbSelect }d", selec