You can use a UK prescription to get medicines, including special food required for medical reasons, in Spain. Prescription medicines are not free in Spain. With an EHIC or GHIC you get a reduced rate, but you'll still pay: 50% of the prescription price.