Keyboard Input To Program Window

V+ discussions, tips and tricks, sample code, Q & A

Keyboard Input To Program Window

Postby pedros » Wed Oct 03, 2012 8:26 am

Is it possible to monitor the keyboard in V16.3 and when a button is pressed read the value of the key which is pressed into a $CHR variable
pedros
 
Posts: 3
Joined: Fri Sep 04, 2009 12:17 am

Re: Keyboard Input To Program Window

Postby brianch » Wed Oct 03, 2012 10:23 am

You could try this program...

.PROGRAM varchr()

;ABSTRACT: Example program to retrieve characters from the keyboard one at a time and type them out to the monitor.
;CTRL-C is use as an escape character to end the program.
;SIDE EFFECTS: Typed characters are also echoed to the monitor when you type them.

AUTO rval
AUTO $tchr

ATTACH (4) ;Attach the keyboard

WHILE TRUE DO ;Run forever

rval = GETC(4) ;Get input from keyboard

IF rval == 3 THEN ;Check for CTRL-C so you can escape

DETACH(4) ;Detach keyboard
EXIT ;Exit the WHILE loop (exit program)

ELSE

$tchr = $CHR(rval) ;Turn input into a one character string
TYPE "You typed ", $tchr ;Do what ever you want with your variable

END ;END IF
END ;END WHILE

.END

...Sorry about the readability, the white space was scrubbed when I entered the post.
brianch
 
Posts: 14
Joined: Fri Oct 24, 2008 9:06 am

Re: Keyboard Input To Program Window

Postby pedros » Thu Oct 04, 2012 2:34 am

Is there any way that i can stop keyboard input from being echoed to the monitor because when i type in "n" for the operator to signify NO then the monitor sees this and responds by displaying the "NET" info
pedros
 
Posts: 3
Joined: Fri Sep 04, 2009 12:17 am

PROMPT and ATTACH keywords not working

Postby Rajat Rohit » Sun Jun 18, 2017 11:32 pm

Hi,

I am using Adept ACE version 3.0.3.11 on my windows PC. I am not able to get inputs from the keyboard using PROMPT or ATTACH keywords. It says invalid instruction in the editor. I am not able to check the V+ version also. Can someone please help me in this?
Rajat Rohit
 
Posts: 8
Joined: Wed Jun 14, 2017 11:24 pm

Re: Keyboard Input To Program Window

Postby Guenter Grass » Tue Jun 20, 2017 1:58 am

Hi,

either you typed in the commands with a wrong syntax or you are using an iCobra/eVario robot which is using Micro V+ as an operating system. In Micro V+ the PROMPT and ATTACH commands are not available.

Here an example for the prompt command
PROMPT "Enter number", number

If the connection to program your Cobra robot is a serial cable than you are using Micro V+.

Best Regards
Günter
Guenter Grass
 
Posts: 189
Joined: Thu Oct 16, 2008 4:34 am

Re: Keyboard Input To Program Window

Postby Rajat Rohit » Tue Jun 20, 2017 4:06 am

Hi,
Thanks for replying. I am using Cobra i600 as you said. Can you tell me how can I take inputs from the keyboard in Micro V+?

Thanks
Rajat Rohit
 
Posts: 8
Joined: Wed Jun 14, 2017 11:24 pm

Re: Keyboard Input To Program Window

Postby Guenter Grass » Tue Jun 20, 2017 7:04 am

Hi,

the only thing I can think of is to change the value of a variable from the monitor window and wait in the V+ program for the change.

e.g. V+ Program
step = 0
DO
WAIT
UNTIL step <> 0

In the Monitor Window type
DO @2 step = 5

Best Regards
Günter
Guenter Grass
 
Posts: 189
Joined: Thu Oct 16, 2008 4:34 am

Re: Keyboard Input To Program Window

Postby Rajat Rohit » Wed Jun 21, 2017 2:20 am

Hi

I used to DO monitor command as "DO @0:dig_in in = 2" in my program. The command is getting executed but the value of the variable "in" is not changing.
Rajat Rohit
 
Posts: 8
Joined: Wed Jun 14, 2017 11:24 pm

Re: Keyboard Input To Program Window

Postby Guenter Grass » Wed Jun 21, 2017 2:59 am

Hi,

as you describe the instruction fails to set the value of the LOCAL variable "in" in the program dig_in. DO @0:dig_in in = 2

Can you test it with a global variable? e.g. glob_in with DO @2 glob_in = 2
Make sure that you run the instruction in a Task that is not currently running. E.g. if task 0 is running change the global variable in task 2 with DO @2

Best Regards
Günter
Guenter Grass
 
Posts: 189
Joined: Thu Oct 16, 2008 4:34 am

Re: Keyboard Input To Program Window

Postby Rajat Rohit » Wed Jun 21, 2017 4:43 am

Hi

I tried making the variable global ..but still its not changing the value. Is there anything else I am missing out on?
Thank You.
Rajat Rohit
 
Posts: 8
Joined: Wed Jun 14, 2017 11:24 pm

Next

Return to V+

Who is online

Users browsing this forum: No registered users and 1 guest

cron