User functions on NT

Post Reply
sabety
Posts: 76
Joined: Wed Dec 06, 2000 7:11 am

User functions on NT

Post by sabety »

I want to write a user function for vortex that reads and writes binary files. I read that I need to create a new texis by re-compiling the vufunc.c file etc etc. I am extremely hesitant to mess around with my texis executable in the off-chance that my c function is, ahem, not bulletproof...

so my questions are: can the function's interaction with vortex be tested before changing texis? Can I go back to the older version of texis by recompiling without the new function later? Which compiler to use? I have Borland C Builder for NT. Can this even be done on NT?
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

User functions on NT

Post by John »

There are already the <read> and <write> functions in vortex that handle binary files.

Saving a copy of the original texis.exe would be the safest plan for a fall back. You should be able to add user functions with NT. We haven't tried the Borland compiler, but Microsoft Visual C should work.
John Turnbull
Thunderstone Software
sabety
Posts: 76
Joined: Wed Dec 06, 2000 7:11 am

User functions on NT

Post by sabety »

Sounds like it might be safer to just write a separate C app that gets called by vortex. Since this is for dev use, don't really care about the extra overhead.

Say if I wanted to record some data as a binary file how would I go about it using <WRITE>? If in C I would have code like this to write a binary file:

FILE *fp;
fp=fopen("c:\\fp.dat", w+b);
char ps[10]="charly1234";
fwrite(ps, sizeof(ps[0]), sizeof(ps)/sizeof(ps[0]), fp);
fclose(fp);
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

User functions on NT

Post by John »

Similar code in Vortex would be:

<$ps="charly1234">
<WRITE "c:\fp.dat"><fmt %s $ps></WRITE>

The <fmt %s> prevents any HTML escapement or problems with binary data in $ps.
John Turnbull
Thunderstone Software
sabety
Posts: 76
Joined: Wed Dec 06, 2000 7:11 am

User functions on NT

Post by sabety »

Neat.

Are there any gotchas for appending multiple values to this file? I would use the APPEND flag, but can I insert new values at any point in the structure? I guess what I am asking is whether a pointer type facility can be used to move around within the file at some later stage?

Also, the $ps array can contain values of different sizes, right?
In a later read, how can I be certain what offsets to use to get the correct values back. fread requires prior knowledge of array element sizes and the number of elements, and can get those using sizeof, but in this case it is not guaranteed, correct?

Can I use <varinfo size> to get this information?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

User functions on NT

Post by mark »

<write> will always either replace the entire file or append to the end whatever data you supply regardless of size. You can't seek and overwrite data in the middle. <read> will allow you to read arbitrary lengths at arbitrary offsets (seek). It's raw bytewise file io, there's no notion of records. It is not intended as a substitute for database like info. See "create table" for that.
Post Reply