05-21-2013 01:22 PM
According to the help documentation in LabView 2011 "Printf (LabVIEW Manager Function)", the conversion character of 'q' is supposed to reference a point. The actual help text is "q Point (passed by value) as %d,%d representing horizontal, vertical coordinates". Is this a valid conversion character for LabView RT 2009? If so, then does anyone have an example of using these characters to print at row 10, column 1 on the console? I'm tried many combinations like: printf("%dqTest Row",(10,1)), etc.
Solved! Go to Solution.
05-21-2013 06:01 PM
LabVIEW Real-Time does not inherently have a "console" - it has an "output stream". There is no published API to allow you to jump around on the console natively (don't cross the streams) - you can't even do it with the LabVIEW Manager functions (it literally prints a dot in that pixel location, not text).
Now, I didn't tell you this, but if you happen to have a target with video memory (like a PXI system, definitely NOT a cRIO or cFP) and you happen to know the address of where video memory sits on your system <cough> 0x0B8000 </cough>, you can directly write ascii characters to specific areas on the screen - just like they did back in the DOS days.
#include <iostream> #include <windows.h> void VGAChar(unsigned int row, unsigned int col, char c, unsigned char attr) { static volatile char *video_mem = (char *)0x0B8000; unsigned int pos = ((row * 80) + col)*2; video_mem[pos] = c; video_mem[pos+1] = attr; } void VGAString( unsigned int row, unsigned int col, char * str, unsigned char attr) { int i = 0; while (str[i] != '\0') { VGAChar(row+(col+i)/80, (col+i)%80, str[i], attr); /* print each character */ i++; } } int main (void) { char buffer[ 100 ]; sprintf( buffer, "Hello, my DOS world!" ); VGAString( 10, 10, buffer, FOREGROUND_BLUE | FOREGROUND_RED ); // prints in PURPLE at ROW 10, COL 10. return 0; }
Of course I don't condone this, and it's definitely NOT supported (and only works on PharLap-based targets with a video console), but it IS a lot of fun. 🙂
-Danny