Register

output without pause

Discuss issues related to the Casio Basic Language
Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

output without pause

Postby nsg » Fri Feb 08, 2013 2:58 am

Is there equivalent of BASIC "print" command? I need to output several lines without pause.
The program should ask a line then print out several lines of results (which are string variables), then ask for next line and so on. Something like that.
I cannot figure out how to arrange it. The little black triangle prints numeric value, but pauses. locate places line in specific place, but then I cannot use ? for input because it keeps moving down and eventually scrolls the window.
I might even be ok with the pauses, but it only seems to ouptut numerical values and not string variables.

I have a feeling that i am missing something obvious.

Senior Member
User avatar
Posts: 66
Joined: Sun Apr 15, 2012 4:00 pm
Calculators: Casio fx-9860G

Re: output without pause

Postby aapman55 » Fri Feb 08, 2013 10:43 am

To ask for a string as input:
Code: Select all
"What is your name?"? -> Str 1 //There are 20 slots for strings


To display a string on the desired location use either Locate (big font) or Text(small font, and uses the graph display, you need to disable the axes for a better looking result)
Code: Select all
Locate 1,1,Str 1


to pause the program you can use this very nice piece of code of Pierrot (viewtopic.php?t=1427&f=24)
Code: Select all
While GetKey:WhileEnd //wait while a key is pressed
Do:Getkey
LpWhile Not Ans


If you do not want the screen to scroll and want to have full control, then you should use clrText.

A small example:
Code: Select all
"What is your name"? -> Str 1
ClrText
Locate 1,1,Str1
While GetKey:WhileEnd
Do:Getkey
LpWhile Not Ans
ClrText
"How old are you"? -> A

et cetera...


Please keep in mind that if you want to incorporate some comments, in casio basic its the apostrofe '

User avatar
Posts: 89
Joined: Thu Apr 05, 2012 3:16 pm
Location: Akron, OH, USA
Calculators: Casio fx-9750GII, Casio fx-CG10

Re: output without pause

Postby flyingfisch » Fri Feb 08, 2013 4:19 pm

I thought that there were only six string slots...

Senior Member
User avatar
Posts: 66
Joined: Sun Apr 15, 2012 4:00 pm
Calculators: Casio fx-9860G

Re: output without pause

Postby aapman55 » Fri Feb 08, 2013 9:42 pm

Ah, then i think i mixed it up with something else. Never really used those strings.

Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

Re: output without pause

Postby nsg » Sat Feb 09, 2013 5:05 pm

Here is what I wanted (equivalent in PC basic):
10 input "What is your name";n$
20 g$="Hello, "+n$
30 print g$
40 goto 10

That is, ask for some data, perform some manipulation, output a result, ask for next data, while previous result is still visible.

Here is what I ended up doing:
""->Str 1
Lbl 1:ClrText:Locate 1,3,Str 1:"Your name"?->Str 2:"Hello, "+Str 2->Str 1
Goto 1

ClrText resets the position of query question mark to top line and ensures that it would not overwrite previous output.
Previous output is UNDER the current question mark, which may be confusing to the user. And only one previous answer is visble, it would be better if more were visible, there is enough room on the screen.

With getkey aproach i only can get a scancode and have to translate them into characters myself, doing all shift and alpha mode switching in the process. Also, there is no visible blinking cursor (which is good for video game, but bad for data entry).

This seems like awkward and roundabout way to do a very simple thing.

Senior Member
User avatar
Posts: 66
Joined: Sun Apr 15, 2012 4:00 pm
Calculators: Casio fx-9860G

Re: output without pause

Postby aapman55 » Sun Feb 10, 2013 10:53 am

no the getkey is only for the pause purpose.
For string manipulations go to [PRGM]->F6->F6-> Str. The you see a lot of functions for strings. In your case you can use StrJoin.

Example:
Code: Select all
"AAP" -> Str 1
StrJoin("YOUR NAME IS ",Str 1)


So what you actually want is a program that asks your name, then greets you and then ask your name again? While the previous greetings are still visible?

Senior Member
User avatar
Posts: 113
Joined: Sun Dec 16, 2012 2:59 pm
Calculators: None

Re: output without pause

Postby Casimo » Sun Feb 10, 2013 12:55 pm

aapman55 wrote:no the getkey is only for the pause purpose.
For string manipulations go to [PRGM]->F6->F6-> Str. The you see a lot of functions for strings. In your case you can use StrJoin.

Example:
Code: Select all
"AAP" -> Str 1
StrJoin("YOUR NAME IS ",Str 1)


So what you actually want is a program that asks your name, then greets you and then ask your name again? While the previous greetings are still visible?


Isn't it
Code: Select all
StrJoin("YOUR NAME IS ",Str 1)->Str2
?
Image

Senior Member
User avatar
Posts: 66
Joined: Sun Apr 15, 2012 4:00 pm
Calculators: Casio fx-9860G

Re: output without pause

Postby aapman55 » Sun Feb 10, 2013 2:35 pm

if you want to store it, yes. But i just wanted to show the concept of how to use this function

Senior Member
Posts: 69
Joined: Sat Feb 02, 2013 4:29 am
Calculators: Casio Cfx Series, Casio fx-CG10

Re: output without pause

Postby nsg » Sat Feb 16, 2013 5:54 pm

Ok, I found something strange.
aapman55, on my calculator (fx-cg10, os er 1.04) your code when run from program environment does not produce final string "YOUR NAME IS AAP". It just writes "Done" and that's it. On the other hand, when run from run/matrix (in line mode), as Prog "NAME", then there is an output!

To check that this is not just an artifact of str being last line and thus filling Str Ans variable, i tried this:

Code: Select all
Lbl 1
"Name"? -> Str 1
StrJoin("Hello, ",Str 1)
Goto 1


And it works differently in Run/Matrix(Line) and Program modes.
In program it asks question, but does not produce any ouptut, in run/matrix mode it produces output and keeps scrolling, exactly as I want.

Once again, this is for fx-CG10. Can anybody with fx-9xx0 see if it has same discrepancy?

Senior Member
User avatar
Posts: 113
Joined: Sun Dec 16, 2012 2:59 pm
Calculators: None

Re: output without pause

Postby Casimo » Sat Feb 16, 2013 7:09 pm

On my fx9860 GII-2 it's the same.
Image

Next

Return to Casio Basic Development

Who is online

Users browsing this forum: No registered users and 38 guests