Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Beginners Guide to Dark Basic - DBP - need help Chapter 15

Author
Message
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 20th Feb 2006 14:27
I'm studying the Guide to DarkBasic and am in Chapter 15 that covers FileManager Program. There is a part of the Source Code that I don't understand.
I've attached the code as a wordPad file.
The Arrays are given the value of :
ô¿ô
NewCommand(1) = 0
CurrentPage(1) = 0
CurrentSelectedItem(1) = 1
MaxFiles(1) = 0
PageSize(1) = 20
PageStartY(1) = 40
FileSpacing(1) = 16
ô¿ô
However in the FUNCTION DisplayFiles
it has the calculations :
------
PageOfFiles = CurrentPage(1)*PageSize(1)
-----
Complete function below:
FUNCTION DisplayFiles()
Black = RGB(0,0,0)
White = RGB(255,255,255)
Blue = RGB(0,0,255)
Red = RGB(255,0,0)
FIND FIRST

MaxFiles(1) = 0
WHILE GET FILE TYPE()<> -1
MaxFiles(1) = MaxFiles(1) + 1
FIND NEXT
ENDWHILE

FIND FIRST
PageOfFiles = CurrentPage(1)*PageSize(1)
FOR X = 1 to PageOfFiles
FIND NEXT
NEXT X

FOR X = 0 TO PageSize(1)-1
IF GET FILE TYPE() = -1
EXIT
ENDIF
PosY = ((x)*FileSpacing(1))+PageStartY(1)
IF GET FILE TYPE() = 0
TempString$ = GET FILE NAME$()
TempString2$ = GET FILE NAME$()+" "+GET FILE DATE$()
ELSE
TempString$ = "<"+GET FILE NAME$()+">"
TempString2$ = "<"+GET FILE NAME$()+"> "+GET FILE DATE$()
ENDIF

IF CurrentSelectedItem(1)=(x-StartA)+1
INK White,Blue
CurrentFile$(1) = GET FILE NAME$()
CurrentFileType(1) = GET FILE TYPE()
TEXT 10,PosY, TempString$
SpaceString$ = " "
FOR y = 1 to 120
SpaceString$ = SpaceString$ + " "
NEXT y
INK White, Black
CENTER TEXT 320,380, SpaceString$
CENTER TEXT 320,380, TempString2$
ELSE
INK White,Black
TEXT 10,PosY, TempString$
ENDIF
FIND NEXT
NEXT X
ENDFUNCTION
End of the function statement.
From what I can figure in:
PageOfFiles = CurrentPage(1)*PageSize(1)
PageOfFiles should = 0 (see below)
(PageOf Files = 0 * 20)

What am I missing.
I I've added the complete source code below but I'm new and I don't think it will be added to my question.
Thanks in advance,
Yekoms

Keep'em Movin

Attachments

Login to view attachments
Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 20th Feb 2006 17:44 Edited at: 20th Feb 2006 17:45
That .txt doesent contain anything. And next time, unse the [ code ][ /code ] (except the spaces) for any code, like this:


Sorry, but I dont really understand your question (Ive not read that chapter, since I dont got that book). All I can tell you is that the program seems to work for me.
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 20th Feb 2006 18:07
The program does work. The Source did display under the SOURCE button on the right. My question is that in the Function DisplayFiles, it calculates "PageOfFiles = CurrentPage(1)*PageSize(1)" inwhich, CurrentPage(1) = 0 and PageSize(1) = 20, and, as I figure it, should equal 0. The program works, but, I'm trying to figure out why. I'll attach the code again as a word.doc and under the code section.

Keep'em Movin

Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Feb 2006 21:29


All the above part does is start at the first filename and run though the files until it's hit CurrentPage(1)*PageSize(1). It starts out at zero but when you push pagedown "CurrentPage(1)" is increased and the above snip runs through the first 19 files so the rest of the function will display the files starting at file #20. If you rem this off you won't be able to see any other pages than the first page...because the first page just skips this part because it starts at zero.

Here's what increases "CurrentPage(1)"... located in the "ProcessCommands()" function:



Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 21st Feb 2006 14:07
Thanks, that helps. Still can't grasp why it would display if the result is 0 unles it displays it on the 2nd run-thru.
Being new I'm not sure how to get the [ + Code Snippet ] to display but will try it a different way.
Thanks again for the help, I'll set back and study the source code some more.
[
FIND FIRST
PageOfFiles = CurrentPage(1)*PageSize(1)
FOR X = 1 to PageOfFiles
FIND NEXT
NEXT X
]

Keep'em Movin
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 21st Feb 2006 14:09
Still can't seem to get it to display as [ + Code Snippet ]
What's the seceret?
[\
FIND FIRST
PageOfFiles = CurrentPage(1)*PageSize(1)
FOR X = 1 to PageOfFiles
FIND NEXT
NEXT X
]

Keep'em Movin
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 21st Feb 2006 23:02
It doesn't display anything its made to skip pages. The command "find first" shows the very first file in the current directory. "find next" loads up the next file and so on until 20 files have been seen. The next section is the part that actually show the files.

Think of it like a book. If you look at a book you'll see that a certain number of lines are in that book per page. It reads the first line, then all the lines down to the last line. When the section that actually shows the files runs it starts on the next page of the book and shows only that page. If want to see page 3 that section skips the first two pages so the 3rd page can be shown. The only difference this "book" only has 20 lines per page.

When it's on the first page that section is skipped. It won't even run until you want to look at page 2 and above.

To make code snips you use
[ code ]
Your code here.
[ /code ]

Just remove the spaces between the brackets and we see this:



Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 22nd Feb 2006 16:13
Thanks,It's making more sence now. I still have a few more modifications to the program yet but am waiting to understand each part b4 I move to the next.
If I can't figure it out I'll be back
Thanks again from a newbee.

FUNCTION BlueSkys
ô¿ö
-
testing the CODE SNIPPET
ENDFUNCTION

[\code]

Keep'em Movin
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 22nd Feb 2006 16:15
CODE SNIPPET DIDN'T WORK

I don't mean to waste space but I'm trying to get the + code snippet to display

Keep'em Movin
Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 23rd Feb 2006 19:26
Next Question
Futher down in the FUNCTION DisplayFiles

What does the "(x-StartA)+1" do? As this is the only place in the entire Source Code that the 'StartA' is found. The only thing I can come up with is x =
, which, as I see it, StartA is 0 as it isn't given a value at any point in the program.

Keep'em Movin
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 23rd Feb 2006 19:42
Yeah. "StartA" is really not needed. I don't see it anywhere else in the code either. When variables are used for the first time without defining them they always start at zero.


Yekoms
18
Years of Service
User Offline
Joined: 6th Dec 2005
Location: Deep inside FUNCTION BlueSkys
Posted: 23rd Feb 2006 22:38
Thanks
that's what I was thinking.
Again, thanks for help'n a newbee.
ô¿ô

Keep'em Movin
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 24th Feb 2006 11:23
Np.


Login to post a reply

Server time is: 2024-11-27 03:37:40
Your offset time is: 2024-11-27 03:37:40