You were reported to the kirk session who investigated. If guilty of antenuptual fornication (because your first child was very, very, very 'premature') you would have to appear in the place of repentance during the weekly church service, sometimes in sackcloth - a loose smock of sacking. The number of weeks you had to appear depended on the seriousness of the offence. You were also fined and the money went to the fund for assisting the poor. Offences such as Sabbath breaking and the like were punished in the same way. If things got very bad, for example if someone had produced a third illegitimate child or committed adultery, they would be referred to the Presbytery.
Graham.