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, hex

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Newbie2k2
Newbie


Joined: 17 Mar 2002
Posts: 11

PostPosted: Mon Mar 18, 2002 1:00 pm    Post subject: binary, hex Reply with quote

Ok my problem is - i'm a Newbie :)

i want to code a program that copy the hex numbers from a file
(the rest i can solve myself- bad english ? :D)
there is an example code below
but it's not the same i want !

here is the example of a hex editor that was in VDS v.402:

Code:
REM ****************************************************
REM binfile.dsc v. 4.0
REM use of the @Binfile() funtion
REM (c) 1995 - 2001 S.A.D.E.

Title Simple Hex Editor
  option fieldsep,@tab()
  DIALOG CREATE,Simple Hex Editor,-1,0,602,360
REM *** Modified by Dialog Designer on 22/05/01 - 00:28 ***
  DIALOG ADD,STYLE,STYLE1,Courier New,,,,NAVY
  DIALOG ADD,MENU,&File,Open|CTRL+O,Save|CTRL+S,Save As|CTRL+A,-,Exit|CTRL+X
  DIALOG ADD,MENU,&Edit,Search|CTRL+F
  DIALOG ADD,LIST,LIST1,5,5,590,290,,STYLE1,CLICK,HAND
  DIALOG ADD,EDIT,EDIT1,300,80,350,20,,,STYLE1,EXIT
  DIALOG ADD,EDIT,EDIT2,300,445,130,20,,,STYLE1,EXIT
  DIALOG ADD,BITMAP,BITMAP1,300,20,35,35,hex.ico
  DIALOG ADD,STATUS,STATUS1
  Gosub SPLASH
  DIALOG SHOW
:Evloop
  wait event
  goto @event()
:SearchMENU
  %%String = @input(Text to search:)
  If %%String
    List create,1
   List assign,1,List1
   %A = @match(1,%%String)
   If %A
     List seek,List1,@index(1)
   End
   List close,1
  End
Goto evloop
:OpenMENU
    %%File = @filedlg()
:Update
   If %%File
     binfile open,1,%%File,read
     %D = @binfile(SIZE,1)
        If @greater(@file(%%File,Z),%D)
      WARN File doesn't exist or is handled by the system ! 
      goto evloop
     End
        If @greater(@file(%%File,Z),524287)
      if @not(@ask(File is to large to be viewed in list box. Continue with Worpad ?))
        goto evloop
      Else
        %%Flag = 1
      End
     End
     dialog cursor,wait
     List create,1
     dialog set,status1,%%File - [%D octets]
     %S = 0
     binfile seek,1,%S
     while @not(@binfile(EOF,1))
       %D = @binfile(read,1,HEX,16)
         binfile seek,1,%S
      %T = @binfile(read,1,TEXT,16)
      If @greater(48,@len(%D))
        Repeat
          %D = %D" "
        until @equal(@len(%D),48)
      End
      List add,1,@hex(%S,8)@tab()%D@tab()%T
      %S = @sum(%S,16)
     wend
     If %%Flag
       List savefile,1,@windir(T)@name(%%file).doc
      runm wordpad @chr(34)@windir(T)@name(%%file).doc@chr(34),wait
     Else
       List assign,list1,1
     End
     List close,1
     binfile close,1
     dialog cursor
   End
  goto evloop
:SaveMENU
  if @ask(Backup file ?)
    File copy,%%File,@path(%%File)@name(%%File).bak
  End
  File delete,%%File
  %A = %%File
  Gosub WRITE
  goto evloop
:Save AsMENU
  %A = @filedlg(,,,SAVE)
  If %A
    If @file(%A)
     if @not(@ask(File exists. Overwrite ?))
       Goto evloop
     End
   End
    Gosub WRITE
  End
  Goto evloop
:List1click
  %%Index = @index(list1)
  parse "%%Ofset";EDIT1;EDIT2,@item(list1)
Goto evloop
:Edit1exit
:Edit2exit
  If @not(@zero(@count(List1)))
    List seek,list1,%%Index
    List put,list1,%%Ofset@tab()@dlgtext(edit1)@tab()@dlgtext(edit2)
  End
Goto evloop
:ExitMENU
:Close
  exit
:WRITE
   BINFILE OPEN,1,%A,WRITE
    List create,1
    List create,2
   List assign,1,List1
   repeat
     %P = @next(1)
     If %P
       parse "%A;%I;%A",%P
      List add,2,%I
     End
   until @null(%P)
   List close,1
   List seek,2,0
   repeat
     %P = @next(2)
     If %P
       BINFILE WRITE,1,HEX,%P
     End
   until @null(%P)
   BINFILE CLOSE,1
   List close,2
