nqce: an editor for Not Quite C | Manual | Language Reference | ReadMe | Shortcuts | FAQ |
NQC Language Reference |
Input Commands
Input Ports - IN_1 IN_L - IN_2 IN_M - IN_3 IN_R Input Modes - SensorMode(i, mode) - SMODE_RAW - SMODE_BOOL - SMODE_EDGE - SMODE_PULSE - SMODE_PERCENT - SMODE_CELCIUS - SMODE_FAHRENHEIT - SMODE_ANGLE Input Types - SensorType(i, type) - STYPE_SWITCH - STYPE_TEMP - STYPE_LIGHT - STYPE_ANGLE Input Configurations - Sensor(i, config) - IN_CFG(type,mode) - IN_SWITCH - IN_LIGHT - IN_ANGLE - IN_PULSE - IN_EDGE |
Output Commands
Output Ports - OUT_A - OUT_B - OUT_C Output Modes - OUT_ON - OUT_OFF - OUT_FLOAT Output Directions - OUT_FWD - OUT_FLIP - OUT_REV Full Speed - OUT_FULL Output Functions - Fwd(o, p) - Rev(o, p) - Off(o) - Float(o) - OutputMode(o, m) - OutputDir(o, d) - OutputPower(o, p) |
Data Sources
General - Timer(n) - Random(n) - Input(n) - InputType(n) - InputMode(n) RCX Specific - Program() - InputRaw(n) - InputBool(n) - Watch() - Message() |
Miscellaneous
Misc. - Wait(c) - PlaySound(x) - PlayNote(f, d) - Sleep(v) - Display(v) - SendMessage(v) - ClearMessage() Data Logging - SetDatalog(v) - Datalog(v) - UploadDatalog(s, n) Controlling IR Mode - IR_LO 0 - IR_HI 1 - IR_Mode(m) |
IN_1
= Input Port 1 (Same as IN_L - Left)
IN_2
= Input Port 2 (Same as IN_M - Middle)
IN_3
= Input Port 3 (Same as IN_R - Right)
SensorType(IN_2, IN_LIGHT); //Sets Light Sensor in PORT 2
SensorMode(i, mode)
= Set a sensor's mode when it reads input
SMODE_RAW
= Raw mode
SMODE_BOOL
= Boolean mode
SMODE_EDGE
= Edge mode
SMODE_PULSE
= Pulse mode
SMODE_PERCENT
= Percent mode
SMODE_CELCIUS
= Celcius mode
SMODE_FAHRENHEIT
= Fahrenheit mode
SMODE_ANGLE
= Angle mode
SensorMode(IN_1, SMODE_RAW); //Sets Sensor in Input Port 1 to RAW MODE
SensorType(i, type)
= Set a sensor's type
STYPE_SWITCH
= Touch sensor type
STYPE_TEMP
= Temparature sensor type
STYPE_LIGHT
= Light sensor type
STYPE_ANGLE
= Angle sensor type
SensorType(IN_M, STYPE_LIGHT); //Sets a sensor in Input Port 2 as a LIGHT TYPE
Sensor(i, config)
= Sets a sensor with a specific configuration
IN_CFG(type,mode)
= Customized Configuration
IN_SWITCH
= Touch config
IN_LIGHT
= Light config
IN_ANGLE
= Angle config
IN_PULSE
= Pulse config
IN_EDGE
= Edge config
Sensor(IN_1, IN_SWITCH); //Makes a sensor in Input Port 1 with a Touch configuration
Sensor(IN_L, IN_CFG(STYPE_LIGHT, SMODE_RAW)) // Sets a Light sensor in port 1 with Raw
OUT_A
= Output Port 1
OUT_B
= Output Port 2
OUT_C
= Output Port 3
Fwd(OUT_A, 1); //Tells the motor in Output Port A to go forward at speed 1
OUT_ON
= Tells the output to turn On
OUT_OFF
= Tells the output to turn Off
OUT_FLOAT
= Tells the output to slowly turn Off (Floating)
OUT_FWD
= Sets output to go forward
OUT_FLIP
= Sets output to reverse direction
OUT_REV
= Sets output to go reverse
OUT_FULL
= Full speed!!!
On(OUT_B, OUT_FULL); //Sets the motor in Output Port B to go full speed
Fwd(o, p)
= Sets the motor go forward and speed
Rev(o, p)
= Sets the motor go reverse and speed
Off(o)
= Turns off Motor
Float(o)
= Slowly turns off Motor
OutputMode(o, m)
= Sets the output mode
OutputDir(o, d)
= Sets the output direction
OutputPower(o, p)
= Sets the output power
Fwd(OUT_A+OUT_C, 4); //Sets the motors in port A and C to go forward at half speed
Fwd(OUT_A, 4); //Sets the motor in port A to go forward at half speed
OutputPower(OUT_C, 3); //Sets the motor in port C to 3rd Power
Off(OUT_A); //Turns off motor in port A
Timer(n)
= RCX timer
Random(n)
= Starts a random timer, then proceeds with the program
Input(n)
= Reads the value of the sensor
InputType(n)
= Set Input type for sensor
InputMode(n)
= Set Input mode for sensor
On(OUT_B, 8);
Random(50); //Randomly turns off motor in output port B at 1 to 5 seconds
Off(OUT_B);
Program()
= Starts a program in a Program Slot
InputRaw(n)
= Reads the input value in Raw mode
InputBool(n)
= Reads the input value in Boolean mode
Watch()
= Return value of the system clock
Message()
= Return value of the last IR msg received
Program(2); //Starts program in Slot 2 of the RCX's memory
Wait(c)
= Tells the RCX to wait c seconds (1/10th of a second) then proceeds with the program
PlaySound(x)
= RCX plays one of the system sounds
[sounds]
PlayNote(f, d)
= RCX plays a note by specifiying frequency and duration (1/10th of a second)
Sleep(v)
= Tells program to halt for v seconds (1/10th of a second)
Display(v)
= Choose which display the RCX will bring up in its LCD
SendMessage(v)
= Send another RCX a number through IR
ClearMessage()
= Clear Message
Wait(20); //Program waits for 2 seconds
PlaySound(3); //Program then plays system sound 3
SetDatalog(v)
= Set the datalog size
Datalog(v)
= Add a point to the datalog
UploadDatalog(s, n)
= Upload datalog
IR_LO 0
= Sets IR range to short-range
IR_HI 1
= Sets IR range to long-range
IR_Mode(m)
= Set range
IR_Mode(IR_HI); //Sets IR Mode to Long-range
[sounds] Systems sounds (1-5) are numbered:
PlaySound(1);
= two short beeps PlaySound(2);
= a slow downward arpeggioPlaySound(3);
= a slow upward arpeggioPlaySound(4);
= a low buzzPlaySound(5);
= a fast upward arpeggio
Copyright 1999 © Murray Altheim. All Rights Reserved.
This page is based on Kevin Saddi's NQC Reference Page. Used with permission.
Last Updated: February 28, 1999