View Full Version : Worm HELP......LOL...plz =p
TimeSurfer
01-22-2008, 10:32 PM
ProcedureDLL.s ConvertBytes(FSbytes.l)
FileSize.l = FSbytes
If FileSize < 1024
sTEXT.s = "Bytes"
FileSize.l = FSbytes
ElseIf FileSize >= 1024 And FileSize < 1048576
sTEXT.s = "Kilobytes"
FileSize.l = FSbytes / 1024
ElseIf FileSize >= 1048576 And FileSize < 1073741824
sTEXT.s = "Megabytes"
FileSize.l = FSbytes / 1048576
ElseIf FileSize >= 1073741824 And FileSize < 1099511627776
sTEXT.s = "Gigabytes"
FileSize.l = FSbytes / 1073741824
ElseIf FileSize >= 1099511627776
sTEXT.s = "Terabytes"
FileSize.l = FSbytes / 1099511627776
EndIf
ProcedureReturn StrD(FileSize,2) + " " + sText
EndProcedure
That my purebasic4 code im having a problem getting it to work though lol it works fine for bytes and kilobytes its the rest of it thats not working. any thoughts bro?
TimeSurfer
01-23-2008, 01:12 PM
if even tried using double and quad rather then long and still no go. the **** thing works fine if call it from within itself im so lost.....
ProcedureDLL.s ConvertBytes(FSbytes.d)
sTEXT.s = ""
If FSbytes < 1024
sTEXT = "Bytes"
ElseIf FSbytes >= 1024 And FSbytes < 1048576
sTEXT = "Kilobytes"
FSbytes = FSbytes / 1024
ElseIf FSbytes >= 1048576 And FSbytes < 1073741824
sTEXT = "Megabytes"
FSbytes = FSbytes / 1048576
ElseIf FSbytes >= 1073741824 And FSbytes < 1099511627776
sTEXT = "Gigabytes"
FSbytes = FSbytes / 1073741824
ElseIf FSbytes >= 1099511627776
sTEXT = "Terabytes"
FSbytes = FSbytes / 1099511627776
EndIf
ProcedureReturn StrD(FSbytes,2) + " " + sTEXT
EndProcedure
TimeSurfer
01-23-2008, 10:08 PM
i tried your fix worm yet im still having problems if the variable input is too large it wont work. like if i try to call the conversion for 1 gigabyte it doesnt display anything yet it seems to work for byte, kb , and mb ive heard this is due to the restriction of long but yet double as youve tried and quad ive tried and still nothing for gb or tb im so confused everything tells me this should work
Maybe pass it in as a string, then use ValD to convert it to a double.
ProcedureDLL.s ConvertBytes(BytesIn.s)
FSbytes.d = ValD(BytesIn)
sTEXT.s = ""
If FSbytes < 1024
sTEXT = "Bytes"
ElseIf FSbytes >= 1024 And FSbytes < 1048576
sTEXT = "Kilobytes"
FSbytes = FSbytes / 1024
ElseIf FSbytes >= 1048576 And FSbytes < 1073741824
sTEXT = "Megabytes"
FSbytes = FSbytes / 1048576
ElseIf FSbytes >= 1073741824 And FSbytes < 1099511627776
sTEXT = "Gigabytes"
FSbytes = FSbytes / 1073741824
ElseIf FSbytes >= 1099511627776
sTEXT = "Terabytes"
FSbytes = FSbytes / 1099511627776
EndIf
ProcedureReturn StrD(FSbytes,2) + " " + sTEXT
EndProcedure
Your call would look similar to this
nVal = 1099511627776
sReturn = DLL.CallFunction("AutoPlay\\Docs\\Bytes.dll", "ConvertBytes", "\""..nVal.."\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL)
TimeSurfer
01-24-2008, 11:47 AM
ahh ok....I see thanks worm appreciate it
TimeSurfer
01-24-2008, 02:34 PM
very wierd still doesnt work.
on page show code
nVal = 1099511627776
sReturn = DLL.CallFunction("AutoPlay\\Docs\\Bytes.dll", "ConvertBytes", "\""..nVal.."\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL)
Label.SetText("Label1", sReturn);
when i run the app it makes the label go blank. very very wierd.
like i said though it seems to work for bytes,kilobytes, and megabytes. just not gigabytes or terabytes for some reason. [the dll only works for b,kb,mb if i change the procedure from double to long. otherwise i get same results as when i use double. it shows nothing]
Works for me... is your DLL names Bytes like mine was?
TimeSurfer
01-24-2008, 03:08 PM
oops lol i feel like a complete idiot now. lol, i completely left out the convert long to double. thanks worm i appreciate the help.
TimeSurfer
01-24-2008, 03:49 PM
hey worm this should work too right?
ProcedureDLL.s ConvertBytes(BytesIn.s,BytesDis.l)
FSbytes.d = ValD(BytesIn)
sTEXT.s = ""
If FSbytes < 1024
If BytesDis = 1
sTEXT = "Bytes"
ElseIf BytesDis = 2
sTEXT = "b"
ElseIf BytesDis = 3
sTEXT = "B"
EndIf
ElseIf FSbytes >= 1024 And FSbytes < 1048576
If BytesDis = 1
sTEXT = "Kilobytes"
ElseIf BytesDis = 2
sTEXT = "kb"
ElseIf BytesDis = 3
sTEXT = "KB"
EndIf
FSbytes = FSbytes / 1024
ElseIf FSbytes >= 1048576 And FSbytes < 1073741824
If BytesDis = 1
sTEXT = "Megabytes"
ElseIf BytesDis = 2
sTEXT = "mb"
ElseIf BytesDis = 3
sTEXT = "MB"
EndIf
FSbytes = FSbytes / 1048576
ElseIf FSbytes >= 1073741824 And FSbytes < 1099511627776
If BytesDis = 1
sTEXT = "Gigabytes"
ElseIf BytesDis = 2
sTEXT = "gb"
ElseIf BytesDis = 3
sTEXT = "GB"
EndIf
FSbytes = FSbytes / 1073741824
ElseIf FSbytes >= 1099511627776
If BytesDis = 1
sTEXT = "Terabytes"
ElseIf BytesDis = 2
sTEXT = "tb"
ElseIf BytesDis = 3
sTEXT = "TB"
EndIf
FSbytes = FSbytes / 1099511627776
EndIf
ProcedureReturn StrD(FSbytes,2) + " " + sTEXT
EndProcedure
im calling it like this
FSbytes = 1099511627776
FStype = 1
sReturn = DLL.CallFunction("AutoPlay\\Docs\\bytes.dll", "ConvertBytes", "\""..FSbytes..","..FStype.."\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
did i screw it up?
You need to enclose the parameter you are passing as a string withing quotes, if its numeric, do not encose it.
FSbytes = 1099511627776
FStype = 1
sReturn = DLL.CallFunction("AutoPlay\\Docs\\bytes.dll", "ConvertBytes", "\""..FSbytes.."\","..FStype, DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
TimeSurfer
01-24-2008, 05:39 PM
K i think i get it now. strings must be enclosed numerics arent. thanks again worm. I dont think Id know what to do without your help bro. Guess thats why they call you the WORMINATOR =p
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.