CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 114 users online: 3 members, 86 guests and 25 bots.
Members: GISdude.
Bots: VoilaBot (2), Spinn3r (1), VoilaBot (4), Yahoo! Slurp (1), Googlebot (14), MSN/Bing (3).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
Author Message
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 13 Sep 2011 07:13:02 pm    Post subject: Fun Programming help- Virus Scanner

Ok, so me and a firend are working on a project called virus scanner. It does nothing really, just pretends to scan for viruses, thus wasting the calculator. Here is the code now

Code:

:ClrHome
:0→P:0→Q:0→R:0→V:0→W:0→C
:For(P,0,100,1)
:Disp "SCANNING FOR"
:Disp "VIRUSES"
:Disp C
:Disp "PERCENT"
:Disp "COMPLETED"
:For(Q,0,25,.1)
:End
:ClrHome
:C+1→C
:End
:Pause "PRESS TO CONT."
:ClrHome
:For(W,0,10,1)
:Disp "FOUND VIRUSES!"
:For(V,0,100,1)
:End
:ClrHome
:End
:Disp "FOUND"
:randInt(100,1000)→A
:Disp A,"VIRUSES"
:Pause

So far that just does a bunch of fancy work to scan, pause for the user, and show a random number of viruses. We plan to add more code that will delay the calculator for X seconds, based on the number of viruses. What we need help with is two features . 1- (this will change the current way the # of viruses is displayed)we want to have the calculator check if has already run, and if so, display o viruses. If not, then the calculator makes up a number of viruses and runs.
2-(adds a progress bar) When the program first runs it displays Scanning... X percent complete. We want to add a visual progress bar to the screen. What we mean is every 6.25 cycles of the previous display, it adds a symbool to the last line displayed, giving the user a visual representation of how much progress has passed.
Back to top
souvik1997


Guru-in-Training


Joined: 19 Apr 2010
Posts: 2870

Posted: 13 Sep 2011 07:31:25 pm    Post subject:

For #1, you could create a list and store a value in it. Then, when your program starts you can check if that value is still in that list.

Code:
:1->dim(LVIRUS
:If LVIRUS(1)=1.23213
:Then
://the virus check has already been run before
:Else
://the virus check has not been run before
:End
:1.23213->LVIRUS(1

You can change 1.23213 to any other number if you want to.
_________________
CALCnet Tournament-38%


deviantArt
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55733
Location: Earth, Sol, Milky Way

Posted: 13 Sep 2011 07:38:34 pm    Post subject:

Agree for (1). You could also use one of the Finance variables instead of a list, if you wanted. For (2). Just draw a rectangle, then draw successive vertical lines in the progress bar.
_________________


Back to top
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 13 Sep 2011 08:53:55 pm    Post subject:

Like solution for one but have issuses with two. For the progress screens I have text and with to add the progress bar to the last line of the screen. I feel like this could be accomplished by just using 16 characters to progressively fill the line. I see a solution but can't code it. This code would go after "for(p,0,100,1)". You have a second counter that counts .25 instead of one in var f. If f is a multiple of 6.25 then add one character to the line. Can anyone code this idea?
Back to top
souvik1997


Guru-in-Training


Joined: 19 Apr 2010
Posts: 2870

Posted: 13 Sep 2011 09:03:56 pm    Post subject:

JPfowl wrote:
Like solution for one but have issuses with two. For the progress screens I have text and with to add the progress bar to the last line of the screen. I feel like this could be accomplished by just using 16 characters to progressively fill the line. I see a solution but can't code it. This code would go after "for(p,0,100,1)". You have a second counter that counts .25 instead of one in var f. If f is a multiple of 6.25 then add one character to the line. Can anyone code this idea?

To see if F is a multiple of 6.25, you can use "not(fPart(F/6.25". That would output 1 if F is a multiple of 6.25, and 0 if it isn't.
_________________
CALCnet Tournament-38%


deviantArt
Back to top
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 13 Sep 2011 09:36:42 pm    Post subject:

How can I add the second counter in the code though? I can't use another for(, so what can I use?
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55733
Location: Earth, Sol, Milky Way

Posted: 14 Sep 2011 09:51:14 am    Post subject:

JPfowl wrote:
How can I add the second counter in the code though? I can't use another for(, so what can I use?
Why not just divide your primary loop variable by 4 each time you need to check this "second" loop value?
_________________


Back to top
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 14 Sep 2011 02:20:17 pm    Post subject:

How would that work though? If I divide the primary loop inside of the loop then is won't add up to the same number of cycles. What I need is for the two cycles to run at the same time, because the primary loop counts by ones from 0-100 but the secondary myst count by 6.25 from 0 to 100.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55733
Location: Earth, Sol, Milky Way

Posted: 14 Sep 2011 03:36:04 pm    Post subject:

JPfowl wrote:
How would that work though? If I divide the primary loop inside of the loop then is won't add up to the same number of cycles. What I need is for the two cycles to run at the same time, because the primary loop counts by ones from 0-100 but the secondary myst count by 6.25 from 0 to 100.
Well, it's not a very optimized solution, but you could run the loop by the GCD of the two increments:


Code:
For(X,0,100,0.25
If X=int(X
Then
//Do the increment-1 stuff
End
If (X/6.25) = int(X/6.25
Then
//Do the increment-6.25 stuff
End
End

_________________


Back to top
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 19 Sep 2011 10:03:10 pm    Post subject:

So this is the code so far

Code:

:ClrHome
:0→Z
:SetUpEditorVIR
:If dim(∟VIR)>0
:dim(∟VIR)→Z
:If Z>0
:Then
:Goto SR
:Else
:{1.62574}→∟VIR
:Goto SS
:End
:Lbl SS
:0→A:0→B:0→C:0→D:0→D:0→E:0→F:0→G:0→H:0→I:0→J:0→K:0→L:0→M:0→N:0→O:0→P:0→Q:0→R:0→S:0→T:0→U:0→V:0→W:0→X:0→Y:0→Z
:For(P,0,100,1)
:If P=int(P)
:Then
:Output(1,1,"SCANNING FOR"
:Output(2,1,"VIRUSES"
:Output(3,1,(C/2)
:Output(3,4,"PERCENT"
:Output(4,1,"COMPLETED"
:Output(6,1,"|             |"
:Output(5,1,"|[PROGRESS BAR]|"
:Output(7,1,"V              V"
:For(R,0,25,.1)
:End
:(P/6.25)→Y
:If Y=int(1)
:Then
:G+1→G
:End
:If Y≥1 and Y<2
:Output(8,1,"บ")
:If Y≥2 and Y<3
:Output(8,1,"บบ"
:If Y≥3 and Y<4
:Output(8,1,"บบบ"
:If Y≥4 and Y<5
:Output(8,1,"บบบบ"
:If Y≥5 and Y<6
:Output(8,1,"บบบบบ"
:If Y≥6 and Y<7
:Output(8,1,"บบบบบบ"
:If Y≥7 and Y<8
:Output(8,1,"บบบบบบบ"
:If Y≥8 and Y<9
:Output(8,1,"บบบบบบบบ"
:If Y≥9 and Y<10
:Output(8,1,"บบบบบบบบบ"
:If Y≥10 and Y<11
:Output(8,1,"บบบบบบบบบบ"
:If Y≥11 and Y<12
:Output(8,1,"บบบบบบบบบบบ"
:If Y≥12 and Y<13
:Output(8,1,"บบบบบบบบบบบบ"
:If Y≥13 and Y<14
:Output(8,1,"บบบบบบบบบบบบบ"
:If Y≥14 and Y<15
:Output(8,1,"บบบบบบบบบบบบบบ"
:If Y≥15 and Y<16
:Output(8,1,"บบบบบบบบบบบบบบบ"
:If Y≥16 and Y<17
:Output(8,1,"บบบบบบบบบบบบบบบบ"
:C+2→C
:End
:End
:Pause "PRESS TO CONT."
:ClrHome
:For(W,0,10,1)
:Output(1,1,"FOUND VIRUSES!"
:Output(2,1,"FOUND VIRUSES!"
:Output(3,1,"FOUND VIRUSES!"
:Output(4,1,"FOUND VIRUSES!"
:For(V,0,100,1)
:End
:ClrHome
:End
:Output(1,1,"FOUND"
:randInt(100,1000)→A
:(100A)→B
:Output(1,6,A
:Output(1,7,"VIRUSES"
:Disp "PRESS ANY KEY TO"
:Pause "DELETE VIRUSES"
:For(J,0,B,1)
:Lbl SR
:Output(3,1,"CALC VIRUS FREE"
:Output(4,1,"PLEASE THANK"
:Output(5,1,"Josh P"
:""

There is a problem however, towards the end there is a final for command that looks like this ":For(J,0,B,1)". That code is supposed to delay based on the the number of viruses that were picked before. When I run this program however, the delay is skipped altogether and the program goes from the commands above to the commands below that line instantly (or so it seems). Why is the delay not working?
Back to top
souvik1997


Guru-in-Training


Joined: 19 Apr 2010
Posts: 2870

Posted: 19 Sep 2011 10:05:39 pm    Post subject:

That command needs an End after it. Use this instead:

Code:
:For(J,0,B,1):End

_________________
CALCnet Tournament-38%


deviantArt
Back to top
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 19 Sep 2011 10:06:12 pm    Post subject:

Oh duh.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55733
Location: Earth, Sol, Milky Way

Posted: 19 Sep 2011 10:09:25 pm    Post subject:

souvik1997 wrote:
That command needs an End after it. Use this instead:

Code:
:For(J,0,B,1):End
Don't use a For() loop for a delay, though, and even if you do, omit the 1,): to make it:


Code:
For(J,0,B
End


The better solution is a rand( delay, something like

Code:
rand(int(B/3

_________________


Back to top
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 19 Sep 2011 10:14:33 pm    Post subject:

Whats the difference between the for and the rand? I know the approx. ratio for the for function at For(X,0,100 is about 100 sec. What is the ratio with the rand funct?

Also when I compile i get this error-
Error on line 22 at "... \")
:Output(5,1,"\[PROGRESS BAR]...".
Error on line 23 at "..."\[PROGRESS BAR]/")
:Output(7,1,"...".
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55733
Location: Earth, Sol, Milky Way

Posted: 19 Sep 2011 11:26:29 pm    Post subject:

You save almost half the bytes with the rand() method, even when you need to manipulation the pause amount, as with int(B/3). SourceCoder is confused because the TI-83+/84+ has no backslash character.
_________________


Back to top
JPfowl


Member


Joined: 25 Jan 2011
Posts: 135

Posted: 23 Sep 2011 10:16:47 pm    Post subject:

Ok, got it. I have another program that gores with this one, the "virus". It uses an output with randint('s to pick a random location, then displays a random number. The thing I need help with is this, is there a way to do a random letter? Or do I have to do a randint(1,20)->a. If a=... for all the letters?
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55733
Location: Earth, Sol, Milky Way

Posted: 24 Sep 2011 05:53:45 am    Post subject:

JPfowl wrote:
Ok, got it. I have another program that gores with this one, the "virus". It uses an output with randint('s to pick a random location, then displays a random number. The thing I need help with is this, is there a way to do a random letter? Or do I have to do a randint(1,20)->a. If a=... for all the letters?
No, you absolutely do not!


Code:
sub("ABCDEFGHIKLMNOPQRSTUVWXYZ",randInt(1,26),1


This example picks a random number from 1 to 26, then picks out the one-character substring of the alphabet starting at that offset.
_________________


Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

Go to Registration page
   
View previous topic :: View next topic  
Page 1 of 1 ป All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.038630 seconds.