View previous topic :: View next topic |
Author |
Message |
Hippo Contributor
Joined: 08 Feb 2005 Posts: 53
|
Posted: Mon Feb 21, 2005 4:55 pm Post subject: Byte Convertor |
|
|
While coding for my current project I had to knock up a quick byte convertor. I thought I would share the code here 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 |
|
|
Hippo Contributor
Joined: 08 Feb 2005 Posts: 53
|
Posted: Wed Feb 23, 2005 8:19 pm Post subject: |
|
|
20 views and no reply |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Wed Mar 30, 2005 9:20 am Post subject: |
|
|
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 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 |
|
|
gonzabar Newbie
Joined: 24 Jun 2001 Posts: 15 Location: Madrid, Spain
|
Posted: Wed Mar 30, 2005 9:18 pm Post subject: What about real numbers... |
|
|
What about real numbers (single precision, 4 bytes or double precision 8 bytes) ? |
|
Back to top |
|
|
Serge Professional Member
Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Fri Apr 01, 2005 12:10 am Post subject: |
|
|
Quote: | It's probably because most people already has made something like this, or atleast as a routine. |
oh so true
serge _________________
|
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Sun Apr 03, 2005 9:41 pm Post subject: |
|
|
Doesn't mean it's not useful or an excellent piece of code
Serge wrote: | Quote: | It's probably because most people already has made something like this, or atleast as a routine. |
oh so true
serge |
_________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Serge Professional Member
Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Mon Apr 04, 2005 9:10 am Post subject: |
|
|
not at all ff, in fact some "newbies" of vds may find it extremely useful
serge _________________
|
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Mon Apr 04, 2005 9:26 am Post subject: |
|
|
Yeah I agree with that _________________
|
|
Back to top |
|
|
Hippo Contributor
Joined: 08 Feb 2005 Posts: 53
|
Posted: Tue Apr 19, 2005 2:13 pm Post subject: |
|
|
Nice to know its useful to someone |
|
Back to top |
|
|
|
|
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
|
|