after stating the case, delivered the opinion of the court.
It is to be noted in the first instance that the defendant had pleaded in its answer contributory negligence on the part of the plaintiff and negligence of the fellow-servants of the plaintiff as special defenses. Whether the defense of negligence of a fellow-servant is a special defense which must be pleaded is unnecessary to be determined here. The authorities are conflicting upon the question. Put contributory negligence *40on the part of the plaintiff .in an action of the character of this one is such a special defense, and must be pleaded by the defendant. This doctrine has the support of an unbroken line of authorities in this state from Higley v. Gilmer, 3 Mont. 90, 35 Am. Rep. 450, to the recent case of Nord v. Boston & Montana C. C. & S. M. Co., 30 Mont. 48, 75 Pac. 681. (See, also, 2 Current Law, 1007; 5 Ency. of PI. & Pr. 1, and cases cited.) The pleading of this defense constituted new matter within the meaning of section 720 of the Code of Civil Procedure, as amended by an Act of the legislature approved February 22, 1899 (Sess. Laws 1899, p. 142) ; and any mere anticipatory denials in the complaint of the facts constituting this special defense were insufficient (Louisville & N. R. Co. v. Paynter’s Adm’x, 26 Ky. Law Rep. 761, 82 S. W. 412), and the failure to reply to such allegations of newmatter was an admission on the part of the plaintiff of the truth of the facts therein set forth if those facts were sufficiently pleaded.
Section 722 of the Code of Civil Procedure, as amended by. the Act of 1899, above, provides: “If the answer contains new matter and the plaintiff fails to reply or demur thereto within the time allowed by law, the defendant may move, on notice, for such judgment as he may be entitled to upon such statement, and the court may thereupon render judgment,” etc. The method of procedure provided in this section, namely, a motion for judgment on the pleadings, was followed, and then it became the plain legal duty of the court to pass upon such motion, involving as it did a consideration of the facts and the law of the case, the same having been argued and submitted, unless something intervened to relieve the court of this duty; and the only thing suggested is the application of the plaintiff to dismiss his action and the order of the court made thereon, the application having been filed and the order made after the motion for judgment on the pleadings had been argued and submitted to the court for its decision.
Section 1004 of the Code of Civil.Procedure provides, among other things: “An action may be dismissed or a judgment of nonsuit entered in the following cases: (1) By the plaintiff himself, at any time before trial,” etc.
*411. Did the plaintiff move to dismiss his action before trial ? As satisfactory a definition of the word “trial” as we are able to find is one which has been adopted, in substance at least, in the statutes of various states and by the courts of last resort of a large number of states. A trial is the examination before a competent tribunal, according to law, of the facts or law in issue in a cause, for the purpose of determining such issue. (21 Ency. of Pl. & Pr. 956; Anderson v. Pennie, 32 Cal. 266; Tregambo v. Comanche M. & M. Co., 57 Cal. 501; Crossland v. Admire, 118 Mo. 87, 24 S. W. 154; Second Nat. Bank v. First Nat. Bank, 8 N. D. 50, 76 N. W. 504; Mathews v. Clayton Co., 79 Iowa, 510, 44 N. W. 722; Railway Co. v. Thurstin, 44 Ohio St. 525, 9 N. E. 232.) Under the provisions of section 722, above, as amended, the defendant was entitled to judgment if his special defense was sufficiently pleaded; and upon his motion for judgment the only questions presented to the court for determination were the sufficiency of the pleading of this special defense, and the particular judgment to which defendant was entitled, if the plea was found to be sufficient. These questions the court must determine upon the pleadings themselves. The aid of a referee or a jury is allowed only for the purpose of determining the amount involved in the controversy. (Section 722, as.amended, above.)
While we are unable to find any case similar to the one at bar, a number of cases somewhat analogous have been called to our attention, as well as a construction of statutes either directly similar to our own or involving provisions so nearly like them as to be of some assistance in reaching our determination. Section 3 of an Act of Congress approved March 3, 1875 (18 Stat. 471, c. 137 [U. S. Comp. St. 1901, p. 510]), respecting the removal of causes from the state to federal courts, provides for such removal if the party applying shall make his application in the state court “at or before the term at which the suit could be first tried and before the trial.” In Babbitt v. Clark, 103 U. S. 606, 26 L. Ed. 507, the supreme court of the United States, in construing the above section of the Act of 1875, held that, after an issue of law had been submitted to the court, the *42case could not then be removed to tbe federal court, as tbe application for removal did not come “before the trial.”
In Alley v. Nott, 111 U. S. 472, 4 Sup. Ct. 495, 28 L. Ed. 491, tbe same court beld tbat tbe bearing of a generál demurrer to tbe complaint was a trial witbin tbe meaning of tbe removal statute, basing its decision upon tbe fact tbat tbe determination of tbe questions-presented by tbe demurrer would finally dispose of tbe case as stated in tbe complaint on its merits, unless leave of court was bad to amend or plead over. Tbe court said: “Tbe trial of such an issue is tbe trial of tbe cause as a cause, and not tbe settlement of a mere matter of form in proceeding.” Tbe doctrine of tbis case was specifically affirmed in Laidly v. Huntington, 121 U. S. 179, 7 Sup. Ct. 855, 30 L. Ed. 883.
By an Act of Congress approved March 3, 1887 (24 Stat. 552, c. 373 [U. S. Comp. St. 1901, p. 510]), tbe Act of 1875, above, was amended, particularly witb reference to tbe removal of causes based upon tbe ground of local prejudice. In tbe amended Act it is provided tbat tbe application must be made in tbe state court “at any time before tbe trial.” In Lookout Mt. R. Co. v. Houston (C. C.), 32 Fed. 711, tbis statute was construed, and it was there beld tbat tbe bearing on a demurrer which went to tbe entire complaint was a trial witbin tbe meaning of tbe Act of 1887, above.
So far as tbe particular language under consideration is concerned, section 581 of tbe California Code of Civil Procedure is identical witb our section 1004, above; and in Goldtree v. Spreckels, 135 Cal. 666, 67 Pac. 1091, a consideration of tbe phrase “at any time before trial” was bad, and, comparing it witb tbe language of tbe Act of Congress of 1875, above, tbe supreme court of California said: “Tbe language of our Code is 'at any time before trial.’ There is no perceivable difference between tbe two Acts. We cannot see why it is not true, as was said in Tregambo v. Mining Co., supra [57 Cal. 501], tbat, 'when a court bears and determines any issue of * * * law for tbe purpose of determining tbe rights of tbe parties, it may be considered a trial.’ ” After referring to like decisions made by tbe supreme court of Ohio (Beaumont v. Herrick, 24 *43Ohio St. 446) and Nebraska (State v. Scott, 22 Neb. 628, 36 N. W. 121), the court further says: “In none of the California cases coming under our observation has the precise question been decided, which is sufficient apology for having gone into the matter at some length. In our opinion, the subdivision of the section 581 in question cannot be restricted in its meaning to trials of the merits after answer, for there may be such a trial on a general demurrer to the complaint as will effectually dispose of the case where the plaintiff has properly alleged all the facts which constitute his cause of action. If the demurrer is sustained, he stands on his pleading, and submits to judgment on the demurrer, and, if not satisfied, has his remedy by appeal. In such a case, we think there would be a trial within the meaning of the Code, and the judgment would cut off the right of dismissal unless it was first set aside, or leave given to amend.”
While each of the foregoing decisions is made with reference to a general demurrer which went to the entire cause of action pleaded in the complaint, it appears to us that for the stronger reason the doctrine announced is applicable to the case under consideration; for, as we have said above, the only questions presented by the motion for judgment on the pleadings were, first, the sufficiency of the pleading of the special defense, and, second, the particular judgment to which the defendant was entitled if the defense was found to be sufficiently pleaded. These were purely questions of law, and the motion went to the entire case made by the pleadings, and its determination decided the entire case made to a much greater extent than the decision on a general demurrer; for, if the court found that the special defense was sufficiently pleaded, then in this particular instance it is quite impossible to conceive of any amendment which could be made which would relieve the plaintiff from the consequences of his failure to reply. The sufficiency of the pleading being admitted, the court could do but one thing, namely, determine the particular judgment to which the defendant was entitled.
We hold, then, that the submission of the motion for judgment on the pleadings in this case was a trial of the case within the meaning of section 1004, above, and the application made *44to dismiss after the submission of the motion for judgment on the pleadings came too late. The attempt of the court to dismiss the case upon such application or praecipe was futile, and the order of dismissal a nullity. The cause is still pending, and the plain legal duty of the court is to reinstate it upon the calendar and determine the motion.
2. Is mandamus the proper remedy? Counsel for plaintiff contend that the order dismissing the action was a final judgment from which an appeal lies, and therefore mandamus is not an available remedy. The order of the court was not a judgment. In the first place, the order was not warranted by the statute under which the court presumed to act. Secticm 1004, above, provides: “The dismissal' mentioned in the first two subdivisions is made by entry in the clerk’s register.” This order was made in the minutes of the court. The clerk is the custodian of his register, and the only entries to be made therein are entries by the clerk, and not by anyone else. Besides, the order does not bear the characteristics of a judgment. It is nothing more than an order of the court upon which a judgment of dismissal and for costs could have been entered. (Miller v. Northern Pacific Ry. Co., 30 Mont. 289, 76 Pac. 691.) The text-books and encyclopedias which announce the doctrine that the dismissal of an action is a final judgment from which an appeal will lie almost without exception cite authorities from states having special statutes, permitting an appeal from an order of the character of the one made in this instance, or from courts holding that a judgment of dismissal is a final judgment within the meaning of the statutes providing for appeals from final judgments, and with them we agree. One or two isolated cases may be found holding that an order substantially in the form of the one made here is of itself a judgment, but with them we do not agree. Our Code (section 1007, Code of Civil Procedure) emphasizes the fact that the final disposition of an action on a dismissal thereof is accomplished by a judgment.
In Miller v. Railway Co., above, this court held that the dismissal warranted by section 1004, made by the clerk, only ter*45minates the action so far as to prevent further proceedings except the rendition and entry of a judgment. There cannot be two judgments, each finally disposing of the action, and, if the judgment of dismissal and for costs to which defendant is entitled is such final judgment, then it is self-evident that the order of dismissal is not such.
There is nothing in Dahler v. Steele, 1 Mont. 206, or in Holter Lumber Co. v. Insurance Co., 18 Mont. 282, 45 Pac. 207, in conflict with the views herein expressed.
But if it be said that the defendant railway company might have had a judgment entered upon the order, and from such judgment might have appealed to this court, it is sufficient to say that such a remedy would be inadequate. The provisions of our Code with reference to mandamus, pertinent here, are found in.sections 1961 and 1962 of the Code oí Civil Procedure. Under section 1961 it is declared that the purpose of the writ is “to compel the performance of an act which the law specially enjoins as a duty resulting from an office.” Section 1962 is as follows: “The writ must be issued in all cases where there is not a plain, speedy, and adequate remedy in the ordinary course of law.” It will be observed that there is nothing in these provisions which prevents the issuance of the writ even in those cases where an appeal lies. The distinction between section 1962 and the provisions relative to certiorari (section 1941 of the same Code) 'is to be. noted.
If the remedy by appeal, or any other method other than mandamus, is not plain, speedy, and adequate, mandamus will lie, if the case is otherwise a proper one. The only question presented to this court by such an appeal — if, indeed, the defendant, railway company could have appealed — would be the action of the court in dismissing the action. It would not present for the determination of this court the question as to whether or not the district court should pass upon the motion for judgment on the pleadings, and certainly on an appeal from a final judgment this court could not coerce the district court into passing upon that motion, which is practically the only purpose to be sought by this proceeding.
*46Of course, we agree with counsel that, where a court has acted in a given particular, mandamus will not lie to correct the error, if error was made. But in this instance the court has not acted, but has particularly refused to act — that is, it has refused, to pass upon the motion for judgment on the pleadings, duly argued and submitted, and properly before it. We are of the-opinion that the determination of such motion is an act which the law specifically enjoins as a duty resulting from the office, and that the record in this instance-presents a case where the-remedy by appeal, if available, would be entirely inadequate,, and that mandamus will lie.
Let the writ issue as prayed for.
Writ issued.
Me. Chief Justice Beantly and Me. Justice Milbuen concur.