Whenever the presiding judge of any court has reason to believe that the evidence of an inmate is necessary in any criminal proceedings and that other evidence cannot be obtained on behalf of the state or of the defendant, the presiding judge shall order a writ to be issued directing the warden of the penitentiary to bring the body of the inmate before the court, on a day to be named in the writ, to give testimony for the state or for the defendant in such case.