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 


VDSUG

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


Joined: 09 Aug 2007
Posts: 79

PostPosted: Thu Aug 09, 2007 5:21 pm    Post subject: VDSUG Reply with quote

Hello,

I'm having an issue with reading a large file.

This is what I'm trying to accomplish.

say I have a 100 meg file.

I would like to load only 1 percent of that file into the UG buffer in RAWDATA mode. View that 1 percent of the file in a vdslist "list1". Be able to increment that view by what ever byte count I specify.

Then be able to search for an instance in the 100 meg file and return results to list2.

I kind of can get this to work. but now I cant view any regular size files just loops and my original code is so butchered I'm need a fresh start.. I've been banging my head agaist this for a week now.. Crying
Back to top
View user's profile Send private message
briguy
Contributor
Contributor


Joined: 09 Aug 2007
Posts: 79

PostPosted: Thu Aug 09, 2007 7:35 pm    Post subject: Reply with quote

This is the code I have. I trimmed out much of it after I figured it wasn’t working right.

Issues I'm having.
1. If the file is small 300 bytes it just loops.
2. If the file is fairly large 5+ megs it seams to work fine but I’m really not sure if I'm getting the exact byte position or all the data..
3. I would like the track bar increment along with the file position.


Ideally I would like to work as mentioned in my first post.

Any help would be greatly appreciated.


Code:

#define command,UG
   #define function,ug

   if @file(@path(%0)VDSUG.DLL)
      external @path(%0)VDSUG.DLL
   else
      if @file(@windir()\system\VDSUG.DLL)
         external @windir()\system\VDSUG.DLL
      else
         title PROGRAM ERROR
         warn Cannot find a necessary file:@tab()@cr()@cr()VDSUG.DLL
         exit
      end
   end

   option SCALE, 96
   option DECIMALSEP, "."
   %%title = "Search-IT"
   title %%title
  DIALOG CREATE,FILE VIEW,-1,0,841,730,DRAGDROP
  DIALOG ADD,STYLE,STYLE1,Wingdings 3,20,,BLACK,
  DIALOG ADD,STYLE,STYLE2,Wingdings 3,16,,BLACK,
  DIALOG ADD,STYLE,STYLE3,Wingdings 3,12,,BLACK,
  DIALOG ADD,LIST,LIST1,60,12,708,452
  DIALOG ADD,GROUP,GROUP1,127,775,38,218
  DIALOG ADD,BUTTON,BUTTON1,20,16,64,24,Open
  DIALOG ADD,STATUS,STATUS1,[160] | [200] |
  DIALOG ADD,BUTTON,BUTTON4,77,727,44,24,Clear
  DIALOG ADD,BUTTON,BUTTONfind,20,90,64,24,Find
  DIALOG ADD,TRACKBAR,TRACKBAR1,116,727,40,400,0,1,,VERTICAL,BOTH,CLICK
  DIALOG ADD,LIST,LIST2,537,12,708,157
  DIALOG ADD,BITBTN,BITBTN_FUP,132,778,32,32,,J,,STYLE1
  DIALOG ADD,BITBTN,BITBTN_MUP,165,778,32,32,,h,,STYLE2
  DIALOG ADD,BITBTN,BITBTN_SUP,198,778,32,32,,5,,STYLE3
  DIALOG ADD,BITBTN,BITBTN_SDN,243,778,32,32,,6,,STYLE3
  DIALOG ADD,BITBTN,BITBTN_MDN,276,778,32,32,,i,,STYLE2
  DIALOG ADD,BITBTN,BITBTN_FDN,309,778,32,32,,K,,STYLE1
  DIALOG ADD,LINE,LINE1,235,778,34,4
  DIALOG SHOW

   %p = @sendmsg(@winexists(~LIST1),$0194,3000,0)
   %p = @sendmsg(@winexists(~LIST2),$0194,3000,0)

   list CREATE, 1
   list CREATE, 2

:Evloop

   wait event
   goto @event()

:BUTTON1BUTTON
   ##   %%bufsize = @ug(FILEREADBUFSIZE,100)
   %%file = @shortname(@filedlg(file,title,,))
   ug FILEOPEN,1,%%file, READ
   %%filesize = @ug(filegetsize,1)
   %%data = @ug(FILEREAD, 1, RAWDATA, 0, @chr(255))
   dialog SET,LIST1,%%data
   %%curpos = @ug(FILEGETPOS, 1)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   %%percent = @div(%%filesize,100)
       #%%bufsize = @ug(FILEREADBUFSIZE, %%percent)
   goto evloop


:buttonFINDbutton
   %%input = @input(enter search,)
   %%inputlength = @len(%%input)
   info  %%inputlength

   repeat
      %%searchfoundpos = @ug(FILESEARCHTEXT, 1, %%input)
        %%sumofpos = @sum(%%inputlength,%%searchfoundpos)
        %%curpos = @ug(FILEGETPOS, 1)
      %%data2 = @ug(FILEREAD, 1, RAWDATA,0, @chr(255))
      dialog set,list1,%%data2
      %%search = @MATCH(list1,%%input)
      list add,list2,%%CurPOS@tab()@tab()@item(list1)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   until @equal(%%CurPOS,0)
   goto evloop


:button4button
   list clear,list1
   list clear,list2
   list close,list1
   list close,list2
   list create,list1
   list create,list2
   goto evloop

:trackbar1click
   %%trackbar = @dlgtext(trackbar1)
   %%level = @sum(@diff(100,%%trackbar),0)
   %%percent2 = @fmul(%%level,%%percent)
   %%newpos = @ug(FILESETPOS, 1, %%percent2)
   %%data3 = @ug(FILEREAD, 1, RAWDATA, %%NEWPOS, @chr(255))
   dialog set,list1,%%data3
   %%curpos = @ug(FILEGETPOS, 1)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   goto evloop

:BITBTN_SUPBUTTON
   %%curpos = @ug(FILEGETPOS, 1)
   %%newpos = @fsub(%%CurPOS,100)
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   %%data2 = @ug(FILEREAD, 1, RAWDATA, %%SetPOS, @chr(255))
   dialog set,list1,%%data2
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   goto evloop

:BITBTN_SDNBUTTON
   %%curpos = @ug(FILEGETPOS, 1)
   %%newpos = @SUM(100,%%CurPOS)
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   %%data2 = @ug(FILEREAD, 1, RAWDATA, %%SetPOS, @chr(255))
   dialog set,list1,%%data2
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   goto evloop

:BITBTN_MUPBUTTON
   %%curpos = @ug(FILEGETPOS, 1)
   %%newpos = @fsub(%%CurPOS,1000)
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   %%data2 = @ug(FILEREAD, 1, RAWDATA, %%SetPOS, @chr(255))
   dialog set,list1,%%data2
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   goto evloop

:BITBTN_MDNBUTTON
   %%curpos = @ug(FILEGETPOS, 1)
   %%newpos = @SUM(1000,%%CurPOS)
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   %%data2 = @ug(FILEREAD, 1, RAWDATA, %%SetPOS, @chr(255))
   dialog set,list1,%%data2
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   goto evloop

:BITBTN_FUPBUTTON
   %%curpos = @ug(FILEGETPOS, 1)
   %%newpos = @fsub(%%CurPOS,10000)
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   %%data2 = @ug(FILEREAD, 1, RAWDATA, %%SetPOS, @chr(255))
   dialog set,list1,%%data2
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   goto evloop

:BITBTN_FDNBUTTON
   %%curpos = @ug(FILEGETPOS, 1)
   %%newpos = @SUM(10000,%%CurPOS)
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   %%data2 = @ug(FILEREAD, 1, RAWDATA, %%SetPOS, @chr(255))
   dialog set,list1,%%data2
   %%setpos = @ug(FILESETPOS, 1, %%NewPOS)
   dialog set,status1,Lines in Buffer - @count(list1)@tab()Current File Possition - %%CurPos@tab()File/Size - @ug(filegetsize,1)
   goto evloop

:Close
   ug FILECLOSE, 1
   exit
Back to top
View user's profile Send private message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Fri Aug 10, 2007 9:19 am    Post subject: Reply with quote

This may help you. It's how I quickly search for text or hex in 5MB binfiles using only std VDS 5 functions & commands.

Code:
  # find (text) %s-%s
  # find (hex) 25 73 2d 25 73
  binfile open,1,%%inFile,read
  %y =
  %z =
  %S = 2270000
  # 0x22a330
  binfile seek,1,%S
  repeat
    binfile seek,1,%S
    %x = @binfile(read,1,HEX,5)
    %y = @trim(%x)
    if @equal(25 73 2d 25 73,%y)
      rem info found a match!
      %z = 1
    end
    %S = @sum(%S,1)
  until @binfile(EOF,1) @equal(%z,1)


In this example I was starting the search at 0x22a330 (offset 2270000) and searching for 25 73 2d 25 73 in hex which is %s-%s in text.

%S in the code is the offset to start the search from, so you could adapt this code into a user function or command and start a 2nd search from the %S position of the last successful search.

_________________
cheers

Dave
Back to top
View user's profile Send private message
briguy
Contributor
Contributor


Joined: 09 Aug 2007
Posts: 79

PostPosted: Mon Aug 13, 2007 12:11 pm    Post subject: Reply with quote

Dave,

I played around with your code but I cant seam to figure out how to get the raw file output like the vdsug extension. This code will go into my archives for future use though. 

Thanks!
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