PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Record and play back (stylus)?

Just wondering if you can record the movements of the stylus when writing, to an external file to play back at a later date? or is this impossible with Gapidraw?

If so, what version can it be done in and any clues on how to do it?

If not, thanks for your time
You have to program the functionality yourself, as you would with any other graphical API.
I want to do the same functionality but I dont know how. I've got the recordings of the stylus points (previous and present) in StylusMove so i just need these points sent out to a new file just created within but i dont know how to achieve this.

Can anyone direct me into the right direction or has anyone done this kind of thing before?

And how can you read from this file with these recordings in the future to re-draw with these points i.e. take in a point every 4 frames so it looks like an animation

any help would be appreciated
Jonny

(i just need to show that i have attempted to do this for my project, or know how to do it for future development of my project)
You need to read up on something called "file i/o" (input/output). You want to use a text format, reading and writing numbers as strings.

As a simple example, suppose you output your data as text containing the x y coordinates:

Code:

12 345
67 890
...


Then later you input that data and redraw those coordinates. Something like that.
thanks for that

I think i can do this now. Ive looked up help files and it says to use CreateFile, WriteFile and ReadFile is this the way to go?
I've got it creating a file but im confused on how to write to it.

ive got coordinates to write to this file the previous x & y and present x & y, these will change every time the user moves the stylus so will the file stay open and these future coordinates add on to the end of the file until i program to close it or will it overwrite these?

thanks
If you keep the file open you can repeatedly write to the file and it will append to the end of the file.
thanks for that mlepage.

Just wondering how to write to the opened file with writeFile?

WriteFile(
HANDLE hFile,
LPCVOID lpBuffer,
DWORD nNumberOfBytesToWrite,
LPDWORD lpNumberOfBytesWritten,
LPOVERLAPPED lpOverlapped
);

ive got two numbers to send to file and i dont know how to add these to the buffer within the writeFile, can anyone help?

when i write to file is the number of bytes be two or four for 'nNumberOfBytesToWrite'

This method is complicated on how to do

Thanks
Jonny
hi every1,

im trying to send 2 variables (LastStylusPosition.x + LastSylusPosition.y) to file, first i create file named u.txt and want to send MyMessage to file but i dont know how to send these two numbers together

Code:
hFile = CreateFile(TEXT("\\U.TXT"),GENERIC_WRITE|GENERIC_READ,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

MyMessage = LastStylusPosition.x && LastStylusPosition.y;

WriteFile(hFile,MyMessage,4,4,NULL);


the above code brings back the following

error C2664: 'WriteFile' : cannot convert parameter 2 from 'unsigned long' to 'const void *'

i need a space between these two numbers as well and im not sure if the above will do this

Can anyone pls advise

Jonny
When you read up on file IO, ignore anything about binary IO and focus on text IO.

What you are coding above is binary IO, which even if you coded properly, isn't what you want.

Try searching for fprintf since it will do what you want. You'll probably want the generic text versions of this and related functions.

Code:

FILE* pFile = _tfopen(_T("FILE.TXT"), _T("w"));
_ftprintf(pFile, _T("%d %d\n"), num1, num2);
fclose(pFile);
Thanks mlepage,

This worked fine. I just have to work out how to read these coordinates in again to redraw (not knowing the actual number of coordinates used), I think I know how. I looked at the function fscanf, is this the best one to use or is there a better one?

Thanks again for your help its very much appreciated

Jonny
Yes you will use fscanf. Discover the "generic text" version of this function. (This is because the Pocket PC uses wide characters, incidentally.) Read the documentation and be sure you get your format string and parameters correct.