10-24-2012 04:09 AM
my code is like this (shortened):
#include <cvirte.h> #include <userint.h> #include "word97.h" #include <formatio.h> #include "toolbox.h" #include <utility.h> #include <Data Types.h> #include "Function Prototypes.h" #include "Globals.h" #include GUI_HEADER #include <stdio.h
some code above ( not relevant)
ErrChk (Word_SelectionTypeText (currSelHandle, NULL, "<Esc>[7A] ...some text.."));
some code bellow (not relevant)
and it works (move 7 spaces up) but then it also types <Esc>[7A] which i dont want it to, i just want it to move 7 cursor lines up and then not type my code. i have tried it above (bellow this text) but then it comes up with 10 errors and really doesnt like it. im wondering if there is a thing like cout or echo for cvi. another problem is that im using a very old version of cvi, cvi6.0. Plus if there is any other way to move it up 7 lines then im willing to hear it , or to delete 7 line (but i doubt you can delete it as no-one has any idea how)
some code above ( not relevant)
<Esc>[7A] ErrChk (Word_SelectionTypeText (currSelHandle, NULL, "...some text.."));
some code bellow (not relevant)
thanks for any help, it could be pretty easy i dont know as im new to CVI, but i have done programming here and there on assembler and C++.
lewis
10-25-2012 06:36 AM
Hi Lewis,
Welcome to the NI discussion forums.
It's difficult to analyse this code because I don't have access to the particular functions or header files you are trying to call. Is there a way you can provide me with the full project so that I can see what you are trying to do?
For now I have assumed that the escape charactor you're trying to send is 7A in hex, have you tried replacing <ESC>[7A] with \x7a ?
10-25-2012 08:34 AM
its very long (like 1200 lines is the biggest file and there are 12 files all different sizes if you want them all) as its a front end sytem with lots of different calculations and things in. My friend said "seeing as your doing a hnc in electronics program try to figue this out" and well i have got rid of about 10/11 other errors but this one is abit more confusing as the obvious doesnt work and nether does the difficuilt, but basically it imports a word document onto a new one , imports a table and then adds more lines unerneth it.
The problem occurs that it is too long by a line but there are 7 spaces that i can get rid of this is because the table is 8 colloms wide and doesnt stop when it ends it goes on another 8 times (thinking there are more rows when there arnt). This is why im trying to delete some lines or go up a few lines
also the hex code didnt work it just imputed a ":" and that was it, it didnt go up any lines. Is there a code like "cout ("\b")" or something like that for cvi?
Finally the headers dont really do anything except define things and input different calculations / set up that dont relate to this little bit of code
thanks for looking into this,
lewis
10-25-2012 10:31 AM
Apologies, I only really needed the code to understand the function and to test any of my suggestions. It's very strange that the function performs the escape sequence action (<ESC> is the escape sequence character) and then prints it out as text as well. I previously hadn't acknowledged that the [7A instruction was to place the cursor upwards. What happens if you do not include the extra "]".
You're writing in the C language, so \b should be a non-destructive backspace character inside a string.
10-26-2012 02:06 AM
the strange thing is that the \b doesnt work at all it just prints an unknown symbol (looks like a card with a dimond in the middle) but then /n and /t work as i have tried them allready.
and i know esc is an escape sequance character that why i didnt understand why it printer it ether, but i tried it with out the bracket and it still prints "<ESC>[7A ..... somewords..." so that doesnt work ether sorry. is there a different way you know that will work with cvi 6 that deletes 4/5/6/7 lines or moves up 4/5/6/7 lines? it could be a string or anything (im willing to try alot to make it work)
any solutions will be greatfull, and thanks ben for trying to sort this out for me,
lewis
10-26-2012 05:32 AM - edited 10-26-2012 05:33 AM
Hi Lewis,
It seems that I don't have access to the word97 header so I apologise if this seems very hit and miss.
I've read up on it and there also seems to be a function that allows you to move up the selection, try playing around with the Word_SelectionMoveUP function. Prototyped as
HRESULT CVIFUNC Word_SelectionMoveUp (CAObjHandle objectHandle, ERRORINFO *errorInfo, VARIANT unit, VARIANT count, VARIANT extend, long *returnValue);
For example putting the following above your Word_SelectionTypeText() function and removing the escape sequence might work:
ErrChk(Word_SelectionMoveUp (curSelHandle, NULL, CA_DEFAULT_VAL, CA_VariantLong(7), CA_DEFAULT_VAL, NULL)); /*Defaults to "line" units, and "extend mode" to "move"*/
If you're still having no luck then it may be better if you sent me everything, so that I can have a good idea about what else is going on in the code and I can try a few things for myself.