Here is how I usually do it
if(KeyBoard & ~KeyBoard) {String += toChar(KeyBoard)}
S:writeString(String,0,2,90)
Although I know how console screens work, I failed at every attempt to make them work. Either there would be extra spaces, or double characters, or XY of the char randomly changing, or nothing displaying, or even my text appearing backwards!
I know this isn't a place where people would do your work for you, but could someone please show me the right way to make an expression2 connecting a keyboard and a console screen? So that what you type appears on the screen, rows automatically change, enter and backspace keys work as intended?
Here is how I usually do it
if(KeyBoard & ~KeyBoard) {String += toChar(KeyBoard)}
S:writeString(String,0,2,90)
Last edited by SpectreCat; 07-09-2009 at 09:38 PM.
New to the E2? Try my Tutorial:
A Beginners Guide to Expression 2
***Please send a PM before you add me to friends***
That always adds spaces between the characters whenever I do that.
:|
This is what I basically use. It uses memory cells, and only writes if it's a writable character (127 > writable chars > 31). Also if you write to the second to last line, it scrolls the text upwards. I have not taken enter and backspace into account here, I just posted this example to give you the general idea of how it's usually done. This is not tested, but it should work.Code:S:writeCell(Cell+1,1000999) if(~Mem&Mem&Mem<127&Mem>31){ S:writeCell(Cell,Mem) S:writeCell(Cell+1,999) Cell+=2 if(Cell>=958){ S:writeCell(2038,1) S:writeCell(2046,1) Cell = 900 } }
"If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
-- Niels Bohr
Wire FPGA


Here's mine. It allows you to backspace, enter, and hold down keys.
Code:@name Console Screen Writer, by -HP- @inputs Keyboard Scr:wirelink @persist String:string X Y LineLength:array Timer:string if (first()) { X = 0 Y = 0 Scr:setNumber("Clk",1) Scr:setNumber("Reset",1) LineLength = array() } if (clk(toChar(Keyboard))) { timer(toChar(Keyboard),100) Timer = toChar(Keyboard) } elseif (~Keyboard) { stoptimer(Timer) timer(toChar(Keyboard),500) Timer = toChar(Keyboard) } if (clk(toChar(Keyboard)) | ~Keyboard) { if (Keyboard >= 32 & Keyboard <= 126) { if (X == 29 & Y == 17) { exit() } Scr:writeString(toChar(Keyboard),X,Y) X++ LineLength:setNumber(Y,X) if (X == 30) { Scr:writeString(" ",X,Y,0,0,0) X = 0 Y++ } String = String + toChar(Keyboard) } if (Keyboard == 13) { Scr:writeString(" ",X,Y,0,0,0) Y++ X = 0 String = String + " " } if (Keyboard == 127) { Scr:writeString(" ",X,Y) if (X == 0 & Y > 0) { Y-- X = LineLength:number(Y) } elseif (X > 0) { X-- LineLength:setNumber(Y,X) } Scr:writeString(" ",X,Y) String = String:sub(1,String:length()-1) } } Scr:writeString(" ",X,Y,999,0,1)
Hy, a simple example
Code:@name Console screen simple @inputs Button @outputs @persist @trigger all runOnTick(1) if(Button){Screen:writeString("Hello world!",1,0,999)}
Ps: Screen:writeString("..Text.."),Enable/Disable (1/0),Line,color
good bye![]()
Last edited by warrior08; 07-10-2009 at 05:50 AM.


Warrior fails extremly :P Also what the heck is that memory thing? -.-
Hurr
Bookmarks