Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert from VB
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00719715
Message ID:
00720268
Views:
14
Hi Jose

Thanks for the code.

I am also having trouble using the Logger_File_Upload and was wondering if you have any ideas why it won't work.


Here's the VB code
Public Type TagloggerFile
  filename(1 To 13) As Byte
  filelength As Long
End Type

Declare Function Logger_FileUpload Lib "Taglogger.dll" (ByRef filename As TagloggerFile, ByVal data As String) As Long



Dim file As TagloggerFile
  Dim data As String * 50000
  Dim filename As String
  Dim k As Integer
  Dim filedata As String
  Dim status As Long
    
    
  'Name and contents of the file to be uploaded to the Taglogger
  filename = "dlltest.txt"
  filedata = "This is a test of the Logger_FileUpload function."
  
  
  'Convert string to array of bytes padded with nullbytes
  For k = 1 To 13
    If k <= Len(filename) Then
      file.filename(k) = Asc(Mid(filename, k, 1))
     MsgBox (Asc(Mid(filename, k, 1)))
    Else
      file.filename(k) = 0
    End If
  Next
  
  file.filelength = Len(filedata)
  
  data = filedata
  
  status = Logger_FileUpload(file, data)



* Here is the document that goes with the DLL

3.7 Logger_FileUpload
int Logger_FileUpload( TAGLOGGERFILE *Filename, char *Data )
Description:
This function loads a file to the tagLogger. If a file with this
name already exists on the tagLogger, it wil automatically be
overwritten. Files are transfered at a speed of approximately
2kB/s, so it can take some time before uploading is completed
if the file is quite large.
Inputs:
FileName FileName is a pointer to a structure of the type
TAGLOGGERFILE
typedef struct
{
char name[13];
unsigned long filelength;
} TAGLOGGERFILE;
The filename will be in the MSDOS format
(“filename.ext\0”).
Data Data is a pointer to a string containing the file
data.
Outputs:
NONE
Return value:
1 OK
-3 Error, No connection with tagLogger established
-4 Error, Time-out on tagLogger request
-5 Error, Transmission error.
-6 Error, Illegal filename
Note:
The filename-format is “<name>.<ext>” where <name> should
have between 1 and 8 characters, and <ext> between 1 and 3.
The only characters allowed are A..Z, a..z and 0..9. All
lowercase characters will be automatically converted to
uppercase.
Thanks

John


>This should do it.
>Of course I cannot test it without the DLL, so you may have to debug it.
>
>
>
>Function FileDownload( lcFileName)
>	Declare Long Logger_FileDownload in "Taglogger.dll" String @ FileNameStruct, String @ Data
>
>	Local lcFileStruc && file name structure as defined for TAGLOGGERFILE
>	Local lcData  && buffer to hold file contents
>	Local lnStatus && return status
>	Local lnSize
>
>	lcFileStruc = Alltrim(lcFileName)+Chr(0) && "name.ext"+null char
>	lcFileStruc = Padr(lcFileStruc,13,Chr(0)) && padded to 13 bytes long
>	lcFileStruc = lcFileStruc + Replicate(Chr(0),4) && to get returned file size
>	lcData = Space(50000) && max. file length, you may change this
>	
>	lnStatus = Logger_FileDownload( @lcFileStruc, @lcData)
>	
>	If lnStatus = 1
>		lnSize = Asc(Substr(lcFileStruc,14)) ;
>			+ Asc(Substr(lcFileStruc,15))*0x100;
>			+ Asc(Substr(lcFileStruc,16))*0x10000;
>			+ Asc(Substr(lcFileStruc,17))*0x1000000   && double word from string
>	
>		MessageBox("File content is:"+Chr(13)+Left(lcData, lnSize),64,"Success")
>	Else
>		MessageBox("Error status returned: "+Transform(lnStatus),48,"Failed")
>	EndIf
>	
>EndFunc
>
>
>Regards,
>Jose.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform