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.
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.
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.
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?
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.
How can I add the second counter in the code though? I can't use another for(, so what can I use?
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?
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.
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
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?
That command needs an End after it. Use this instead:

Code:
:For(J,0,B,1):End
Oh duh.
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
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,"...".
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.
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?
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.
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement