#!/usr/bin/Rscript options(warn = -1) gfisnum=0 gdisplaystr="" gbinop="+" gax=0 gbx=1 MAXDISP=24 acolor = c(2628095,1015567,986895,12632256) kbdchars = c("Off","C"," 0 ) { if ( nchar(gdisplaystr) == 1 ) { displaystr( "0", 6052991 ) } gdisplaystr<<-substring(gdisplaystr,2,nchar(gdisplaystr)-1) if ( nchar( gdisplaystr ) > 0 ) { displaystr( gdisplaystr, 6052991 ) } } } else if ( (rowcol == 18 ) & ( nchar( gdisplaystr ) > 0 ) ) { if ( gdisplaystr[1] == "-" ) { gdisplaystr<<-substring(gdisplaystr,2,nchar(gdisplaystr)) } else if ( nchar(gdisplaystr) < ( MAXDISP - 1 ) ) { gdisplaystr <<- paste("-",gdisplaystr,sep="") } displaystr( gdisplaystr, 6052991 ) } else if ( ( rowcol == 3) | (rowcol == 7) | ( rowcol == 11) | ( rowcol == 15 ) ) { gbinop <<- kbdchars[rowcol+1] gax <<- as.numeric(gdisplaystr) gfisnum <<- 0 } else if ( rowcol == 19 ) { if ( gfisnum ) { gbx <<- as.numeric(gdisplaystr); gfisnum <<- 0 } if ( gbinop == "*" ) { gax <<- gax * gbx } else if ( gbinop == "/" ) { gax <<- gax / gbx } else if ( gbinop == "+" ) { gax <<- gax + gbx } else if (gbinop == "-" ) { gax <<- gax - gbx } gdisplaystr <<- paste( gax, sep="" ) displaystr( gdisplaystr, 6052991 ) } } input<-file('stdin','r') while ( length(aline <- readLines(input,n = 1) ) > 0 ) { line <- aline[[1]] if ( line == "drawapp" ) { writeLines("Fo 0 611 3\nFo 1 400 3\nFo 2 140 3\n",sep="",stdout()) writeLines("F 0 16777215\nFR 0 0 0 10000 10000\n",sep="",stdout());displaystr( "0", 6052991 ) writeLines("B 0 12632256",stdout()) for (i in 1:length(kbdcolor)-1) { writeLines( paste("F 0 10526880\nFR 0 ",(i%%4)*2000+220," ",floor(i/4)*1200+1220," ",(i%%4)*2000+2080," ",floor(i/4)*1200+2280,sep=""),stdout()) writeLines( paste("F 0 986895\nR 0 ",(i%%4)*2000+200," ",floor(i/4)*1200+1200," ",(i%%4)*2000+2100," ",floor(i/4)*1200+2300,sep=""),stdout()) writeLines( paste("F 0 ",kbdcolor[i+1],sep=""),stdout()) writeLines( paste("C$ 0 ",(i%%4)*2000+1100," ",floor(i/4)*1200+1700,'"',kbdchars[i+1],'"',sep=""),stdout()) } writeLines( 'F 1 16711935\nL$ 1 20 924"Rscript cloud app transpnt shell stdio"',stdout()) writeLines( 'F 2 255',stdout() ) writeLines( 'C$ 2 5000 7200"Corrie Zucker Technologies LLC."',stdout()) writeLines( 'C$ 2 5000 7340"d/b/a CZ Technologies"',stdout()) writeLines('Z ',stdout()) } else if ( line == "QUERY_REMOTE" ) { writeLines( "Rz 1200 900\nZ ",stdout()) Sys.sleep(0.824) } else { buttonxy = unlist(strsplit(line," ")) button = as.numeric(buttonxy[1]) x = as.numeric(buttonxy[2]) y = as.numeric(buttonxy[3]) if (is.numeric(x) && length(x) == 1 && !is.na(x)) { if ( x >= 0 ) { row = floor((y-1200)/1200); col = floor((x-200)/2000) if ( ( row >= 0 ) & ( row < 5 ) & ( col >= 0 ) & ( col < 4 ) ) { keytoexe(row*4+col) } } else if ( x == -2 ) { keytoexe( chartorowcol[chartorowcol$char %in% button,]$rowcol ) } else if ( x == -4 ) { writeLines( paste("Rz ",button," ",y,sep=""),stdout()) } else if ( x == -5 ) { writeLines( paste("Mv ",button," ",y,sep=""),stdout()) } else if ( x == -98 ) { Sys.sleep(0.0024*y) } } } }