char *prepareSourceCodeDefinition(const char *acFile, const char *acText, bool bForm) { XString sText; sText = acText; sText = sText.replace("\r", ""); int n = 0; XString sSQLName = ""; XString sSQLControls = ""; XString sAdditonalCode = ""; XString sAdditional = ""; int nBorderLeft = 0; int nBorderRight = 0; int nBorderTop = 0; int nBorderBottom = 0; int nHeight = 0; n = sText.find("Height = "); if (n >= 0){ n += 9; int n2 = sText.find("\n", n); nHeight = atoi(sText.mid(n, n2 - n).ascii()); } n = sText.find("BorderLeft = "); if (n >= 0){ n += 13; int n2 = sText.find("\n", n); nBorderLeft = atoi(sText.mid(n, n2 - n).ascii()); } n = sText.find("BorderRight = "); if (n >= 0){ n += 14; int n2 = sText.find("\n", n); nBorderRight = atoi(sText.mid(n, n2 - n).ascii()); } n = sText.find("BorderTop = "); if (n >= 0){ n += 12; int n2 = sText.find("\n", n); nBorderTop = atoi(sText.mid(n, n2 - n).ascii()); } n = sText.find("BorderBottom = "); if (n >= 0){ n += 15; int n2 = sText.find("\n", n); nBorderBottom = atoi(sText.mid(n, n2 - n).ascii()); } n = sText.find("SQLControls = \""); if (n >= 0){ n += 15; int n2 = sText.find("\"", n); sSQLControls = sText.mid(n, n2 - n); } n = sText.find("SQLName = \""); if (n >= 0){ n += 11; int n2 = sText.find("\"", n); sSQLName = sText.mid(n, n2 - n); } n = 0; n++; static XString sDefinition; sDefinition = ""; XString sConstructor = ""; sDefinition += "\n"; do { n = sText.find("Begin ", n); if (n == -1) break; int n2 = sText.find("\n", n); n += 6; XString sLine = sText.mid(n, n2 - n); int n3 = sLine.find(" "); XString sType = sLine.mid(0, n3); XString sName = sLine.mid(n3 + 1); sName = sName.stripWhiteSpace(); sDefinition += "Public "; sDefinition += sName; sDefinition += " As "; sDefinition += sType; sDefinition += "\n"; sConstructor += sName; sConstructor += " = Control(\""; sConstructor += sName; sConstructor += "\")\n"; n = sText.find("End\n", n); // proceed to the end of that control defintion } while (true); int X = 0; int nFocusOrder = 1000; if (!sSQLName.isEmpty() && bForm) { if (sSQLControls.isEmpty()){ createSQLControl("Recordset", 90, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); createSQLControl("First", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); createSQLControl("Previous", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); createSQLControl("GoTo", 60, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); createSQLControl("Next", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); createSQLControl("Last", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); createSQLControl("AddNew", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); X += 5; createSQLControl("Info", 110, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); X += 20; createSQLControl("Update", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); X += 20; createSQLControl("Delete", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } else { if (sSQLControls.contains("Recordset")){ createSQLControl("Recordset", 90, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } if (sSQLControls.contains("First")){ createSQLControl("First", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } if (sSQLControls.contains("Previous")){ createSQLControl("Previous", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } if (sSQLControls.contains("GoTo")){ createSQLControl("GoTo", 50, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } if (sSQLControls.contains("Next")){ createSQLControl("Next", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } if (sSQLControls.contains("Last")){ createSQLControl("Last", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } if (sSQLControls.contains("AddNew")){ createSQLControl("AddNew", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } X += 5; if (sSQLControls.contains("Info")){ createSQLControl("Info", 90, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } X += 20; if (sSQLControls.contains("Update")){ createSQLControl("Update", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } X += 20; if (sSQLControls.contains("Delete")){ createSQLControl("Delete", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight, nFocusOrder++, &sSQLControls); } /* X += 20; if (sSQLControls.contains("Requery")){ createSQLControl("Requery", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("Seek")){ createSQLControl("Seek", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("ClearFilter")){ createSQLControl("ClearFilter", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("AddFilter")){ createSQLControl("AddFilter", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("AddNotFilter")){ createSQLControl("AddNotFilter", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("SetFilter")){ createSQLControl("SetFilter", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("SetNotFilter")){ createSQLControl("SetNotFilter", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("SortAscending")){ createSQLControl("SortAscending", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } if (sSQLControls.contains("SortDescending")){ createSQLControl("SortDescending", 20, &sDefinition, &sAdditonalCode, &sAdditional, &X, nBorderLeft, nBorderBottom, nHeight); } */ } } sDefinition += "\n\nConstructor "; sDefinition += getFilenameWithoutPathAndExtension(acFile); sDefinition += "()\n"; sDefinition += "\nLoad(\""; sDefinition += getFilenameWithoutPathAndExtension(acFile); sDefinition += "\")\n\n"; sDefinition += sConstructor; sDefinition += "\nFinish()\n\n"; sDefinition += sAdditonalCode; sDefinition += "\nEnd Constructor\n"; sDefinition += sAdditional; if (!sSQLName.isEmpty() && bForm) { sDefinition += "Sub Form_OnGoTo2()\n"; if (sSQLControls.isEmpty() || sSQLControls.contains("GoTo")) sDefinition += " SQLGoTo.Value = \"\" & Me.Position()\n"; if (sSQLControls.isEmpty() || sSQLControls.contains("Info")){ sDefinition += " If IsFilterActive() Then\nSQLInfo.Caption = \"of \" & Me.Length() & \" record(s) (Filter)\"\nElse\nSQLInfo.Caption = \"of \" & Me.Length() & \" record(s)\"\nEnd If\n"; } sDefinition += "End Sub\n"; } return (char *) sDefinition.ascii(); }