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 


Byte Convertor

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
Hippo
Contributor
Contributor


Joined: 08 Feb 2005
Posts: 53

PostPosted: Mon Feb 21, 2005 4:55 pm    Post subject: Byte Convertor Reply with quote

While coding for my current project I had to knock up a quick byte convertor. I thought I would share the code here Smile I Hope someone finds it useful.

Code:

rem Byte Convertor By Hippo 21/02/05 
 
  DIALOG CREATE,Byte Convertor,-1,0,349,178
  DIALOG ADD,EDIT,EDIT1,40,20,230,20,Enter Value to be Converted to Bytes
  DIALOG ADD,COMBO,COMBO1,70,20,50,21,,,LIST
  DIALOG ADD,BUTTON,BUTTON1,70,270,60,20,Convert!
  DIALOG ADD,TEXT,TEXT1,20,20,,,Enter Value to Be Converted to Bytes eg 1048576
  DIALOG ADD,TEXT,TEXT2,70,80,,,Change the Suffix and hit Convert
  DIALOG ADD,EDIT,EDIT2,130,20,180,20,,,READONLY
  DIALOG ADD,TEXT,TEXT3,110,20,,,Here is the Number of Bytes
  DIALOG ADD,BUTTON,BUTTON2,130,230,100,20,Copy to Clipboard
  DIALOG SHOW
 
  list add,COMBO1,KB
  list add,COMBO1,MB
  list add,COMBO1,GB
 

:Evloop
  wait event
  goto @event()
 
:button1BUTTON
       
  %%bytes = @dlgtext(EDIT1)
  %%suffix = @dlgtext(COMBO1)
 
  if @equal(%%suffix,KB)
     %%result = @fmul(%%bytes,1024)
     DIALOG SET,EDIT2,%%result
  end
 
  if @equal(%%suffix,MB)
     %%result = @fmul(%%bytes,1048576)
     DIALOG SET,EDIT2,%%result
  end
 
  if @equal(%%suffix,GB)
     %%result = @fmul(%%bytes,1073741824)
     DIALOG SET,EDIT2,%%result
  end
  goto evloop
 
:Button2BUTTON
 
  if @not(@null(@dlgtext(edit2)))
     CLIPBOARD CLEAR
     CLIPBOARD SET,@dlgtext(edit2)
  end
 
  goto evloop 
 
:Close
  Exit
Back to top
View user's profile Send private message
Hippo
Contributor
Contributor


Joined: 08 Feb 2005
Posts: 53

PostPosted: Wed Feb 23, 2005 8:19 pm    Post subject: Reply with quote

20 views and no reply Sad Confused
Back to top
View user's profile Send private message
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Wed Mar 30, 2005 9:20 am    Post subject: Reply with quote

It's probably because most people already has made something like this, or atleast as a routine.

I've made some minor changes to your code, hope you don't mind Smile
Code:
  rem Byte Convertor By Hippo 21/02/05
title Byte Convertor
  DIALOG CREATE,Byte Convertor,-1,0,349,178
REM *** Modified by Dialog Designer on 30.03.2005 - 11:18 ***
  DIALOG ADD,EDIT,EDIT1,40,20,230,20,Enter Value to be Converted to Bytes
  DIALOG ADD,COMBO,COMBO1,70,20,50,21,,,LIST
  DIALOG ADD,BUTTON,BUTTON1,70,270,60,20,Convert!
  DIALOG ADD,TEXT,TEXT1,20,20,,,Enter Value to Be Converted to Bytes eg 1048576
  DIALOG ADD,TEXT,TEXT2,70,80,,,Change the Suffix and hit Convert
  DIALOG ADD,EDIT,EDIT2,130,20,180,20,,,READONLY
  DIALOG ADD,TEXT,TEXT3,110,20,,,Here is the Number of Bytes
  DIALOG ADD,BUTTON,BUTTON2,130,230,100,20,Copy to Clipboard
  DIALOG SHOW

  list add,COMBO1,KB
  list add,COMBO1,MB
  list add,COMBO1,GB
  list seek,COMBO1,0


:Evloop
  wait event
  goto @event()

:button1BUTTON

  %%bytes = @dlgtext(EDIT1)
  %%suffix = @dlgtext(COMBO1)

  if @NUMERIC(%%bytes)
 
  if @equal(%%suffix,KB)
    %%result = @fmul(%%bytes,1024)
    DIALOG SET,EDIT2,%%result
  end

  if @equal(%%suffix,MB)
    %%result = @fmul(%%bytes,1048576)
    DIALOG SET,EDIT2,%%result
  end

  if @equal(%%suffix,GB)
    %%result = @fmul(%%bytes,1073741824)
    DIALOG SET,EDIT2,%%result
  end
  goto evloop
 
  else
    WARN Please enter numeric values only.
    dialog focus, EDIT1
  end

:Button2BUTTON

  if @not(@null(@dlgtext(edit2)))
    CLIPBOARD CLEAR
    CLIPBOARD SET,@dlgtext(edit2)
  end

  goto evloop

:Close
  Exit

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
gonzabar
Newbie


Joined: 24 Jun 2001
Posts: 15
Location: Madrid, Spain

PostPosted: Wed Mar 30, 2005 9:18 pm    Post subject: What about real numbers... Reply with quote

What about real numbers (single precision, 4 bytes or double precision 8 bytes) ?
Back to top
View user's profile Send private message Send e-mail
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Fri Apr 01, 2005 12:10 am    Post subject: Reply with quote

Quote:
It's probably because most people already has made something like this, or atleast as a routine.


oh so true Smile

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sun Apr 03, 2005 9:41 pm    Post subject: Reply with quote

Doesn't mean it's not useful or an excellent piece of code Wink


Serge wrote:
Quote:
It's probably because most people already has made something like this, or atleast as a routine.


oh so true Smile

serge

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Mon Apr 04, 2005 9:10 am    Post subject: Reply with quote

not at all ff, in fact some "newbies" of vds may find it extremely useful

serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
GeoTrail
Valued Contributor
Valued Contributor


Joined: 18 Feb 2003
Posts: 572
Location: Bergen, Norway

PostPosted: Mon Apr 04, 2005 9:26 am    Post subject: Reply with quote

Yeah I agree with that Smile
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Hippo
Contributor
Contributor


Joined: 08 Feb 2005
Posts: 53

PostPosted: Tue Apr 19, 2005 2:13 pm    Post subject: Reply with quote

Nice to know its useful to someone Smile
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 -> Visual DialogScript 5 Source Code 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