Bartle's book, Modern theory of integration, focuses on Henstock-Kurzweil integrals, where $\mathcal{R}^*(I)$ denotes the set of Henstock-Kurzweil integrable functions on $I = [a, b]$.
Also, $\mathcal{M}(I)$ denotes the Lebesgue measurable functions on $I$, defined as almost sure limits of step functions.
A step function $s:I\to \mathbb{R}$ is a function for which there exists $x_0 = a < x_1 < ... < x_n = b$ such that $s$ is constant on $(x_i, x_{i+1})$ for $i = 0, ..., n-1$. But $s(x_i)$ can be defined however we like.
$\text{mid}(a, b, c)$ for $a, b, c\in\mathbb{R}$ denotes middle value of $a, b, c$, that is if for example $a \leq b \leq c$, then $\text{mid}(a, b, c) = b$.
Similarly, if $f, g, h$ are functions, then $\text{mid}(f, g, h)(x) := \text{mid}(f(x), g(x), h(x))$.
Theorem $9.1.$ If $\alpha \leq f \leq \omega$ and $\alpha, \omega\in\mathcal{R}^*(I)$, $f\in \mathcal{M}(I)$, then $f\in\mathcal{R}^*(I)$.
Proof: Let $s_k\to f$ almost surely and $g_k = \text{mid}(\alpha, s_k, \omega)$. Then $g_k\in\mathcal{R}^*(I)$, $\alpha\leq g_k\leq \omega$ and $g_k\to f$ almost surely, so from dominated convergence theorem $f\in\mathcal{R}^*(I)$. $\square$
My doubts about above proof: How do we know that $g_k\in \mathcal{R}^*(I)$?
In exercise $8.R$ I had the same issue, and Bartle suggested to use this theorem:
Theorem $7.13.$ Suppose $f, g, \alpha, \omega\in\mathcal{R}^*(I)$.
If $f, g\leq \omega$ then $f\land g, f\lor g\in\mathcal{R}^*(I)$.
If $\alpha\leq f, g$ then $f\land g, f\lor g\in\mathcal{R}^*(I)$.
However, I don't see how to apply the above theorem to show that if $\alpha\leq \omega$ and $\alpha, g, \omega\in\mathcal{R}^*(I)$, then $\text{mid}(\alpha, g, \omega)\in\mathcal{R}^*(I)$.
If $\alpha\leq f \leq \omega$, set $f_1 := f-\alpha$ and $\omega_1 = \omega-\alpha$ so that $0 \leq f_1 \leq \omega_1$ where $\omega_1 \in \mathcal R^*(I)$. Since $f=f_1+\alpha$ it suffices to show that $f_1 \in \mathcal R^*(I)$. Take a sequence $(s_n)$ of step functions with $s_n(x) \to f_1(x)$ for a.e. $x \in I$. Now $0\leq s_n^+(x)$ and $0\leq f_1(x)$ for a.e. $x \in I$ hence, replacing $s_n$ by $s_n^+$ we may assume $s_n\geq 0$ for all $n \in \mathbb N$.
Now it follows that $\omega_1$ and $s_n$ are bounded above by $\omega_1+s_n \in \mathcal R^*(I)$, and so by 7.13, $r_n = \min\{\omega_1,s_n\} \in \mathcal R^*(I)$, and clearly $r_n(x) \to f_1(x)$ as $n\to \infty$ for a.e. $x\in I$. Now since $\omega_1\in \mathcal R^*(I)$, dominated convergence shows that $\lim_{n\to \infty} r_n =f_1 \in \mathcal R^*(I)$.