Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Structured Programming
It has been kindly pointed out to me that Liberty Basic does have an alternative to the PROCedures used in BBC BASIC (for Windows) needed for true Structured Programming as below. I wonder how the experts on programming view the LB way

Gordon

'copy two files into one
fileOne$ = "first.txt"
fileTwo$ = "second.txt"
combined$ = "together.txt"
call mergeFiles fileOne$, fileTwo$, combined$

end

sub mergeFiles firstFile$, secondFile$, merged$
open merged$ for output as #merged
open firstFile$ for input as #first
print #merged, input$(#first, lof(#first));
close #first
open secondFile$ for input as #second
print #merged, input$(#second, lof(#second));
close #second
close #merged
end sub
Reply
Quote:It has been kindly pointed out to me that Liberty Basic does have an alternative to the PROCedures used in BBC BASIC (for Windows) needed for true Structured Programming as below. I wonder how the experts on programming view the LB way

Gordon

'copy two files into one
fileOne$ = "first.txt"
fileTwo$ = "second.txt"
combined$ = "together.txt"
call mergeFiles fileOne$, fileTwo$, combined$

end

sub mergeFiles firstFile$, secondFile$, merged$
open merged$ for output as #merged
open firstFile$ for input as #first
print #merged, input$(#first, lof(#first));
close #first
open secondFile$ for input as #second
print #merged, input$(#second, lof(#second));
close #second
close #merged
end sub
Looks fairly straightforward.

However, you should be careful with your usage of the terms COPY and MERGE.

COPY can be a simple file copy or it can be a concatenation of one or more files, which is what you are doing above.

On the other hand, a MERGE implies merging individual records of each file by some key, which is not what you are doing in your sub mergeFiles.

A word of warning: Copying or concatenating files can be dangerous when you do this from within a program which may interpret end-of-record characters, end-of-file characters, and some special characters differently than MSDOS. The recommended way is to SHELL to the required copy command. Believe me, I found this out the hard way.
*****
Reply
Structured programming is just common sense. But unfortuneatly not many qbers seems to have that common sense from the code i've seen. And to who ever said assembly is just random code or whatever. You are missinformed. It's no more or less random or structured then say qb for instance. There's more structure in this peice of assembly code then i've seen in most programs written in qb.
http://ratatoskr.dragonhill.cc/forum/vie...4&start=11
oship me and i will give you lots of guurrls and beeea
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)