Post by curly on Dec 6, 2021 7:15:16 GMT -5
Hi Walt,
Thank you so much for you guidance it is most appreciated. I have copied your suggestion "How do I..." and will use it in future, thank you.
I am trying to understand how functions and sub are better than gosub and return as I currently have lots of gosub/returns which were flavour of the month in 1980s.
As part of my process, the electrician must complete an Inspection Schedule of 100 items, each one recording the worst case found using outcome codes N/A(non applicable), OK(satisfactory), LIM(an operational limitation preventing the inspection), N/V(not verified for a non-specific reason), C3, C2, C1(serousness of defect) and FI(further investigation needed). These are in seriousness order from lowest to highest. As part of my application, I must ensure as each validation process takes place, the most serious outcome code is recorded for each inspection schedule. (There can be multiple inspections that relate to a single Inspection Shedule). I have selected one with a quite simple subroutine. I have a small array, Outcome$(8) that holds the list of outcome codes in order, 0="", 1=N/A, 2=OK, 3=LIM, 4=N/V, 5=C3, 6=C2, 7=C1, 8=FI. I currently do this with a gosub and return as follows.
When the validation of one or more pieces of data is checked, I define variables as follows,before calling my subroutine. Is there an advantage of using Call and end sub that I can't see? I must have around a hundred or more subroutines for repetitive tasks.
x - system$(x) is where the existing most serious outcode for the current inspection is stored
outcome$ - this is the outcome string for the latest validation
gosub [SelectMostSeriousOutcome]
' I have included wait to indicate it doesn't run on into a subroutine.
wait
[SelectMostSeriousOutcome]
i = 0
while system$(x) <> Outcome$(i) 'find where in the hierarchy the new outcome code fits
i=i+1
wend
j=0
while outcome$ <> Outcome$(j) 'find where in the hierarchy the existing outcome code sits
j=j+1
wend
if i > j then 'if new outcome code is higher in list than old outcome code
system$(x) = outcome$ 'Inspection schedule updated with new outcome code if appropriate
end if
return
Thank you so much for you guidance it is most appreciated. I have copied your suggestion "How do I..." and will use it in future, thank you.
I am trying to understand how functions and sub are better than gosub and return as I currently have lots of gosub/returns which were flavour of the month in 1980s.
As part of my process, the electrician must complete an Inspection Schedule of 100 items, each one recording the worst case found using outcome codes N/A(non applicable), OK(satisfactory), LIM(an operational limitation preventing the inspection), N/V(not verified for a non-specific reason), C3, C2, C1(serousness of defect) and FI(further investigation needed). These are in seriousness order from lowest to highest. As part of my application, I must ensure as each validation process takes place, the most serious outcome code is recorded for each inspection schedule. (There can be multiple inspections that relate to a single Inspection Shedule). I have selected one with a quite simple subroutine. I have a small array, Outcome$(8) that holds the list of outcome codes in order, 0="", 1=N/A, 2=OK, 3=LIM, 4=N/V, 5=C3, 6=C2, 7=C1, 8=FI. I currently do this with a gosub and return as follows.
When the validation of one or more pieces of data is checked, I define variables as follows,before calling my subroutine. Is there an advantage of using Call and end sub that I can't see? I must have around a hundred or more subroutines for repetitive tasks.
x - system$(x) is where the existing most serious outcode for the current inspection is stored
outcome$ - this is the outcome string for the latest validation
gosub [SelectMostSeriousOutcome]
' I have included wait to indicate it doesn't run on into a subroutine.
wait
[SelectMostSeriousOutcome]
i = 0
while system$(x) <> Outcome$(i) 'find where in the hierarchy the new outcome code fits
i=i+1
wend
j=0
while outcome$ <> Outcome$(j) 'find where in the hierarchy the existing outcome code sits
j=j+1
wend
if i > j then 'if new outcome code is higher in list than old outcome code
system$(x) = outcome$ 'Inspection schedule updated with new outcome code if appropriate
end if
return