forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


binary value

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
X-Tools
Valued Contributor
Valued Contributor


Joined: 20 Sep 2001
Posts: 296
Location: Germany

PostPosted: Wed Aug 13, 2003 4:24 pm    Post subject: binary value Reply with quote

Hi,

I saw that vds5 has more functions for binary variables, so I want to ask
a older problem I had.

I want to upload a document into a database as text (same as binary in php), but not binary or hex in vds, because this needs too much space in the database.

My old problem was, that vds removed all null-characters in the variable so the document was damaged. how can I prevent this with the new functions ?

I want to use a mysql query.

Thank you.

Bye, Fabian
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Wed Aug 13, 2003 5:11 pm    Post subject: Reply with quote

Honestly I don't know how exactly php works but if the space character is being removed by VDS you can replace space by @CHR(32) .
Of course if the same text file is read by both VDS and php simultaneously rather than VDS writing to the text and then php reading it then it won't work.

If CRLF (Carriage Return Line Feed) is being removed you can probably substitute using its hex value using binary file write. I don't know exact details though.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Rebel49
Contributor
Contributor


Joined: 23 Aug 2002
Posts: 78
Location: Nova Scotia, Canada

PostPosted: Wed Aug 13, 2003 10:15 pm    Post subject: Reply with quote

Hi Fabian


The null character has been a bug-a-boo for me as well. I wanted
to use VDS for SNMP work (SIMPLE NETWORK MANAGEMENT PROTOCOL)
but the snmp packets inherently contain null characters. So I could not
get it to work with VDS 4. Eventually my solution was to use a third party freeware snmp polling engine then use VDS to process and display the resulting data and the results were good.
I was hoping VDS 5 and its more powerful commands and functions would perhaps solve this dillema. So far no joy! Hopefully there is a way.

I must state at this point my euthiasism for VDS 5 has been somewhat tempered by the lack of clear examples and help files on the commands and functions. I purchased 4.5 last fall and was ready to purchase
5 at its release but I need help understanding these new functions and I feel it just not there! So I am holding off.

I am still hopeful for the first patch.

Hope you get a solution

REB

_________________
OLD and eager!
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Aug 14, 2003 6:17 pm    Post subject: Re: binary value Reply with quote

X-Tools wrote:
Hi,

I saw that vds5 has more functions for binary variables, so I want to ask
a older problem I had.

I want to upload a document into a database as text (same as binary in php), but not binary or hex in vds, because this needs too much space in the database.

My old problem was, that vds removed all null-characters in the variable so the document was damaged. how can I prevent this with the new functions ?

I want to use a mysql query.

Thank you.

Bye, Fabian


Hi Fabian,
Have you tried recompiling your source code with VDS 5. Do not make any modifications. I have found that VDS 5 will store what ever character you want in a variable. The only problem that I can see is that when you submit the file's data to the VDS dll function that the function or command may not handle the data properly because VDS uses the NULL character as a delimiter between parameters/arguments of a VDS DLL's command/function. This means that when the VDS DLL parses it parameters for a command or arguments for a function it will see the NULL character as a delimiter and will treat anything after that NULL character as the next parameter/argument.
Now for a work around until the developer of that DLL your using adds the ability to read a file directly... I have built a UUEncoder/UUDecoder VDS 5 Unit which will take any binary file and convert it to ASCII. I have also made it possible for the Encoder to use built-in compression so it will compress the file first then UUEncode the file. Then when you decode the UUEncoded file it will detect that the file was compressed and automagicly decompress the file. You can download the Unit and an example script/application from http://dragonsphere.vdsworld.com/VDSUUE.ZIP

If you have any questions your can private message me.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Aug 14, 2003 6:23 pm    Post subject: Reply with quote

Rebel49 wrote:
Hi Fabian


The null character has been a bug-a-boo for me as well. I wanted
to use VDS for SNMP work (SIMPLE NETWORK MANAGEMENT PROTOCOL)
but the snmp packets inherently contain null characters. So I could not
get it to work with VDS 4. Eventually my solution was to use a third party freeware snmp polling engine then use VDS to process and display the resulting data and the results were good.
I was hoping VDS 5 and its more powerful commands and functions would perhaps solve this dillema. So far no joy! Hopefully there is a way.

I must state at this point my euthiasism for VDS 5 has been somewhat tempered by the lack of clear examples and help files on the commands and functions. I purchased 4.5 last fall and was ready to purchase
5 at its release but I need help understanding these new functions and I feel it just not there! So I am holding off.

I am still hopeful for the first patch.

Hope you get a solution

REB


Hi Reb,
I am not sure if my UUEncoder will be of any help to you. I can not remember what DLL you were using to do SNMP. Anyway I would be interested in looking at some examples of your code with the DLL and not the 3rd party polling Engine... If I could see some examples I may be able to find ways around your issues too?

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Rebel49
Contributor
Contributor


Joined: 23 Aug 2002
Posts: 78
Location: Nova Scotia, Canada

PostPosted: Mon Aug 25, 2003 6:30 pm    Post subject: Reply with quote

