Qbasicnews.com
December 16, 2019, 10:29:29 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 ... 9 10 [11]
  Print  
Author Topic: Structured Programming  (Read 31797 times)
GordonSweet
Guru
**
Posts: 287



WWW
« Reply #150 on: December 28, 2005, 05:40:18 AM »

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
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #151 on: December 31, 2005, 04:46:10 PM »

Quote from: "GordonSweet"
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.
*****
Logged
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #152 on: January 20, 2006, 03:25:56 AM »

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/viewtopic.php?t=34&start=11
Logged

oship me and i will give you lots of guurrls and beeea
Pages: 1 ... 9 10 [11]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!