Computing.Net > Forums > Programming > Is it just me?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Is it just me?

Reply to Message Icon

Name: Mechanix2Go
Date: December 16, 2008 at 02:50:57 Pacific
OS: 2K SP3
CPU/Ram: PIII / 512
Product: Clone / CLONE
Comment:

Or is the general tone of posts here getting more daffy with every passing week?


=====================================
If at first you don't succeed, you're about average.

M2



Sponsored Link
Ads by Google

Response Number 1
Name: lee123abc
Date: December 16, 2008 at 03:31:05 Pacific
Reply:

You bored??? Why don't you post some challenges up then???!


0

Response Number 2
Name: Mechanix2Go
Date: December 16, 2008 at 03:54:04 Pacific
Reply:

OK How about date nath in NT5?

hint: change the month and date to a 'julian-like' number [0 thru 365 or 6], prepend the year, do the math and convert julian to yyyymmdd.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: lee123abc
Date: December 16, 2008 at 05:01:26 Pacific
Reply:

Ok.... I think this is you trying to get free help with your homework (So I will let you figure it out alone)
Ha, M2 I have no idea where to begin. I wasn't challenging you directly... just trying to give you something to do.
What other programs do you use and how did you get so good at (your favourite name) DOS?

I have learnt alot from these posts though and have created a bat file that will search a drive for files. (Sounds simple but it was learnt from scratch) I just cant figure out why you guys got so good at bat. What do you do for a living? (I am so keen to learn more but need simpler problems than the one you posted here!)

Lee


0

Response Number 4
Name: BatchFreak
Date: December 16, 2008 at 05:51:08 Pacific
Reply:

Hey Mechanix2Go, I think I got it :p I'll post when I get back from school :)

I only Batch if possible, 2000 more lines of code, oh well.


0

Response Number 5
Name: LinuxOS2
Date: December 16, 2008 at 05:57:59 Pacific
Reply:

Lee, I have a hunch you have not been around these forums much, if you had you would certainly know that Mechanix2Go is in no way in need of class time, this guy knows his #*&%

Keep the old stuff running


0

Related Posts

See More



Response Number 6
Name: lee123abc
Date: December 16, 2008 at 08:49:36 Pacific
Reply:

I have ben hee long enough to know that.... and be a little cheeky!!

I take a bow when I see the name 'M2' in any post!


0

Response Number 7
Name: reno
Date: December 20, 2008 at 10:54:27 Pacific
Reply:

M2, i think i got some idea on how to do it.


0

Response Number 8
Name: reno
Date: December 20, 2008 at 12:48:41 Pacific
Reply:

done...
a bit messy coding and my eye is too sleepy. 3am in the morning here.


@echo off
SetLocal EnableDelayedExpansion

set /a yyyy=%date:~-4%
set /a mm=1%date:~3,2%-100
set /a dd=1%date:~0,2%-100
echo Today=%yyyy%-%mm%-%dd%

Call :GetJulianDate %dd% %mm% %yyyy%
echo JulianDate=%GetJulianDate%

Call :GetStdDate %GetJulianDate%
echo StandardDate=%GetStdDate%
goto:eof

REM FUNCTION GetJulianDate dd as %1, month as %2, year as %3
:GetJulianDate
set /a GetJulianDate=%1
if NOT %2=='1' (
set /a loopUntil=%2-1
for /L %%i IN (!loopUntil!,-1,1) do (
call :GetNumOfDays %%i %3
set /a GetJulianDate+=!GetNumOfDays!
)
)
set GetJulianDate=%3%GetJulianDate%
set GetJulianDAte=%GetJulianDate:~2%
goto :eof

REM FUNCTION GetStdDate julianDate as %1
:GetStdDate
::Julian Year 1930-2029
set jDate=%1
set /a yyyy=19%jDate:~0,2%
if !yyyy! lss 1930 set /a yyyy+=100
set /a ddd=1%jDate:~-3%-1000
for /L %%i In (1,1,12) do (
call :GetNumOfDays %%i !yyyy!
set /a ddd-=!GetNumOfDays!
if !ddd! leq 0 (
set /a mm=%%i
set /a dd=ddd+=!GetNumOfDays!
goto :breakLoop
)
)
:breakLoop
if !mm! leq 9 set mm=0!mm!
if !dd! leq 9 set dd=0!dd!
set GetStdDate=!yyyy!!mm!!dd!
goto :eof


REM FUNCTION GetNumOfDays month as %1, year as %2
:GetNumOfDays
if %1==2 (
set /a remainder=%2-%2/4*4
if !remainder!==0 (set /a GetNumOfDays=29) else (set /a GetNumOfDays=28)
) else (
for %%i in (1 3 5 7 8 10 12) do if %1==%%i set /a GetNumOfDays=31
for %%i in (4 6 9 11) do if %1==%%i set /a GetNumOfDays=30
)
goto :eof

for %%i in (10 11 12) do (if %date:~3,2%==%%i (set /a mm=%date:~3,2%) else (set /a mm=%date:~4,1%))
for /L %%i in (10,1,31) do (if %date:~0,2%==%%i (set /a dd=%date:~0,2%) else (set /a dd=%date:~1,1%))


0

Response Number 9
Name: Razor2.3
Date: December 20, 2008 at 19:36:35 Pacific
Reply:

I prefer to cheat:

Sat 12/20/2008 22.30.28.17
C:\>copy con a.bat
echo WScript.Quit DatePart("yyyy", Now) > #.vbs
cscript //NOLOGO #.vbs
set d=%ErrorLevel%
echo WScript.Quit DatePart("e: Done
y", Now) > #.vbs
cscript //NOLOGO #.vbs
set d=%d%%ErrorLevel%
del #.vbs
@echo %d%^Z

1 file(s) copied.


Sat 12/20/2008 22.33.38.22
C:\>a


Sat 12/20/2008 22.33.50.55
C:\>echo WScript.Quit DatePart("yyyy", Now) 1>#.vbs


Sat 12/20/2008 22.33.50.55
C:\>cscript //NOLOGO #.vbs


Sat 12/20/2008 22.33.50.67
C:\>set d=2008


Sat 12/20/2008 22.33.50.67
C:\>echo WScript.Quit DatePart("y", Now) 1>#.vbs


Sat 12/20/2008 22.33.50.69
C:\>cscript //NOLOGO #.vbs


Sat 12/20/2008 22.33.50.75
C:\>set d=2008355


Sat 12/20/2008 22.33.50.75
C:\>del #.vbs
2008355


Sat 12/20/2008 22.33.50.75
C:\>

Edit: Other direction!

Sat 12/20/2008 22.49.42.22
C:\>copy con a.bat
echo d = WScript.Arguments(0) > #.vbs
echo d = DateSerial(Left(d, 4), 1, Right(d, Len(d) - 4)) >> #.vbs
echo WScript.Quit DatePart("yyyy", d) * 10000 + DatePart("m", d) * 100 + DatePart("d", d) >> #.vbs
cscript //NOLOGO #.vbs %1
set d=%ErrorLevel%
del #.vbs
@echo %d%^Z

1 file(s) copied.


Sat 12/20/2008 22.54.08.19
C:\>a 2008355


Sat 12/20/2008 22.54.37.94
C:\>echo d = WScript.Arguments(0) 1>#.vbs


Sat 12/20/2008 22.54.37.94
C:\>echo d = DateSerial(Left(d, 4), 1, Right(d, Len(d) - 4)) 1>>#.vbs


Sat 12/20/2008 22.54.37.94
C:\>echo WScript.Quit DatePart("yyyy", d) * 10000 + DatePart("m", d) * 100 + DatePart("d", d) 1>>#.vbs


Sat 12/20/2008 22.54.37.94
C:\>cscript //NOLOGO #.vbs 2008355


Sat 12/20/2008 22.54.38.00
C:\>set d=20081220


Sat 12/20/2008 22.54.38.00
C:\>del #.vbs
20081220


Sat 12/20/2008 22.54.38.02
C:\>



0

Response Number 10
Name: Razor2.3
Date: December 20, 2008 at 20:27:26 Pacific
Reply:

Actually, while we're screwing around, here's a fun idea. Change your TMP environment variable (either from "System Properties" or with SETX) to NUL. Log off/on, then try to download something with Firefox or Internet Explorer.

Then [don't] do it to someone else's PC.


0

Response Number 11
Name: Mechanix2Go
Date: December 21, 2008 at 01:30:21 Pacific
Reply:

reno,

Using DATE substring is a non-starter.

I'll read through your cade later to see what you've done withn the ,ath.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 12
Name: reno
Date: December 21, 2008 at 05:27:25 Pacific
Reply:

i've another subroutine to get date from bios written by my guru. hehehe, i've been learning to write script from his codes the past few days at this forum.

to razor2.13:
thats a nice vbs, hope you dont mind if i use your code in my batch file.


REM FUNCTION GetDate() Return date as integer(yyyymmdd)
:GetDate
::== YMD8.bat

@echo off > d.d

>> d.d echo E 0100 B4 2A CD 21 B4 4C CD 21
>> d.d echo N #DAY#.COM
>> d.d echo RCX
>> d.d echo 8
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 F0 B4 4C CD 21
>> d.d echo N #MONTH#.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 89 C8 B4 4C CD 21
>> d.d echo N #YEAR#.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 D0 B4 4C CD 21
>> d.d echo N #DAT#.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo Q

debug < d.d > nul
del d.d

#dat#.com
for /L %%a in (1,1,9) do if errorlevel %%a set dd=0%%a
for /L %%a in (10,1,31) do if errorlevel %%a set dd=%%a

#day#.com
for /L %%a in (0,1,6) do if errorlevel %%a (for %%b in (Sun Mon Tue Wed Thu Fri Sat) do set ddd=%%b)

#month#.com
for /L %%a in (1,1,9 ) do if errorlevel %%a set mm=0%%a
for %%a in ( 10 11 12) do if errorlevel %%a set mm=%%a

#year#.com
if errorlevel 215 set yyyy=2007
if errorlevel 216 set yyyy=2008
if errorlevel 217 set yyyy=2009
if errorlevel 218 set yyyy=2010

del #*#.com

set /a GetDate=%yyyy%%mm%%dd%
goto :eof


0

Response Number 13
Name: Mechanix2Go
Date: December 22, 2008 at 02:37:02 Pacific
Reply:

To be clear, that code to get date from BIOS is not mine. I think it came from dtech10.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 14
Name: Razor2.3
Date: December 22, 2008 at 03:13:25 Pacific
Reply:

The problem with Mechanix2Go's / dtech10's method is that it's obsolete and removed from Windows 64-bit. I don't have a solution, either (excluding alternate languages).


0

Response Number 15
Name: Mechanix2Go
Date: December 22, 2008 at 06:00:34 Pacific
Reply:

"removed from Windows 64-bit"

huh?


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 16
Name: Razor2.3
Date: December 22, 2008 at 13:33:58 Pacific
Reply:

On Vista 64-bit:

C:\Windows>dir debug.exe /s /b
File Not Found


0

Response Number 17
Name: Mechanix2Go
Date: December 22, 2008 at 14:54:44 Pacific
Reply:

The wunderkind at M$ finally broke backward compatibility. LOL


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 18
Name: Judago
Date: December 22, 2008 at 22:52:26 Pacific
Reply:

[Edit2]
Ok I Think I fixed the problem, sorry for re-editing but it saves the thread being unreadable. Should work with fancy date formats.
[/edit2]

To get today's date in batch this seems to work in xp. Not sure about anything other systems. Probably won't work on locked down systems without access to reg.


@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "skip=2 tokens=3" %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sDate') do set lim=%%a
for /f "skip=4 tokens=2,*" %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate') do (
set dt=%%b
if defined lim set dt=!dt:%lim%= !
for %%c in (!dt!) do (
set /a pcnt+=1
set p!pcnt!=%%c
)
)
set dvar=%date%
if defined lim set dvar=!dvar:%lim%= !
for %%a in (%dvar%) do set nvar=%%a !nvar!
for %%a in (%nvar%) do (
call :test %%a
set /a pcnt-=1
if !pcnt!==0 goto finish
)
goto finish

:test
if /i "!p%pcnt%:~0,1!"=="y" (
set tyear=%1
) else (
if /i "!p%pcnt%:~0,3!"=="mmm" (
call :month %1
) else (
if /i "!p%pcnt%!"=="dd" (
set tday=%1
) else (
if /i "!p%pcnt%!"=="d" (
set tday=%1
) else (
if /i "!p%pcnt%!"=="mm" (
set tmonth=%1
) else (
if /i "!p%pcnt%!"=="m" (
set tmonth=%1
)
)
)
)
)
)
goto :eof

:month
for %%z in ("jan=1" "feb=2" "mar=3" "apr=4" "may=5" "jun=6" "jul=7" "aug=8" "sep=9" "oct=10" "nov=11" "dec=12") do set %%z
set tmonth=!%1!
goto :eof

:finish
if %tyear% lss 10 set tyear=20%tyear%
if %tday% lss 10 set tday=0%tday%
if not "%tmonth:~0,1%"=="0" if %tmonth% lss 10 set tmonth=0%tmonth%
echo The day is the %tday%
echo The month is %tmonth%
echo the year is %tyear%
endlocal
pause
goto :eof



0

Response Number 19
Name: Mechanix2Go
Date: December 26, 2008 at 08:14:14 Pacific
Reply:

Doesn't work in w2k. But regardless, I don't see any date math. Just a way to get the layout via reg/ cp settings.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 20
Name: Judago
Date: December 27, 2008 at 00:59:15 Pacific
Reply:

True no date math, the reason I posted it was because the conversation came back to how to get a reliable source for date output from batch. I think it's worth a mention because I got a consistent output with every date setting I could think of in xp. This included dd ddd mm mmm yyyy and many other strange settings.

Sorry for interrupting your thread, I guess I'm probably the daffy one......


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Is it just me?

download figlet www.computing.net/answers/programming/download-figlet/10193.html

what programming language to chose www.computing.net/answers/programming/what-programming-language-to-chose/9048.html

if success do this else do that www.computing.net/answers/programming/if-success-do-this-else-do-that/8426.html