While trying to solve a certain exercise in Hartshorne I realized that I need to use the following result:
Let $X,Y$ be two ringed topological spaces. Suppose we have a covering $\{U_i\}$ of $X$ and morphisms $f_i :U_i \to Y$ such that $f_i|_{U_i \cap U_j} = f_j|_{U_i \cap U_j}$ for every $i,j$. The bar just denotes ordinary restriction of morphisms to a subspace. Then there is a morphism $f : X \to Y$ such that $f|_{U_i} = f_i$.
Now the obvious choice for a morphism $f(x) = f_i(x)$ if $x \in U_i$ should work. Indeed for every $i$ we have maps $f_i^\sharp : \mathcal{O}_Y \to {f_i}_\ast(\mathcal{O}_X|_{U_i})$ and using this I want to build a morphism $f^\sharp : \mathcal{O}_Y \to f_\ast \mathcal{O}_X$. It suffices to define $f^\sharp$ open set by open set so choose $V \subseteq Y$ open. Choose $s \in \mathcal{O}_Y(V)$ and define $$s_i := f^\sharp_i(s) \in {f_i}_\ast (\mathcal{O}_X|_{U_i})(V).$$
My question is: Why should it be the case that $s_i|_{f_i^{-1}(V) \cap f_j^{-1}(V)} = s_j|_{f_i^{-1}(V) \cap f_j^{-1}(V)}$? I ask this because the $\{f_i^{-1}(V)\}$ cover $f^{-1}(V)$ and then I can invoke the gluing property of a sheaf to give me a section of $f_\ast \mathcal{O}_X(V)$. I am tempted to say from the diagram
<p>$\hspace{1in}$<img src="https://i.stack.imgur.com/hU6EU.png" alt="enter image description here"></p> <p>that I can apply the functor $\mathcal{O}_Y(-)$ to the bottom right corner and $\mathcal{O}_X(-)$ to the other three corners and still obtain a commutative square, but is this legal?</p>