Liberty BASIC Community Forum
« This sequential database is running ! update »

Welcome Guest. Please Login or Register.
Nov 24th, 2017, 10:51am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: This sequential database is running ! update  (Read 422 times)
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx This sequential database is running ! update
« Thread started on: Aug 13th, 2016, 5:45pm »

Hi there ,

i got it.

No chance without the debugger in animate mode.

This is a sequential database with a one dimensional
array dimensioned for 1000 slots.

The code is right now ready.
I had no time for style outfit and line number improvement.

The sorting algo is not implemented yet. no time.
You see the place in the code. a memo
I will work on the algo for next step and make a post.


1. the file is loaded in memory with input #1
a index is created that is counting the slots "index"

2. a new input is made in the array with a new variable
called outex1 = index + 1 slot more

3. You can close the application and the array is written
to the file "datenbank.txt" in output mode.

4. A search option is running correct if you want to find
a record.
There is a gosub prepared for a label [editdata]
which is not ready and can be programmed
for all that are interested in.
If you have find the data , it is recommended to
make the user a chosen option to edit the data.


Everybody who likes this code can have an experience
to complete that.
Its the base ground for a normal array database with
searching/editing/input etc.
GUI is a optional plus for that code.


Here is the raw code :

____________________________________________

Rem Sequentielle Datenbank = .txt Datei mit Suchfunktion und Sortierung


10 CLS

14 dim daten$(1000)