Hi Mindpower;

Well it has been quite a while since I dabbled with that but I think
I found the code in question. It uses VDSIPP

Code:
REM INTERNET UDP-SERVER,ACTIVATE,<udp server>,<port>
REM INTERNET UDP-SERVER,CREATE,<udp server>
REM INTERNET UDP-SERVER,DEACTIVATE,<udp server>
REM INTERNET UDP-SERVER,DESTROY,<udp server>
REM INTERNET UDP-SERVER,NEW,<udp server>
REM INTERNET UDP-SERVER,SENDUSER,<udp server>,<user ip>,<user port>,<string>

REM INTERNET UDP,CREATE,<udp client>
REM INTERNET UDP,DESTROY,<udp client>
REM INTERNET UDP,NEW,<udp client>
REM INTERNET UDP,SEND,<udp client>,<string>
REM INTERNET UDP,SERVER,<udp client>,<hostname>,<port>
REM INTERNET UDP,THREADS,<udp client>,<state>
rem USE THIS SCRIPT WITH VDS 3.x ONLY.  IT WILL NOT WORK
rem WITH VDS 2.x.



  option scale,96
  option fieldsep,|
  option decimalsep,.
 rem  info You need to run the VDS 3 UDP-SERVER EXAMPLE.DSC with this demo!
  external vdsipp.dll,DEMO

REM ################################################################
REM          THIS DATA WILL ASSEMBLE A SNMP FRAME!
REM          BYTE BY BYTE INFO DETERMINED by ENGINEERS
REM          MANUAL ON SNMP     (FRAME CONSTRUCTION)
REM ################################################################

%A = @CHR(48)@CHR(39)@CHR(2)@CHR(1)@chr(0)@CHR(4)@CHR(6)@CHR(112)
%B = @CHR(117)@CHR(98)@CHR(108)@CHR(105)@CHR(99)@CHR(160)@CHR(26)@CHR(2)
%C = @CHR(2)@CHR(4)@CHR(210)@CHR(2)@CHR(1)@CHR(0)@CHR(2)@CHR(1)
%D = @CHR(0)@CHR(48)@CHR(14)@CHR(48)@CHR(12)@CHR(6)@CHR(8)@CHR(43)
%E = @CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(5)@CHR(0)@CHR(5)@CHR(0)

%%message = %A%B%C%D%E

REM %%MESSAGE NOW CONTAINS THE DESIRED FRAME INFO



title Udp (SNMP) Example
  DIALOG CREATE,Udp (SNMP) Example,70,117,302,276
  DIALOG ADD,LIST,LIST1,6,6,288,194
  DIALOG ADD,BUTTON,BUTTON1,238,8,286,24,Send SNMP Message
  DIALOG ADD,EDIT,EDIT1,208,6,288,19
  DIALOG SHOW
info SNMP Message Length is @len(%%message) characters!
  rem ** CREATE the UDP client and turn THREADS ON **
  INTERNET UDP,NEW,1
  INTERNET UDP,CREATE,1
  INTERNET UDP,ACTIVATE,1
 
  INTERNET UDP-SERVER,CREATE,1
  INTERNET UDP-SERVER,ACTIVATE,1
  INTERNET UDP,THREADS,1,ON
 
  rem ** Set the UDP server to connect to on port 8090 **
  INTERNET UDP,SERVER,1,localhost,8090
 
  dialog set,edit1,%%message

:evloop
  wait event
  goto @event()

:BUTTON1BUTTON
  rem ** Send a message to the UDP server **
  INTERNET UDP-SERVER,SENDUSER,1,142.67.22.23,161,%%message
 INTERNET UDP,SERVER,1,415H-SP2,161
 INTERNET UDP,SEND,1,%%MESSAGE
  list add,list1,Sent Message: @dlgtext(edit1)
goto evloop

:UDP1ONMESSAGE
  rem ** A message has been received from the UDP server **
  %A = @internet(udp,message,1)
  list add,list1,"---------------------------------------------------------"
  list add,list1,Return message: %A
  list add,list1," "
  list seek,list1,@pred(@count(list1))
goto evloop

:CLOSE
  rem ** Always destroy the client protocols before exiting
  rem your script, to prevent from errors and crashes **
  INTERNET UDP,DESTROY,1
exit



My approach was to assemble an SNMP message and send it out
while monitoring with a protocol/packet analyser. Indeed the method
seemed to work and the message was accurate as far as the first
NULL character. It was truncated beyond that.

I recieved a response from the HOST device but with an error
message something like "invalid SNMP frame"

I was hoping the @BINARY would be a way around this NULL
problem but hasnt happened yet! Crying or Very sad

Thanks for your interest.


REB

_________________
OLD and eager!
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Mon Aug 25, 2003 8:20 pm    Post subject: Reply with quote

Rebel49,
I can see why it is not working. Since the message has the null character in the binary data that you are sending to VDSIPP. All VDS DLL's use the NULL character as a delimeter to parse the command/function parameter/argument list. So the only other suggestion that I would have is for the developer of VDSIPP to use the address of the message/data instead of the actuall value of the message/data... Then you could use @Addr("%M") instead of the value of %%message....

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Rebel49
Contributor
Contributor


