Hot Topic (More than 10 Replies) Looking for an Sbasic function. (Read 1330 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Looking for an Sbasic function.
Nov 13th, 2011 at 8:35am
Print Post Print Post  
Is there an Sbasic function  something like filesize that will grab the date and time a file was created ?

I am trying to place the date and time a file was created into elements.

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Looking for an Sbasic function.
Reply #1 - Nov 13th, 2011 at 5:23pm
Print Post Print Post  
Hi Robert,
I am not aware of sbasic function for that but following User Defined Function should take care of it.

Code
Select All
Function UDFGetDateTimeSize (vPath as String, vFile as String ) as String
var aa as string
var n as Int
var vLoop as Int
var vLine as String
var vFileInfoLine as String
var vResult as String


aa = @RedirectProcess("cmd /c Dir " + vPath + vFile, "")

//aa = @RedirectProcess ("cmd /c Dir C\Sesame2\Sesame.ini", " ")

//vResult = @RedirectProcess("cmd /c DIR", "")
	//WriteLn(vResult)

//WriteLN (aa)

aa = @Replace (aa, @NL ( ), ";" )
n = @CountStringArray (aa)

For vLoop = 1 to n
vLine = @AccessStringArray (aa, vLoop)
If @In (vLIne, vFile) > 0 then
	{
		vFileInfoLine = @AccessStringArray (aa, vLoop)
		vLoop = n

	}

Next

Return (vFileInfoLine)

End Function



var vFileInfo as String
var vDate as String
var vTime as String
var vSize as String




vFileInfo = UDFGetDateTimeSize ("C:\Sesame2\", "Sesame.ini")


While @In (vFileInfo, "  ") > 1
	{
		vFileInfo = @Replace (vFileInfo, "  ", " ")
	}


WriteLn (vFileInfo)

vFileInfo = @Replace (vFileInfo, " ", ";")

vDate = @AccessStringArray (vFileInfo, 1)

WriteLN ("Date File Created = " + vDate)


vTime = @AccessStringArray (vFileInfo, 2) + " " + @AccessStringArray (vFileinfo, 3)

WriteLN ("Time File Created = " + vTime)


vSize = @AccessStringArray (vFileinfo, 4)

WriteLN ("Size of the file = " + vSize)


 

  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Looking for an Sbasic function.
Reply #2 - Nov 13th, 2011 at 8:11pm
Print Post Print Post  
I am not sure if you are trying to pick up date and time when the file is being created or you are looking for date and time of the file already created and looking the date and time as to when it was created.

For the first case, just use @Date and @time functions as the file is being created with I/O commands.
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Looking for an Sbasic function.
Reply #3 - Nov 14th, 2011 at 3:02pm
Print Post Print Post  
Bharat,

Thanks once again for your help! Your first example was perfect.

I just could have sworn I saw some Sbasic command somewhere that did it also. With all the awesome commands in Sbasic, Sometimes I do have trouble remembering what is real vs imagined.

Thanks again,

Robert
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Looking for an Sbasic function.
Reply #4 - Nov 14th, 2011 at 4:27pm
Print Post Print Post  
BOBSCOTT wrote on Nov 14th, 2011 at 3:02pm:
With all the awesome commands in Sbasic, Sometimes I do have trouble remembering what is real vs imagined.



An imaginary SBasic function:
Code
Select All
function imaginary() as double
var imagine as double

   imagine = @sqrt(-1)
   return imagine
end function
 


  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Looking for an Sbasic function.
Reply #5 - Nov 15th, 2011 at 3:58pm
Print Post Print Post  
Since no one commented on my imaginary function joke, I added:

@ServerFileDate(filename as string) as string
@ServerFileSize(filename as string) as intptr

@LocalFileDate(filename as string) as string
@LocalFileSize(filename as string) as intptr

to Sesame3.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Looking for an Sbasic function.
Reply #6 - Nov 15th, 2011 at 4:04pm
Print Post Print Post  
I was tempted. Glad I didn't comment. Those new commands will be helpful. Wink

Would like to request a @FileCopy() and @FileRename() function unless this is already possible.

  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Looking for an Sbasic function.
Reply #7 - Nov 15th, 2011 at 4:22pm
Print Post Print Post  
Steve_in_Texas wrote on Nov 15th, 2011 at 4:04pm:
I was tempted. Glad I didn't comment. Those new commands will be helpful. Wink


But if someone had laughed at my math joke, I might have added these to Sesame2 instead.

Quote:
Would like to request a @FileCopy() and @FileRename() function unless this is already possible.


Local commands - not a problem. Server side commands introduce some serious security issues. I'll look into it.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Looking for an Sbasic function.
Reply #8 - Nov 15th, 2011 at 7:40pm
Print Post Print Post  
Grin LAUGHING!!!! Please add to S2 lol.
  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Looking for an Sbasic function.
Reply #9 - Nov 15th, 2011 at 9:17pm
Print Post Print Post  
Steve_in_Texas wrote on Nov 15th, 2011 at 7:40pm:
Grin LAUGHING!!!! Please add to S2 lol.

Nope. Too late. You blew it.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Looking for an Sbasic function.
Reply #10 - Nov 15th, 2011 at 10:04pm
Print Post Print Post  
AHHH! I'm always a day late and a dollar short.

Wink
  
Back to top
IP Logged
 
Acebanner
Full Member
***
Offline



Posts: 123
Location: New York City
Joined: Jan 23rd, 2008
Re: Looking for an Sbasic function.
Reply #11 - Nov 16th, 2011 at 9:04pm
Print Post Print Post  
An imaginary SBasic function:
Code
Select All
function imaginary() as double
var imagine as double

   imagine = @sqrt(-1)
   return imagine
end function
 



You should check out http://xkcd.com/


  
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Looking for an Sbasic function.
Reply #12 - Nov 16th, 2011 at 9:09pm
Print Post Print Post  
Acebanner wrote on Nov 16th, 2011 at 9:04pm:
You should check out http://xkcd.com/

I'm one of the primary Admins for their Forum.  Smiley
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Acebanner
Full Member
***
Offline



Posts: 123
Location: New York City
Joined: Jan 23rd, 2008
Re: Looking for an Sbasic function.
Reply #13 - Nov 17th, 2011 at 4:08pm
Print Post Print Post  
Hammer wrote on Nov 16th, 2011 at 9:09pm:
Acebanner wrote on Nov 16th, 2011 at 9:04pm:
You should check out http://xkcd.com/

I'm one of the primary Admins for their Forum.  Smiley


Get out! Seriously? Great site.
  
Back to top
IP Logged