Exit

REM **************************************
REM The code below isn't related to this
REM example. It is the part of the graphical
REM user interface for the examples.

:SPLASH
  %%Item = BINFILE@cr()Demo application
  %S = @regread(Curuser,Software\SADE\VDS\4.0,ExSplash)
  %T = 2
  If %S
    DIALOG CREATE,Splash,-1,0,240,160,NOTITLE
REM *** Modified by Dialog Designer on 12/05/01 - 19:41 ***
    DIALOG ADD,STYLE,STYLE1,,,BC,,YELLOW
  DIALOG ADD,BITMAP,BITMAP1,0,0,240,160,examples.dsr|3066
  DIALOG ADD,TEXT,info,94,20,200,46,@name(%0).@ext(%0)@cr()How to use: %%Item,,TRANSPARENT,STYLE1
  DIALOG SHOW
    wait %T
    dialog close
    %E = @event()
  End
Exit



at least the program should look like that but without the list
only the hex numbers should be shown
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Mon Mar 18, 2002 1:43 pm    Post subject: Reply with quote

Is this what you needed? I was just a real quick code snip. Were you
the one who sent me an email about this before? I'm sorry if you
replied back and I didn't reply, I've been real busy! Hope this helps.

Code:

  DIALOG CREATE,Save Hex,-1,0,301,94
  DIALOG ADD,TEXT,TEXT1,6,6,27,13,Input:
  DIALOG ADD,EDIT,EDIT1,5,37,,,
  DIALOG ADD,TEXT,TEXT2,36,6,35,13,Output:
  DIALOG ADD,EDIT,EDIT2,34,46,180,19,
  DIALOG ADD,BUTTON,in,2,228,64,24,...
  DIALOG ADD,BUTTON,out,32,232,64,24,...
  DIALOG ADD,BUTTON,Save,62,8,64,24,Save
  DIALOG SHOW
  :evloop
  wait event
  %e = @event()
  goto %e

:InButton
  %%infile = @filedlg(*.*)
  if %%infile
      dialog set,edit1,%%infile
  end
  goto evloop
 
:outButton
  %%outfile = @filedlg(*.*)
  if %%outfile
      dialog set,edit2,%%outfile
  end
  goto evloop
 
:SaveButton
    if @not(@dlgtext(edit1))
      Info Please select a input file.
      goto evloop
   end   
    if @not(@dlgtext(edit2))
      Info Please select a output file.
      goto evloop
   end   
   %%file = @dlgtext(edit1)
   If %%File
     binfile open,1,%%File,read
     %D = @binfile(SIZE,1)
        If @greater(@file(%%File,Z),%D)
      WARN File doesn't exist or is handled by the system ! 
      goto evloop
     End
     dialog cursor,wait
     List create,1
     %S = 0
     binfile seek,1,%S
     while @not(@binfile(EOF,1))
       %D = @binfile(read,1,HEX,16)
         binfile seek,1,%S
      %T = @binfile(read,1,TEXT,16)
      If @greater(48,@len(%D))
        Repeat
          %D = %D" "
        until @equal(@len(%D),48 )
      End
      List add,1,%D
      %S = @sum(%S,16)
     wend
     list savefile,1,@dlgtext(edit2)
     List close,1
     binfile close,1
     dialog cursor
     Info File saved.
   End
  goto evloop
 
  :close
  stop

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Newbie2k2
Newbie


Joined: 17 Mar 2002
Posts: 11

PostPosted: Mon Mar 18, 2002 1:55 pm    Post subject: Thanx Reply with quote

Yeah this is cool so far,
but it dont saves the file.

It do nothing.
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Mon Mar 18, 2002 2:06 pm    Post subject: Reply with quote

It worked for me. Select the input file, Select the file to save to, then
press the Save button. The input file will be saved in HEX form to
the output file.

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Newbie2k2
Newbie


Joined: 17 Mar 2002
Posts: 11

PostPosted: Mon Mar 18, 2002 2:21 pm    Post subject: Reply with quote

OK BIG THANX !!!!!!!!!

now it worked, i started debug mode
and saw this
Code:
If @greater(48,@len(%D))
        Repeat
          %D = %D" "
        until @equal(@len(%D),48 )
      End

here it looped, so i deleted this part and all went fine !

thank you again
you helped me fast and correct !
Back to top
View user's profile Send private message Send e-mail
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1753
Location: Space and Time

PostPosted: Mon Mar 18, 2002 2:31 pm    Post subject: Reply with quote

Oops Embarassed Sorry, I missed that. Look to the left. Confused Rolling Eyes Wink
_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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