15 index = 0
16 open "datenbank.txt" FOR Input AS #1
17 WHILE EOF(#1)= 0
19 index = index + 1
20 LINE INPUT #1,daten$(index)
21 Print daten$(index)
22 WEND
23 close #1

24 outex1 = index



25 Print "Wollen Sie neue Daten eingeben oder wollen Sie suchen ? ( D / S / N)"
26 Print

40 Input Y$

50 If Y$ = "D" or Y$ = "d" then goto 220
60 If Y$ = "S" or Y$ = "s" then goto [searchfor]
65 If Y$ = "N" or Y$ = "n" then goto 510
70 If Y$ <> "D" and Y$ <> "d" and Y$ <> "S" and Y$ <> "s" then goto 25



220 Print " Jetzt koennen Sie neue Daten eingeben"
outex1 = outex1 + 1
Print
input " Neuer Datensatz : " ; daten$(outex1)
Print
Print " Der neue Datensatz : " ; daten$(outex1) ; " : wurde abgespeichert" : print : print
Print "Wollen Sie neue Daten eingeben ( J / N ) , zurueck zum Hauptmenue mit ENTER"
Print
Input Z$
If Z$ = "J" or Z$ = "j" then goto 220
If Z$ = "N" or Z$ = "n" then goto 510
If Z$ <> "J" and Z$ <> "N" and Z$ <> "j" and Z$ <> "n" then goto 25
Print



510 Print " Vielen Dank fuer die Eingaben , Auf Wiedersehn" : print



'' here comes the sorting algorhytm in YEAH




910 open "datenbank.txt" for output as #1
920 for printex1 = 1 to outex1
930 print #1, daten$(printex1)
940 next
950 close #1

959 print : print

960 for s = 1 to outex1
print daten$(s)
next s




1000 end





[searchfor]

input "Type some text to search for? "; searchFor$
print "Searching for: " : print
print " "; searchFor$ : print
I = 0
nomatch = 1
open "datenbank.txt" for input as #1
WHILE EOF(#1)= 0
Line input #1,daten$(I) ' Input ein String ein lesen

a$ = upper$(daten$(I))
b$ = upper$(searchFor$)
if instr(a$, b$) > 0 then
print "Found! " ;daten$(I) : nomatch = 0 : print : print 'Gosub [Editdata]
end if
I = I + 1
WEND
if nomatch <> 0 then print "No matches found !" : print
close #1
goto 25



[Editdata]



« Last Edit: Aug 14th, 2016, 08:29am by Zabo » User IP Logged

Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: This sequential database is running !
« Reply #1 on: Aug 14th, 2016, 08:25am »

Hello friends ,

i made the mistake in the searchbranch to open the file again. That is not possible.

Altogether you can say :

In array handling with Input and Outpu Mode there are
3 Levels :

1. Loading the complete data from file into memory
2. Playing and mofying the data
3. Writing the complete data back to file.


So i have mofified the searchlabel only for the data in memory. easy handling
Therefore it is possible to gosub from that searchlabel to
a Editlabel and editing the array in memory.

find and edit

Also a cool backupfile i have included.
Everytime when the program will be closed the data
is written to a second backup file !

Here is the code : WBR Zabo



Rem Sequentielle Datenbank = .txt Datei mit Suchfunktion und Sortierung


10 CLS

14 dim daten$(1000)

15 index = 0
16 open "datenbank.txt" FOR Input AS #1
17 WHILE EOF(#1)= 0
19 index = index + 1
20 LINE INPUT #1,daten$(index)
21 Print daten$(index) 'this is only to display
22 WEND
23 close #1

24 outex1 = index



25 Print "Wollen Sie neue Daten eingeben oder wollen Sie suchen ? ( D / S / N)"
26 Print

40 Input Y$

50 If Y$ = "D" or Y$ = "d" then goto 220
60 If Y$ = "S" or Y$ = "s" then goto [searchfor]
65 If Y$ = "N" or Y$ = "n" then goto 510
70 If Y$ <> "D" and Y$ <> "d" and Y$ <> "S" and Y$ <> "s" then goto 25



220 Print " Jetzt koennen Sie neue Daten eingeben"
230 outex1 = outex1 + 1
240 Print
250 input " Neuer Datensatz : " ; daten$(outex1)
260 Print
270 Print " Der neue Datensatz : " ; daten$(outex1) ; " : wurde abgespeichert" : print : print
280 Print "Wollen Sie neue Daten eingeben ( J / N ) , zurueck zum Hauptmenue mit ENTER"
290 Print
300 Input Z$
310 If Z$ = "J" or Z$ = "j" then goto 220
320 If Z$ = "N" or Z$ = "n" then goto 510
330 If Z$ <> "J" and Z$ <> "N" and Z$ <> "j" and Z$ <> "n" then goto 25
340 Print



510 Print " Vielen Dank fuer die Eingaben , Auf Wiedersehn" : print



'' here comes the sorting algorhytm in YEAH




910 open "datenbank.txt" for output as #1
920 for printex1 = 1 to outex1
930 print #1, daten$(printex1)
940 next printex1
950 close #1

960 open "datenbankbackup.txt" for output as #2
970 for printex2 = 1 to outex1
980 print #2, daten$(printex2)
990 next printex2
1000 close #2



1010 print : print

1020 for s = 1 to outex1 'this is only to display
print daten$(s)
next s




1030 end





[searchfor]

input "Type some text to search for? "; searchFor$
print "Searching for: " : print
print " "; searchFor$ : print

nomatch = 1
for suchen = 1 to outex1
a$ = upper$(daten$(suchen))
b$ = upper$(searchFor$)
if instr(a$, b$) > 0 then
print "Found! " ;daten$(suchen) : nomatch = 0 : print : print 'Gosub [Editdata]
end if
next suchen
if nomatch <> 0 then print "No matches found !" : print
goto 25



[Editdata] '' yes , editing is possible here because only the data in memory are changed












User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1689
xx Re: This sequential database is running ! update
« Reply #2 on: Aug 14th, 2016, 4:14pm »

Quote:
'' here comes the sorting algorhytm in YEAH

Don't forget there is a SORT command in LB
User IP Logged

damned Dog in the Manger
Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: This sequential database is running ! update
« Reply #3 on: Aug 14th, 2016, 4:42pm »

Thank you tsh73 ,

i never know that before.

The times of "swap" command is really stuff from yesterday.

A sort command is the best.

With that command it is easy to make the sort routine.

Regards

Zabo
User IP Logged

Zabo
Full Member
ImageImageImage


member is offline

Avatar

Yes. It work's. ha


PM

Gender: Male
Posts: 125
xx Re: This sequential database is running ! update
« Reply #4 on: Aug 15th, 2016, 2:20pm »

WHHHHOOOOOOOOOOOOOOOOAA YEAHHH BABE !

Just want to write a traditional sorting algo that
run without a non existing SWAP command.

Just for fun.

Normally not in use.

' here comes the sorting algorhytm in YEAH
'600 sort daten$(), 1, outex1

600 For sorting = 1 to outex1 -1
610 K=sorting : AK$=daten$(sorting)
620 For extending = sorting+1 to outex1
630 If daten$(extending)<AK$ then K=extending : AK$=daten$(K)
640 next extending
650 daten$(K)=daten$(sorting) : daten$(sorting)=AK$
660 next sorting


Normally the sort command is used.

Anyway , if someone like this code. Grap it !


Zabo
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls