[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

HASHNUMS Update



PureBytes Links

Trading Reference Links

For those of you using HASHNUMS.DLL the following
updated information will help you build C/C++ and
Visual Basic programs that can communicate
with Tradestation. Appologies to Omega-List people
that are not interested, but this is the best way for
users to get updates....For details on HASHNUMS and
some of our new products see:

Quality Trading Innovation
qtrade@xxxxxxxxxxxxxx
www.ozemail.com.au/~qtrade


This updates vbc.txt:
-------------------------------------------------------------------------------
This document describes the Visual basic and C Interface
for HASHNUMS.DLL. This information is provided for the
sophisticated user as an extra feature. It does not form
part of the core product but allows you own programs to
work with Tradestaton.

This interface document will help you to write programs
in C/C++ or Visual Basic that use the DLL to communicate with
Tradestation Easylanguage. Excel also uses VB (Visual Basic)
as a programming langauge and the following information 
applies to it also.

Please refer to the appropriate language documentation
for using DLL's. I cannot provide any support for doing 
this. Using DLL's in this manner requires a certain level
of programming experience and the wrong usage may 
detrimentally affect your system.

Please note that this is a 16-Bit Dll, as Tradestation
is a 16-Bit program. You will have to use the
appropriate 16 Bit programming languages/application.

The C Interface definitions
---------------------------

int	FAR PASCAL _export openWriteCSV(LPSTR object,LPSTR fileName, int append); 
int 	FAR PASCAL _export openReadCSV(LPSTR object, LPSTR fileName);    
int	FAR PASCAL _export openWriteReadCSV(LPSTR object,LPSTR fileName, int append); 

int 	FAR PASCAL _export putAtDef(LPSTR attribute, float value);
int 	FAR PASCAL _export putAt(LPSTR object, LPSTR attribute, float value);
int 	FAR PASCAL _export putAtPrec(LPSTR object, LPSTR attribute, float value, int precision);	  
float	FAR PASCAL _export getAt(LPSTR object, LPSTR attribute);  
float	FAR PASCAL _export getAtDef(LPSTR attribute); 
                                                                                                                 
int 	FAR PASCAL _export putStringAt(LPSTR object, LPSTR attribute, LPSTR text); 
int 	FAR PASCAL _export putStringAtDef(LPSTR attribute, LPSTR text); 
LPSTR 	FAR PASCAL _export getStringAt(LPSTR object, LPSTR attribute);  
LPSTR 	FAR PASCAL _export getStringAtDef(LPSTR attribute);    

int 	FAR PASCAL _export putNoDef(LONG index, float value);
int 	FAR PASCAL _export putNo(LPSTR object,LONG index, float value);
int 	FAR PASCAL _export putNoPrec(LPSTR object, LONG index, float value, int precision);	  
float	FAR PASCAL _export getNo(LPSTR object, LONG index);  
float	FAR PASCAL _export getNoDef(LONG index);      

int	FAR PASCAL _export getTypeNo(LPSTR object, LONG index);      
int	FAR PASCAL _export getTypeAt(LPSTR object, LPSTR attribute);  
 
int 	FAR PASCAL _export putStringNo(LPSTR object, LONG index, LPSTR text); 
int 	FAR PASCAL _export putStringNoDef(LONG index, LPSTR text); 
LPSTR 	FAR PASCAL _export getStringNo(LPSTR object, LONG index);  
LPSTR 	FAR PASCAL _export getStringNoDef(LONG index);   
    
int	FAR PASCAL _export appendCSV(LPSTR object); 
int	FAR PASCAL _export appendDefCSV(void);     
 
int	FAR PASCAL _export setDefObj(LPSTR object); 
void	FAR PASCAL _export setDefPrec(int precision); 
void	FAR PASCAL _export setMissing(float value);
void	FAR PASCAL _export setCrLf(int value);    
float	FAR PASCAL _export cleanUp(void);   
      
int 	FAR PASCAL _export readNextCSV(LPSTR object); 
int 	FAR PASCAL _export readNextDefCSV(void);
int 	FAR PASCAL _export readLineCSV(LPSTR object, LONG LineNumb);   
int 	FAR PASCAL _export readLineDefCSV(LONG LineNumb); 
int 	FAR PASCAL _export readLastCSV(LPSTR object, LONG LineNumb); 
int 	FAR PASCAL _export readLastDefCSV(LONG LineNumb);    


Notes on above
---------------

The values passed to and returned to these functions are the
same as described in the HASHNUMS manual. HASHNUMS is written in
C and so the above provides the definitive interface description.
For alternate languages, eg EasyLanguage and Visual basic, the 
above are just translated. 

In your "C" or C++ program you will not need the _export in your
prototypes. To stop name mangling in C++ compilers you must wrap
the prototypes in extern "C" {...}. See code below.

The functions that return a string pointer (ie getStringAt)
should copy the contents of the string locally. See the use of
buffer below.

The example program below was compiled in 16 Bit Visual C++ 1.52.
The program is a QuickWin Executable. The following section
describes the DEF file, the C code and the output. After
running the program run hashtest.exe and you can see the values
entered from the code below.

-------------------------------------------------------------
                  THING.DEF
-------------------------------------------------------------
NAME		THING
DESCRIPTION    'test my ddl code'
EXETYPE        WINDOWS 3.1
CODE		PRELOAD MOVEABLE DISCARDABLE
DATA		PRELOAD MOVEABLE SINGLE
HEAPSIZE	4096        
STACKSIZE	8192
IMPORTS		hashnums.PUTAT         
		hashnums.CLEANUP     
		hashnums.getat    
		hashnums.putStringAt
  		hashnums.getStringAt
		hashnums.putStringNo  
		hashnums.getStringNo
-------------------------------------------------------------
                  THING.CPP
-------------------------------------------------------------
#include <windows.h>      
#include <windowsx.h> 
#include <io.h>
#include <ctype.h> 
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

extern "C" {
int 	FAR PASCAL putAt(LPSTR object, LPSTR attribute, float value); 
float	FAR PASCAL getAt(LPSTR object, LPSTR attribute);  
int 	FAR PASCAL putStringAt(LPSTR object, LPSTR attribute, LPSTR text);
LPSTR 	FAR PASCAL getStringAt(LPSTR object, LPSTR attribute);    
int 	FAR PASCAL putStringNo(LPSTR object, LONG index, LPSTR text);
LPSTR 	FAR PASCAL getStringNo(LPSTR object, LONG index);
float	FAR PASCAL cleanUp(void);   
}           
           
           
void main(void)
{               
char	buffer[100];

      cleanUp();       
      putAt("Person", "age", 1.111);  
      putAt("Person", "height", 2.222);     
      
      printf("Age: %f\n",getAt("Person", "age"));  
      printf("Height: %f\n\n",getAt("Person", "height"));    
      
      printf("PutStringAt OK: %d\n",putStringAt("Thing","message","hello"));
      lstrcpy(buffer,getStringAt("Thing","message")); 
      printf("Message: %s\n\n", buffer);
      
      printf("PutStringNo OK: %d\n",putStringNo("Something",99,"Ninety Nine"));
      
      lstrcpy(buffer,getStringNo("Something",99));     
      printf("99: %s\n", buffer);
}
-------------------------------------------------------
                  OUTPUT
-------------------------------------------------------
Age: 1.111000      
Height: 2.222000   
                  
PutStringAt OK: 1  
Message: hello     
                  
PutStringNo OK: 1  
99: Ninety Nine    
-------------------------------------------------------




Visual basic version of String returning function
==================================================
The functions above that return an LPSTR cannot be used with
Visual Basic. Instead a String has to be passed as an argument.
You must provide an appropriate buffer to hold the returned
value, eg use String(255,0), to fill a string buffer with nulls
in Visual Basic(see example below). Pass this as the last argument
to get the returned string value. The C prototypes for these
functions are:

int 	FAR PASCAL _export getStrAt(LPSTR object, LPSTR attribute, LPSTR string);  
int 	FAR PASCAL _export getStrAtDef(LPSTR attribute, LPSTR string);   
int 	FAR PASCAL _export getStrNo(LPSTR object, LONG index, LPSTR string);  
int 	FAR PASCAL _export getStrNoDef(LONG index, LPSTR string);


These functions replace:
	getStringAt
	getStringAtDef
	getStringNo
	getStringNoDef


Example Visual Basic Declarations
---------------------------------
The Visual Basic declarations are similar to those described
for Tradestation (except the string returning ones) in the
HASHNUMS manual. The following shows how to declare the
majority of them in Visual basic:

Declare Function putAt Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As String, ByVal myvalue!) As Integer
Declare Function putAtPrec Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As String, ByVal myvalue!, ByVal prec%) As Integer
Declare Function getAt Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As String) As Single

Declare Function putStringAt Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As String, ByVal myStr As String) As Integer
Declare Function getStrAt Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As String, ByVal myStr As String) As Integer

Declare Function putNo Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As Long, ByVal myvalue!) As Integer
Declare Function putNoPrec Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As Long, ByVal myvalue!, ByVal prec%) As Integer
Declare Function getNo Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As Long) As Single

Declare Function putStringNo Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As Long, ByVal myStr As String) As Integer
Declare Function getStrNo Lib "hashnums.dll" (ByVal myobj As String, ByVal myatt As Long, ByVal myStr As String) As Integer

Declare Function cleanUp Lib "hashnums.dll" () As Single
Declare Function openReadCSV Lib "hashnums.dll" (ByVal myobj As String, ByVal fname As String) As Integer
Declare Function openWriteCSV Lib "hashnums.dll" (ByVal myobj As String, ByVal fname As String, ByVal appd As Integer) As Integer
Declare Function appendCSV Lib "hashnums.dll" (ByVal myobj As String) As Integer
Declare Function readNextCSV Lib "hashnums.dll" (ByVal myobj As String) As Integer
Declare Function readLineCSV Lib "hashnums.dll" (ByVal myobj As String, ByVal myline As Long) As Integer


Some example lines of VB code....
---------------------------------
The following are fragments of VB code to interface to the DLL.
In the examples x% will be the returned value as either 1 or 0 to check
if the function worked or not.

To put a float value 203.56 with precision of 2:
	x% = putAtPrec("MyObject", "MyAttribute", 203.56, 2) 

To put a string value "HELLO KIM" at attribute:
 	x% = putStringAt("MyObject", "MyAttribute", "HELLO KIM")   

To put a FLOAT value 203.45 at attribute:
	putAt("MyObject", "MyAttribute", 203.45 )  

To get a string attribute you need to give VB a buffer to place
the returned string:

	Dim buff As String
	buff = String(255, 0)

	x% = getStrAt("MyObject", "MyAttribute", buff)

To get a string from an index attribute at 10. Need
a buffer as above:
	x% = getStrNo(ObjIndexText.Text, 10, buff)

To get a float value from a string attribute:
	getAt(ObjAttText.Text, AttText.Text)

To get a float value from a numeric index at 10:

	getNo("MyObject", 10)  

To open a file for writing:
	x% = openWriteCSV("MyObject", "C:\myfile.csv", 0)  

To append current object to file:
	x% = appendCSV("MyObject")

To open a file for reading:
	x% = openReadCSV("MyObject", "C:\myfile.csv")