Joined: 23 Aug 2002
Posts: 78
Location: Nova Scotia, Canada

PostPosted: Tue Aug 26, 2003 12:03 am    Post subject: Reply with quote

Yeah, I have known for a long time the NULL as a delimiter
was the kiss of death to my code. Pointed out by Tommy
a while back.

But keep hoping for a way around it . Your ideas on it
are interesting indeed and I think I catch your drift.

In the meantime, Plan B is working prety darn well
and I will continue to keep my ear to the ground.

STUPID FLANDERS... I mean NULL.
Evil or Very Mad


REB

_________________
OLD and eager!
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Wed Aug 27, 2003 5:42 pm    Post subject: Reply with quote

I think I can come up with a solution for you Smile

First we're going to have to do some things in your code, for instance change all @chr(0) to ^NULL^, the vdsipp will find such values and replace them with the correct character 0 null teriminator and then pass on the correct information.

The vdsipp will also then return (if you use any function that returns a null character) any values with a null-terminator chr 0 with ^NULL^ within the returned text. This will require your code to then search for ^NULL^ and replace them with chr(0), note however VDS variables appear to be of String type, if they were of AnsiString types they could easily hold the chr(0) value.

I'll have to implement this shortly within the dll and will note it here when the dll has the above functionality Smile.
Back to top
View user's profile Send private message
Rebel49
Contributor
Contributor


Joined: 23 Aug 2002
Posts: 78
Location: Nova Scotia, Canada

PostPosted: Thu Aug 28, 2003 10:45 am    Post subject: Reply with quote

Sounds promising PGWARE!!

I look forward to dusting off that SNMP manual and giving it
another try.

Yes

Thanks


REB

_________________
OLD and eager!
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Thu Aug 28, 2003 4:08 pm    Post subject: Reply with quote

First download latest version of VDSIPP 3.8.28.2003:
DOWNLOAD HERE

Okay VDSIPP now updated with this feature. Here is how to get it to work.

First use the command:

INTERNET REPLACENULL, ON

this command above turns the feature on to replace instances of ^NULL^ to actual character 0's during communication.

Now anywhere in your code where you need to send a character 0 (@chr(0)) you use the text ^NULL^.

The vdsipp will read this in and replace any instances of ^null^ to an actual character 0 and send it to the intended server/client.


Now if you use any of the vdsipp events to read a return message/text and a character 0 is present in the text then this too will be replaced with ^NULL^.


If at anytime you want to turn this feature off you can use the command:
INTERNET REPLACENULL, OFF. If you choose to turn it off and send any text with ^null^ in it, the text will not be converted internally to chr 0's and will be sent literally.


So in your above code you could now use:

Code:

INTERNET REPLACENULL, ON
%A = @CHR(48)@CHR(39)@CHR(2)@CHR(1)^NULL^@CHR(4)@CHR(6)@CHR(112)
%B = @CHR(117)@CHR(98)@CHR(108)@CHR(105)@CHR(99)@CHR(160)@CHR(26)@CHR(2)
%C = @CHR(2)@CHR(4)@CHR(210)@CHR(2)@CHR(1)^NULL^@CHR(2)@CHR(1)
%D = ^NULL^@CHR(48)@CHR(14)@CHR(48)@CHR(12)@CHR(6)@CHR(8)@CHR(43)
%E = @CHR(6)@CHR(1)@CHR(2)@CHR(1)@CHR(1)@CHR(5)^NULL^@CHR(5)^NULL^

%%message = %A%B%C%D%E


Passing the %%message variable to the VDSIPP will then internally convert the ^null^ characters to the correct character 0's and send to the server/client (server in your case).

This ^null^ directive and the INTERNET REPLACENULL command will function with TCP, TCP-SERVER, UDP and UDP-SERVER protocols only for the time being.
Back to top
View user's profile Send private message
Rebel49
Contributor
Contributor


Joined: 23 Aug 2002
Posts: 78
Location: Nova Scotia, Canada

PostPosted: Thu Aug 28, 2003 5:19 pm    Post subject: Reply with quote

YAY! It works!


Wave

Mind you my code is very rudimentary but I am definitely
seeing the data I was looking for from the host device response.
So I will experiment with this in the trial period to see will be
as powerful as I think it will be.

I strongly suspect I will register this.

I wonder if this is a solution for X-tools original question in this thread.

Thanks

Worship Worship Worship


REB

_________________
OLD and eager!
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Thu Aug 28, 2003 5:35 pm    Post subject: Reply with quote

No prob Smile It wasn't that hard to implement, just took some tinkering and testing to see if it would work or not.

As for X-Tools I don't know if it will work in his situation. I think he is using the vdsdll which has a vdsmysql dll in it to communicate remotely. If Tommy would like the code I'm using to do the ^NULL^ conversions I'll gladly share it with him.

A remote mysql query may also be possibly using TCP but I suspect it would not be nearly as easy as using the vdsmysql extension.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group