Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

2251.

Solve : Excel visual basic script wanted.?

Answer»

I'm entering a work schedule on a sheet named "hours" in Microsoft Excel. I want to create a variable so I can type in "open" or "close" and it automatically recognizes what those times are. So I don't have to manually type in "11:45 pm" or "23:35" every time.

How is it done?

Thanks if you can help.first, need to clarify few things:
1. is it vbs (windows SCRIPTING host - installed by default by windows) or is it vba (built-in inside excel)

Quote from: And 1 on March 19, 2009, 11:57:06 PM

I want to create a variable so I can type in "open" or "close" and it automatically recognizes what those times are. So I don't have to manually type in "11:45 pm" or "23:35" every time.
give EXAMPLE on how you type in open close. and which cell is it going to be inserted time.

there is METHOD both in vbs and vba to get current time, and coincedently it's named method Time()
VBA: MsgBox Time
VBS: wsh.echo Time

btw, there is a shortcut when working with excel to insert date or time:
CTRL+semicolon -> insert date on focused cell
CTRL+SHIFT+semicolon -> insert time on focused cellCan you give me more steps? Like what does the code look like in excel?

Something like this:


Private Sub Worksheet_Activate()
Dim noon As Date

noon = #12:00:00 PM#


Set ws = ActiveWorkbook.Sheets("hours")

End Subso, VBA it is.
i still don't understand what you are trying to achieve.

the following code will update K1 and K2 to current time everytime the worksheet is activated.
Code: [Select]Private Sub Worksheet_Activate()
Range("K1") = Format(Time, "hh:mm")
Range("K2") = Format(Time, "hh:mm AMPM")
End SubI want excel to replace the the string "noon" with the time value of 12:00 PM. I want it to be able to do it for any cell in the sheet.

Sorry for not being more clear.And1,

have you try to use the built-in Replace Function?
Press CTRL-H, and fill in "noon" to replace with "12:00 PM", then click ReplaceAll button

From Excel Help File (F1)
Quote
TIMEVALUE
Returns the decimal number of the time represented by a text string. The decimal number is a value ranging from 0 (zero) to 0.99999999, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 P.M.).

Syntax
TIMEVALUE(time_text)

Formula Description (RESULT)
=TIMEVALUE("2:24 AM") Decimal part of a day, for the time (0.1)


or do really mean the timevalue function? which convert time to a decimal number.the VBA way
create macro and name it ReplaceNoon, assign a shortcut key to run the macro, then paste the following code

Code: [Select]Sub ReplaceNoon()
'Application.ActiveSheet.UsedRange.Select
For Each c In Application.ActiveSheet.UsedRange
If Not (IsEmpty(c) Or IsError(c)) Then
If UCase(c.Value) = "NOON" Then
'replace noon to string of 12:00 pm
c.Value = "12:00 PM"

'replace noon to formula timevalue of 11:59 pm
'c.Formula = "=TimeValue(""11:59 PM"")": c.NumberFormat = vbGeneral
End If
End If
Next
End Sub

Notes: TimeValue of 12:00PM is invalid value, but when tested it works and return 0.5
2252.

Solve : Programming help c++?

Answer»

im a new programmer and I am testing my skills by programming simple little games. right now im using inline functions, i dont actually need them but i want practice with them.



when i compile the program it says " [linker error] undefined reference to `DrawingCards()' "
and " ld returned 1 exit status "
or itll say "'DrawingCards()' used but never DEFINED" and highlight the declaration in the header file.

Im not exactly sure what that means but i double checked everything and it SEEMS to look ok to me


It DECLARE it in the header file "int inline DrawingCards();"

Then define it in a separate source file
"int DrawingCards()
{
int FirstHand = 0;
......
}

In the main loop i call it " PlayerHand += DrawingCards(); "


when it compiles the error comes up in the header file when i declare it: "int inline DrawingCards();"

from what i understand the error means that the compiler thinks im calling the function instead of declaring it. but im probably wrong. any suggestions to help me out?

----Also if i make the function a normal int function it compiles and runs fine. but i need it to be an inline function, i do have i loop in the function but it stops itself after 2 loops.


Or if you COULD just point me in the right direction or where i could obtain this information, i looked else where on information on inline functions and only found that the compiler decides if the function can be inlined and it may not inline them if the function is to big, and i doubt any of my functions are to big most are not even a page worth of lines. Write inline at the first declaration of the function in the header file and the whole code of the function:

inline init DrawingCards()
{
blablablabla
}

Inline functions must not be more than 7 lines of code or so.

As a rule do not make inline functions that are too big and it depends on the compiler.change your
Code: [Select]int DrawingCards()
{
int FirstHand = 0;
......
}
to

Code: [Select]int inline DrawingCards()
{
int FirstHand = 0;
......
}

your declaration in the header file must match the implementation.

2253.

Solve : Initializing a multidimensional array?

Answer» HELLO there,
I m TRYING to DYNAMICALLY allocate a multidimensional integer type array in C.
but i am not sure about how to use the malloc syntax in this case.
Could anyone PLEASE help me out.
Thanks a LOT.
2254.

Solve : What java class am I in??

Answer»

How can I find out at run time what java class I am in. Or what java class called me?

thank you.A

In every single class (code) you are in just write a code that will output the INFORMATIONS that is related to the class
Easy i dont know why you want to do that?use reflection.Thanks for the replies. Let me explain the actual problem. I have a main method which reads a FILE and passes the data to a class whose name is a state code. ie AZ, DE,MA etc. Each of these state classes write out data that USES the state code. Each of these state classes is coded by a different person and currently they each have a statement in them that reads:

theState = "xx"; where xx is the name of the class. What I am trying to avoid is one of the programmers using the wrong state code when it is just the name of the class.

what I have come up with is the following method:

private static String myName()
{
String className;
int i = 0;
className = "A";
try
{
int ii = 1 / i;
}
catch (Exception e)
{
StackTraceElement[] se = e.getStackTrace();
String fullClassName = se[1].getClassName();
int lastDot = fullClassName.lastIndexOf(".");
className = fullClassName.substring(++lastDot);
}
return className;
}


Is there a simpler way of doing this. I look up reflection but couldn't figure out how to use it.

Thanks for any help.
what about this.getClassName() instead of purposely causing an error, getting a stack trace and GRABBING the top object?

or am I missing something?this.getClassName() will not compile. I got it to compile. Thanks EVERYONE.

2255.

Solve : VB express 2008 keyboard input.?

Answer»

oh nvm i GOT it now. i FOUND a list of charactersPlease, in future, POST your own QUESTION. Thanks

2256.

Solve : Batch file programming (FIGURED IT OUT!!)?

Answer»

I use this script, but not working on exit asking Y/N question, goes straight to You have Pressed THREE and doesn't exit. (FIGURED IT OUT)

@ECHO off
REM - LABEL INDICATING THE BEGINNING OF THE DOCUMENT.
:BEGIN
CLS
REM - THE BELOW LINE GIVES THE USER 3 CHOICES (DEFINED AFTER /C:)
c:\CHOICE /N /C:1234 PICK A NUMBER (1, 2,3, or 4)%1
pause
REM - THE NEXT THREE LINES ARE DIRECTING USER DEPENDING UPON INPUT

IF ERRORLEVEL ==4 GOTO FOUR
IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE

:FOUR
ECHO ARE YOU SURE YOU WANT TO EXIT (Y/N)
C:\choice /n /c:YN Yes or No? (Y, or N)%1
IF errorlevel ==Y GOTO END
IF errorlevel ==N GOTO BEGIN

(FIX) Change
IF errorlevel ==2 GOTO BEGIN
IF errorlevel ==1 GOTO END

:THREE
ECHO YOU HAVE PRESSED THREE
pause
goto begin

:TWO
ECHO YOU HAVE PRESSED TWO
pause
goto begin

:ONE
ECHO YOU HAVE PRESSED ONE
pause
goto begin

:END
EXITI FIXED IT!! not really programming but i would think that as scriptingQuote from: TChai on March 19, 2009, 11:14:07 AM

not really programming but i would think that as scripting

Scripting is a kind of programming.
2257.

Solve : randomize?

Answer»

I don't know if this can e done in batch but can anyone randomize a variables value(in batch)?
Like for example I give these 3 options and the variable gets as value anyone of them.
for example:

value1 - echo Hello
value2 - echo World
value3 - echo "

Now, each time i execute the batch file i want this variable not to have the same value always.
If that can be done I'd need some help.sure can be done

Code: [Select]@echo off

set r=%RANDOM%
echo Random Number=%r%

set/a a=%random% %% 3 + 1
echo a=%a%

if %a%==1 echo Hello
if %a%==2 echo World
if %a%==3 echo "
Explanation:

USING %random% generates a random number between 0 and 32767.

To restrict a random number to a range from 0 to N-1 you use set /a %random% modulus N. The modulus operator is a percent SIGN %. The modulus is the remainder that results from performing integer division. Thus %random% % 10 results in a random number whose lowest value could be 0 and whose highest value could be 9. To shift the range to be from 1 to N you add 1.

Modulus operator - NOTE that in a batch SCRIPT, (as opposed to on the command-line), you need to double up the % to %%.

Thus to generate a random number from 1 to 3 you could write

set /a rnum=%random% % 3 + 1 at the command prompt

and

set /a rnum=%random% %% 3 + 1 in a batch file.

2258.

Solve : New to J2ME?

Answer»

I want to write simple PROGRAM in J2ME for my Sony Ericsson. I have no IDEA about that but well in java.

I don't know where i can start.

Can anyone tell me Reference or idea to learn J2ME? Especially for Sony Ericsson.i used to write application in J2ME long time ago, mostly written specific for nokia.

first you have to download the SDK for the series of phone. for Nokia, there is Series 40, Series 60, etc. and is available for download at Nokia website, or nokia will send you the SDK CD on request.

so for sony ericsson, you could go to their website and check if the sdk for sony is available for download. if not, there is a general j2me sdk availble at java website, i can't remember what was the name, something like STK. as long as you don't use the phone-specific API, the coding roughly should be the same across all java-phone, the difference mainly is in the screen size.

second, the J2ME API Reference, you should GET those, so you will know the available method and PROPERTIES of each object. it's the programming bible, without those, you are basically 'blind'.

2259.

Solve : How to write a simple dll file?

Answer» PLEASE give me an example of a dll file which CALLS a .ICO file. Program in VC++.

Thanksand "calling" and ico file WOULD MEAN what, EXACTLY?
2260.

Solve : help needed with writing a batch file?

Answer»

Hello,

I have downloaded the updates that i needed for my Win XP PRO. Now I'm trying to write a batch file to start the install of my updates.
I'm able to start the install with the comand: "start" followed by the location, then i used the "then" comand to go to the next update. Th problem is that I want the next update to start after the one before has finished, and not while the first one is still running.
So Will you guys help me please, on how I have to program it, or if there is a better way to accomplish this.

I'm trying to create something like this so I don't need to download the same updates every time.

Thnx

What "then command"? I have never heard of it before.

Type start /? at the prompt to see all the options and the syntax including the /WAIT switch.
I have used "then" in a comand line as followed:

start c:\windowsXPsp3
then
start c:\sp3secrityupdate

I have used the then comand like i would use it in VB: first this comand an "then" the second comand. But the problem is that the batch file starts the comands directly behind eachother, what makes that my updates will install simultaneous and not one by one.
But now I will try what you propose, and will let you know if it works for me.Wow. I always though that in VB the "then" keyword was used with If tests like this

If A = B then
C
End If

So can you please direct me to some documentation that shows this other use that you appear to know about?

Also, you cannot rely on using VB keywords in batch files and expecting them to work. You cannot do this with keywords from Pascal, Fortran, C++, Perl, Python or Bash either. The /wait switch only works for non-gui applications. I tried it with firefox...And found the sad truth. Quote from: Helpmeh on November 19, 2009, 04:58:27 AM

The /wait switch only works for non-gui applications. I tried it with firefox...And found the sad truth.

I just tried it with regedit, notepad, calc, Winword.exe (MS Office 2003) and... "C:\Program Files\Mozilla Firefox\firefox.exe" ...

You did remember the title string? (trawl the forums and see how often this catches people out)



How come ff works for you and not me?!Quote from: Helpmeh on November 19, 2009, 01:21:45 PM
How come ff works for you and not me?!

pls confirm you are using this format

Code: [Select]start /wait "title" "path\Program"
"title" can be just 2 quotes "" but it can't be omitted

"path\Program" needs quotes if there are any spaces

try this

Code: [Select]start /wait "" calc
Quote from: Salmon Trout on November 19, 2009, 01:45:13 PM
pls confirm you are using this format

Code: [Select]start /wait "title" "path\Program"
"title" can be just 2 quotes "" but it can't be omitted

"path\Program" needs quotes if there are any spaces

try this

Code: [Select]start /wait "" calc



That may be why. I have never used start other than
start PATH\PROGRAM

I also didn't add the path, because just doing

start firefox

works fine. Thanks for the info,

the wait switch did it for me.

I have to say that I was wrong with an earlier comand I wrote down here, because the keyword "then" is in DEAD only used in if tests.
So I'm sorry about that mistake.

Anyway, thanks for the help.There is no THEN command, therefore, you can not use it in IF tests. You are thinking of some other LANGUAGE, VB perhaps?Quote from: Helpmeh on November 23, 2009, 04:07:30 AM
There is no THEN command, therefore, you can not use it in IF tests. You are thinking of some other language, VB perhaps?

Read the previous POSTS; this was established on Nov 19.
2261.

Solve : Writing multiple text to a text file?

Answer»

Hello, I am trying to write multiply text from textboxes. I am USING this code for a single textbox. Can someone help me to modify this code to write from multiply textboxes. Thank you.
Dim FILE_NAME As String = "C:\ test2.txt"
If System.IO.File.Exists(FILE_NAME) Then
objWriter.Write(Textbox1.Text)
objWriter.Close()
MsgBox("Text written to file")
ELSE
MsgBox("File doesn't exist")
End ifQuote

I am trying to write multiply text from textboxes.
. . .
Quote
to write from multiply textboxes.

Do you mean multiple?


If you do then


Can't you just make another textbox and add another line?
Code: [Select]Dim FILE_NAME As String = "C:\ test2.txt"
If System.IO.File.Exists(FILE_NAME) Then
objWriter.Write(Textbox1.Text)
objWriter.Write(Textbox2.Text)
objWriter.Close()
MsgBox("Text written to file")
Else
MsgBox("File doesn't exist")
End if


else


Then you must want to multiply it. Just add another textbox and use this code.
Code: [Select]Dim FILE_NAME As String = "C:\ test2.txt"
If System.IO.File.Exists(FILE_NAME) Then
objWriter.Write(Val(Textbox1.Text) * Val(Textbox2.Text))
objWriter.Close()
MsgBox("Text written to file")
Else
MsgBox("File doesn't exist")
End if


end if

If I don't have it right then

Could you explain it more CLEARLY?

end ifQuote from: Linux711 on November 21, 2009, 01:29:41 AM
end if

If I don't have it right then

Could you explain it more clearly?

end if

What's with the "end if"I was trying to make the whole thing like a program.Quote from: Linux711 on November 21, 2009, 02:15:38 AM
I was trying to make the whole thing like a program.

Why not just give a straight answer instead so that there is less chance for confusion?Thanks all who replied. My problem is solved
2262.

Solve : Hangman tutorial program??

Answer»

Hey guys, I was just wondering if there's a good tutorial out there for creating a simple but not too beginner'ish program in python that explains what everything does in it, because I'm having trouble understanding what all the functions and keywords do in python. If its important, I'm using Python 3.1.1. Thx all http://www.amazon.com/Python-Dummies-Computer-Tech/dp/0471778648/ref=sr_1_1?ie=UTF8&s=books&qid=1258861388&sr=8-1 is a great book on it if you have about $20 to spend. I have a used copy that I picked up for $7 off of ebay and it was good in the fact that it has lots of helpful tips and analogies to help understand stuff and of course some humor thrown in as the For Dummies series generally has mixed in as easter eggs.

* I'd go with simple ASCII for the Hangman Game to keep it simple at the command prompt. Later on you can tie in CGI with Python and either IIS or Apache server and make Web Based Games which can look far more professional.why spend your parent's (or your) hard earned moneyneedlessly when you can get for free?? Go to the official web site of Python to learn about Python. Why do people write books and read books about programming in anything? I MEAN, seriously, they can just read the dry and boring technical references.

Heck, why bother with computer books at all? just go with processor, memory, and device specifications, and people can extrapolate the rest for themselves. Or, maybe, these books provide an actual "human" voice to the dry function and statement references.

Back in the day when programs actually came with "hard copy" books, language environments almost non-exclusively came with at least two references- a language reference, and a programmers guide. By the logic provided here would the programmers guide not be extraneous? Why bother with such topics as "getting started" when such space could be used for yet another statement truth table?

Why? the very same reason we HAVE interpreted languages like Python. an analogous statement to "Why read books about it when you have the SDK" is PRETTY much "why use programming languages when we can use machine code?" It sounds silly phrased that way, but that's just what it is.


THAT being said, however; The documentation is vital, and should be a first step in any case. What I contest is the "documentation is always enough" concept; The documentation is written from one perspective, and extra documentation, books, and materials are invaluable as you reach into the upper echelons of a program's designed CAPABILITIES, as it can often help with what would otherwise be an insurmountable hurdle, documentation or no documentation. Oftentimes when confronted with a programming problem of some form, I will read my many programming oriented books; old and NEW. Even the oldest programming books can offer insight into modern programming; it really hasn't changed as much as many of us would like; it's still one of the youngest sciences and while we'd like to think that programming languages like python or .NET or perl are far more advanced then the languages we were using in the 70's they really are far too similar for comfort; we still "speak" to computers in a semi-english "dialect" the only thing that has changed is the grammars and the concepts involved with their arrangement. Saying they are "better" depends entirely on the definition of "better", which can range from the performance of the language to the size of the source code to such esoteric metrics as the average length of it's keywords; each of these particular traits has different values for nearly any programming language and to say one is better then any other is to shut out a world of languages just as the unilanguage english-speaking population would say English is the "best" language.

By shutting out what one believes to be inferior one can become so themselves.


Hmm, once again, a very odd rant-like POST. so after all that "rant", what is your stand?, books or no books? In this age of technology and the web, books are really of little use. True, it may or may not teach you all you need to know about a language, however, the wealth of information about the language is only limited to the author and a few select individuals. look at the PHP doc site for example. I think its good, because people all over the world comes and contribute their code and stuff. Books? what for. there are many stuffs the author may not know and the community has already made aware ofQuote from: gh0std0g74 on November 22, 2009, 01:02:34 AM

books are really of little use.

I hope you only mean that in the present context, because I would really hate to give up Charles Dickens, Patrick O'Brian, Robert Crumb, Robert W Service, 350 Spanish Verbs Conjugated, A-Z Guide to Bristol, Bath and Weston-Super-Mare, etc.
Quote from: Salmon Trout on November 22, 2009, 01:49:50 AM
I hope you only mean that in the present context,
yes of course.
thanks Dave, ill probably consider that when i get the money. my only problem was getting the game to generate random words. thx Quote from: timtim41 on November 23, 2009, 08:45:39 AM
thanks Dave, ill probably consider that when i get the money. my only problem was getting the game to generate random words. thx
use the random module to generate random numbers. Have you read Python documentations yet? if not, start reading.
2263.

Solve : nid help?

Answer»

This part of the question requires you to complete the coding of a client–
server system that simulates an online international banking application. The
customers of the bank can select their preferred language for communication
with a bank server in order to obtain a report on their account’s BALANCE.

We have provided TWO NetBeans projects (in the file TMA02Q1.zip) for this
question: BankingServer and BankingClient. The code consists of
the following classes.

! The server, which runs indefinitely, is called
InternationalServer. It waits for a client to connect, and then
creates a thread (an instance of a class called
InternationalSession, see below) which controls this client’s
session.

! An InternationalAccount class, which has methods that
implement dialogues in different languages. It also has a dummy value
for the balance of an account.

! An InternationalSession class. An object of this class controls a
session, and invokes the methods of an InternationalAccount
object. The run method of this class first invokes the method that
requests the client to choose one of the following four languages:
English, DUTCH, Italian and Portuguese. It then executes the method
which asks (in the appropriate language) for the client’s account number,
and then reports the current balance of this account. (Note that, in the
InternationalAccount class, the problem has been simplified by
supplying a single dummy value for the balance, so that all accounts have
the same balance.)

! A client, called InternationalClient, which connects to the
InternationalServer server. It provides input for the class
InternationalSession, reads the messages it receives back, and
prints these messages on the screen.
Carry out the following steps.

1 Open the projects and inspect the code.
2 Write the code for the class InternationalServer which should do
the following:
! Wait to make a connection with each client at a port with an
appropriate port number outputting a message to the screen saying that
it is waiting for a client.
! Once a client is CONNECTED, create a thread (using the class
InternationalSession), provide it with the correct input and
output streams, and set the thread running.
3 Complete the class
4 Run the server.
5 Run four clients, one in each language.
4
Include the NetBeans projects in your Solutions zip and copy the following
items to your Solution Document.
(i) A copy of the code for your InternationalServer class.
(ii) The code for the completed statements for class
InternationalClient (note that there is no need to supply the code
for the whole class).
(iii)A SCREENSHOT of NetBeans with the Output window visible showing that
the server is running and waiting for a client.
(iv) A screenshot of NetBeans with the Output window visible showing a
client’s dialogue in Dutch.
Then answer the following question:
(v) In class InternationalClient there are readLine statements
associated with two different BufferedReaders on the lines marked
//1 and //2. By tracing through the code, explain for each readLine
statement where the data being read originates fromIs this a school assignment?Quote from: mroilfield on November 22, 2009, 04:56:00 AM

Is this a school assignment?

I think you win a prize, I wonder what Patio and BC are giving away today.

I love it when people think we will do the homework for them. Isn't that what studying is for?Quote from: Quantos on November 22, 2009, 05:07:18 AM
I think you win a prize, I wonder what Patio and BC are giving away today.

I love it when people think we will do the homework for them. Isn't that what studying is for?

I like prizes, however I have never liked doing home work. Quote from: mroilfield on November 22, 2009, 04:56:00 AM
Is this a school assignment?

yes...I hate to tell you this Ub, but you are barking up the wrong tree.

We don't do homework here, we did enough of our own earlier in life.

We would help you find resources, however I'm pretty sure that there may be something in your texts or notes that points to these solutions.Quote from: Quantos on November 23, 2009, 04:15:21 AM
I hate to tell you this Ub, but you are barking up the wrong tree.

We don't do homework here, we did enough of our own earlier in life.

We would help you find resources, however I'm pretty sure that there may be something in your texts or notes that points to these solutions.

Very well put.Quote from: mroilfield on November 23, 2009, 05:01:51 AM
Very well put.

Thank you.
2264.

Solve : VB Scrript to delete old files and subfolders?

Answer»

HelloQuote from: gh0std0g74 on November 23, 2009, 06:11:40 PM

I am only assuming Mike is Bill

I think that is is a pretty safe asumption; "Mike" replicates "Bill"'s posting style to the letter. See his recent posts.
Quote from: BatchFileBasics on November 23, 2009, 11:40:32 AM
yuup bill is back. CAN SOMEONE PLEASE BAN HIM?! he is REALLY annoying me and disrupting all topics hes been in
he can just come in as another nick and do this stuff all over.Hey ike, How many members here do not like you?.
you are up to about 15. including most high authority members. and the whole MS-Dos section.

you doubt i can learn anything? i doubt anyone ACTUALLY wants you here.

Quote from: Salmon Trout on November 24, 2009, 12:15:07 AM
See his recent posts.


Get a clue.

Bill Richardson's name is at bottom of each post.Quote from: BatchFileBasics on November 24, 2009, 05:42:07 PM
i doubt anyone actually wants you here.
not me, i actually ENJOY browsing the forum when he's here. Please check both conditions that before date as well as whether it is empty or not. if it is empty meeans, just delete it. Please do it in the below coding


If file.DateLastModified < BeforeDate and folder== null Then
fso.DeleteFile(file.Path)




please try to do.





Dim fso, startFolder, OlderThanDate

Set fso = CREATEOBJECT("Scripting.FileSystemObject"
startFolder = "c:\test"
OlderThanDate = DateAdd("d", -30, Date) ' 30 days

DeleteOldFiles startFolder, OlderThanDate

Function DeleteOldFiles(folderName, BeforeDate)
Dim folder, file, fileCollection, folderCollection, subFolder

Set folder = fso.GetFolder(folderName)
Set fileCollection = folder.Files
For Each file In fileCollection
If file.DateLastModified < BeforeDate Then
fso.DeleteFile(file.Path)
End If
Next

Set folderCollection = folder.SubFolders
For Each subFolder In folderCollection
DeleteOldFiles subFolder.Path, BeforeDate
Next
End Function

Function DeleteOldfolder(foldername, BeforeDate)

Set folderlist = fso.GetFolder(foldername)
Set folderCollection = Folderlist.SubFolders
For Each Folder In folderCollection
If folder.DateLastModified < BeforeDate Then
fso.DeleteFolder(folder.Path)
End If
Next
End Function
Both conditions are checked, which is the purpose of the nested if.

Code: [Select]Set f = fso.GetFolder(folderName)
Set fc = f.Files
If fc.Count = 0 Then
If f.DateLastModified < BeforeDate Then
fso.DeleteFolder foldername, True
End If
End If

This function is unnecessary, there is not even a reference to it in the main script:
Code: [Select]Function DeleteOldfolder(foldername, BeforeDate)

Set folderlist = fso.GetFolder(foldername)
Set folderCollection = Folderlist.SubFolders
For Each Folder In folderCollection
If folder.DateLastModified < BeforeDate Then
fso.DeleteFolder(folder.Path)
End If
Next
End Function

Sheesh!
2265.

Solve : VBScript to Unzip Issues?

Answer»

I'm not very proficient in VBS, infact, I took this script from another thread on this FORUM, I'm just trying to implement it to my needs.

Set WshShell = CreateObject("Wscript.Shell")
file = WshShell.ExpandEnvironmentStrings("%file%")
direc = WshShell.ExpandEnvironmentStrings("%cd%")

strZipFile = "" & direc & "" & file & ".ZIP"
outFolder = "" & direc & "\" & file & ""

Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(strZipFile).Items()
Set objTarget = objShell.NameSpace(outFolder)
intOptions = 256
objTarget.CopyHere objSource, intOptions


%file% expands to input from the batch file the vbscript will be run from. %cd% expands to %cd% normally. I want the script to take a zip file (that is located in the current directory) and place the extracted files in a folder that has the same name as the zip file (minus the extension).

This is the message I get when I try and run the batch file (the contents of which I will show after):
T:\DOCUMENTS and Settings\USERNAME\My Documents\ Stuff\vb.vbs(9, 1) Microsoft VBScript runtime error: Object required: 'objShell.NameSpace(...)'

Here is the contents of the batch file:
@echo off
set file=%1
set file=%file:.zip=%
cscript //nologo vb.vbs
pause

Can someone tell me how to fix it?Why does the batch file remove the .zip extension, and the vbs script add it back again?
Quote from: Salmon Trout on November 26, 2009, 03:48:26 PM

Why does the batch file remove the .zip extension, and the vbs script add it back again?

So if I add .zip it won't look for .zip.zip files, and if I don't then it will automatically add .zip to the END.

But anyway, can you help?The problem is that the VBScript cannot see the environment variables from the batch file. An alternative is to pass the variables on the CScript command line where the VBScript can see them.

Code: [Select]If WScript.Arguments.Unnamed.Count <> 2 Then
WScript.Echo "Invalid arguments...Job Terminated"
WScript.Quit
End If

strZipFile = WScript.Arguments.Unnamed(1) & "\" & WScript.Arguments.Unnamed(0) & ".zip"
outFolder = WScript.Arguments.Unnamed(1)

Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(strZipFile).Items()
Set objTarget = objShell.NameSpace(outFolder)
intOptions = 256
objTarget.CopyHere objSource, intOptions

Code: [Select]@echo off
set file=%1
set file=%file:.zip=%
cscript //nologo vb.vbs "%file%" "%cd%"
pause

Run your batch file like you always do.

Good luck.

When I post on the forum, I very rarely put in error checking routines. FEEL free to add your own.Thanks, but can you tell me how to add error-checking routines? I added an if exist test to the batch file, to make sure the .zip exists.Quote
I added an if exist test to the batch file, to make sure the .zip exists.

That's all you really need. Not sure if the CopyHere method will create a new folder if it doesn't exist, but you can test that yourself.

2266.

Solve : How to automate a download with batch??

Answer»

Hello all,

I have another question! I would like to know how to make a batch either click a link on a page just opened, or just DOWNLOAD a file from a specified web url.

The reason for this is to automate an update process, without asking the user to click the download button.

I was able to find a PROGRAM to install that would do this, but i am looking for a more batchy version of this. Thanks in advance! There is a third-party program that can do what you want, but I can't remember what it is...hopefully another member can provide it. Thanks for the quick reply!
I was able to find wget.exe and webfetch.exe, however neither seem to be able to resolve my host, nor simply download the file at the specified path for that matter.

Anyone know of any other command executable programs?please specify the PROBLEM you are having with wget & show the code you are using

Code: [Select]S:\>wget http://z.about.com/d/healing/1/0/l/N/gtotem_baboon.jpg
--2009-11-22 08:53:16-- http://z.about.com/d/healing/1/0/l/N/gtotem_baboon.jpg
Resolving z.about.com... 207.126.123.29
Connecting to z.about.com|207.126.123.29|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 66800 (65K) [image/jpeg]
Saving to: `gtotem_baboon.jpg'

100%[==========================================>] 66,800 106K/s in 0.6s

2009-11-22 08:53:17 (106 KB/s) - `gtotem_baboon.jpg' saved [66800/66800]

ALSO CURL is quite good, and is optimised for getting single files more than wget

Code: [Select]S:\>curl -O http://z.about.com/d/healing/1/0/l/N/gtotem_baboon.jpg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 66800 100 66800 0 0 66800 0 0:00:01 0:00:01 --:--:-- 82266


Thanks for the speedy replies.
I was able to get wget to work, apparently Comodo thought it would be funny to block it and not say anything.
Either way, it works, and once again all your help was greatly appreciated.

Moderators you can mark this as solved, if desired.

2267.

Solve : pls sum 1 decode this?

Answer»

heloo every1 its me [PAIN] Again

i wanted to decode a CODED LANGUAGE

the code is as follows

Field1
SYM1001
" #m,m m(#;$?""# (#9am(;(?4m;,?$,/!(m$>m(5=!$.$9!4m,>>$*#()m,m),9,m94=(m:%(#m$9m$>m)(.!,?
()cm"
"|am!"""">(!4m94=()m"
"am>9?""#*!4m94=()m"
"~am."" ""#m94=(m"
yam;,!8(m94=(m



i think its not in binary language
its in LEET SPEAK Language (suppose,means i think)......Hello,

How about letting us know where you got it from and what you wanted. May HELP. And more importantly, is it complete?His "friend" sent it to him. He sent me the same QUESTION in a PM. He is now on my ignore list.
My frnd Says that

his sister hacked the code frm their tutorials
bcoz they do not teach well and take exams regularly,without teaching

she just wanted it to be decoded as it is a Question Paper of xam We don't help people to hack or cheat in SCHOOL tests or do their homework for them.

2268.

Solve : Having trouble setting a variable from a text with batch.?

Answer»

Hello all,

Just as the topic states, I cannot set a variable from an entry in a text FILE due to a space at the end of the entry. For example the program WRITES to the file here:

Code: [Select]ECHO %user% >> user.ini
Then attempts to read from it here:

Code: [Select]set /p user= <user.ini
But when it reads the VALUE its got a space at the end. This is unacceptable because this variable is used for a directory.
My QUESTION is, is there any way to remove a character from the end of the input? Or any other way around this?Code: [Select]ECHO %user% >> user.iniIs not right.Quote from: Geek-9pm on November 29, 2009, 10:29:30 PM

Code: [Select]ECHO %user% >> user.iniIs not right.

Thanks for that wonderful piece of help...

I realized my MISTAKE, your right it's not:

Code: [Select]ECHO %user% >> user.iniits
Code: [Select]ECHO %user%>> user.ini
Thanks anyhow, its working now.Quote from: Geek-9pm on November 29, 2009, 10:29:30 PM
Code: [Select]ECHO %user% >> user.iniIs not right.

Unless the trailing space after %user% does not matter. In some situations it might not.
2269.

Solve : importing python modules?

Answer»

I am just learning python (as of TODAY), and I am having an issue with 'import'
I am writing two scripts inputGen.py and frequency.py:

Code: [Select]# inputGen.py
import sys

def readInputWords():
while 1:
line = sys.stdin.readline()
if line=='': RETURN
words = line[:-1].split()
for word in words:
yield word

for word in readInputWords():
print word


Code: [Select]# frequency.py
import inputGen

def countInputWords():
for word in inputGen.readInputWords():
# the rest of countInputWords()

countInputWords()

The problem is that the MOMENT I import inputGen, the entire script is RUN. Is there some way that I can use readInputWords() in frequency.py without running inputGen.py?

2270.

Solve : Dev C++ and GTK Trouble?

Answer»

I downloaded a bundle of GTK, extracted it, then tried it..

Test code used:

Code: [Select]#include <gtk/gtk.h>

int main( int argc, CHAR *argv[])
{
GtkWidget *window;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);

gtk_main();

return 0;
}
Compiler returns this:

I have tried altering project properties, but it gives the same errors

Code: [Select]1 C:\Dev-Cpp\Test\Main.cpp gtk/gtk.h: No such file or directory.
C:\Dev-Cpp\Test\Main.cpp In FUNCTION `int main(int, char**)':
5 C:\Dev-Cpp\Test\Main.cpp `GtkWidget' UNDECLARED (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
5 C:\Dev-Cpp\Test\Main.cpp `window' undeclared (first use this function)
7 C:\Dev-Cpp\Test\Main.cpp `gtk_init' undeclared (first use this function)
9 C:\Dev-Cpp\Test\Main.cpp `GTK_WINDOW_TOPLEVEL' undeclared (first use this function)
9 C:\Dev-Cpp\Test\Main.cpp `gtk_window_new' undeclared (first use this function)
10 C:\Dev-Cpp\Test\Main.cpp `GTK_WINDOW' undeclared (first use this function)
10 C:\Dev-Cpp\Test\Main.cpp `gtk_window_set_title' undeclared (first use this function)
11 C:\Dev-Cpp\Test\Main.cpp `gtk_window_set_default_size' undeclared (first use this function)
12 C:\Dev-Cpp\Test\Main.cpp `GTK_WIN_POS_CENTER' undeclared (first use this function)
12 C:\Dev-Cpp\Test\Main.cpp `gtk_window_set_position' undeclared (first use this function)
13 C:\Dev-Cpp\Test\Main.cpp `gtk_widget_show' undeclared (first use this function)
15 C:\Dev-Cpp\Test\Main.cpp `G_OBJECT' undeclared (first use this function)
16 C:\Dev-Cpp\Test\Main.cpp `gtk_main_quit' undeclared (first use this function)
16 C:\Dev-Cpp\Test\Main.cpp `G_CALLBACK' undeclared (first use this function)
16 C:\Dev-Cpp\Test\Main.cpp `NULL' undeclared (first use this function)
16 C:\Dev-Cpp\Test\Main.cpp `g_signal_connect_swapped' undeclared (first use this function)
18 C:\Dev-Cpp\Test\Main.cpp `gtk_main' undeclared (first use this function)
C:\Dev-Cpp\Test\Makefile.win [Build Error] [Main.o] Error 1
I have tried altering project properties, but it gives the same errors

How do I make it work?

2271.

Solve : How to display progress in batch??

Answer»

Hello all,

I have a few programs written in batch that perform deletions and other functions that take a variable amount of time.
I need to find a way to display the progress of the certain functions, so that the user doesn't think that the cmd just locked up. I remember something about a hash command, but have been unsuccessful at locating any documentation on it.

If you need more information please ask, your help is much appreciated.There is no 'hash command'. However maybe what you heard of is people echoing hash symbols (#) to the console as a progres indicator. You can echo them without a CRLF like this

0>nul set /p=#

If you are using a loop you can PUT that LINE at the end or start of the loop so each time around 1 # symbol gets shown.



Thanks for the quick reply. Hmm, this is very interesting. I am currently trying to show the progress of the following function:

Code: [Select]RD /Q /S "%programfiles(x86)%\largefolder"

Is this even possible? I just don't see how I could put that in a loop to change the current outcome. Perhaps someone can tell me a way to achieve this. You cannot show the "progress" of a single command like that. What you could do, I guess, is break it up, that is delete all the files in (and below) that FOLDER one by one, showing a symbol each time. Then remove the empty folder which is done with no delay.




Do this:

Code: [Select]echo Working, please be patient.......

(some other code)
Quote from: BatchFileCommand on November 28, 2009, 11:13:05 AM

Do this:

Code: [Select]echo Working, please be patient.......

(some other code)
The OP asked for something along the lines of a progressbar...that doesn't even come close, other than the fact that it says the batch is RUNNING...although if it PAUSES at some point in the process, you'd still never know.It's the most sensible. But if you must.

If the amount of files is set you could do something like:

Code: [Select](file action)
cls
echo [||||| ]
(file action)
cls
echo [||||||| ]
(file action)
cls
echo [|||||||||||]
echo.
echo Done!

I can't think of anything else. Quote from: BatchFileCommand on December 01, 2009, 06:41:14 PM
It's the most sensible. But if you must.

If the amount of files is set you could do something like:

Code: [Select](file action)
cls
echo [||||| ]
(file action)
cls
echo [||||||| ]
(file action)
cls
echo [|||||||||||]
echo.
echo Done!

I can't think of anything else.
That was my first thought when I wanted one too, at one point, but it doesn't work if there is only 1 command.Teracopy which is free, can be started from the command line, called from a batch, etc and has a progress bar with a choice of colours, it can be used for Copy|Move|Delete|Test|Check operations. Can take over Windows copy & move operations (optional).

Docs
http://help.codesector.com/TeraCopy

Download
http://www.codesector.com/teracopy.php

2272.

Solve : Computer acting weird?

Answer»

em: Custom Built

Win Xp Pro Service pack 3
Amd Athlon 64 X2 dual core processor 3800+
2.00ghz, 2.gb ram

Ok i just hooked my pc up again today cause i went from my grandparents back to my apt and well i got on it and it was acting weird. Like when id click on a icon on the desktop it would highlight a few of them then if i tried to type it was like typing in all caps and stuff. i restarted it a couple TIMES and nothing. ran a couple programs on it to find out if it was a virus or something else on here and nothing showed up.. was confused.. all the help would be appreciated thanksI don't know what programs you ran to find out if it was "a virus or something else", but you should run a full scan with your AV utility with the current definitions (you have one installed, yes?) and with MalwareBytes.i ran AVG, superantispyware, and spybot, nothin with them.. but i had a friend email me back and im RUNNING a malware program right now..actually i THINK its the same one you mentioned..thanks..Try Kaspersky Anti-Virus it finds approximately 99% of the viruses I had which other application did not RECOGNIZE. The down-side is it eats a lot of memory, so I turn it off when my pc is fine.Hello,

In my opinion, run a full scan with MalwareBytes and let it clean your computer. If that doesn't help post an HijackThis Log of your computer. You will have to run it as administrator if you're using MS Vista or Win7.

Note to Moderators: Should this topic not be moved to Malware Board?

2273.

Solve : How to program a fork() equivalent in Windows C??

Answer»

Hi all,

I've found some stuff on the web about Windows doesn't support fork() and some people say use spawn() but I can't see a clear example of how to do it.

Here's what I'm TRYING to code with the fork() call. Can anyone suggest how I'd substitute spawn so I can execv the 3rd-party executable SYNCHRONOUSLY and get its return code?
Code: [Select]#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

main(int argc, CHAR *ARGV[])

{
FILE *fp;
int pid, status, died, i;
time_t now;

fp = fopen("C:\\path\\to\\cmdlog.txt","a+");
time(&now);
FPRINTF(fp,"Started %s%s", ctime(&now), argv[0]);
for(i=1;i<argc;i++)
fprintf(fp," %s", argv[i]);
fprintf(fp,"\n");
fclose(fp);

// pid=fork();
argv[0] = "C:\\path\\to\\original-command.exe";
execv("C:\\path\\to\\original-command", argv);
// died = wait(&status);

fp = fopen("C:\\path\\to\\cmdlog.txt","a+");
time(&now);
fprintf(fp, "Completed %s\n", ctime(&now));
fclose(fp);

// return status;
return 0;
}I've finally cracked it.

The following official article from Microsoft was way over complicated and I couldn't understand it
http://support.microsoft.com/kb/190351

but luckily I found this article which explains it in simple terms
http://www.cprogramming.com/faq/cgi-bin/smartfaq.cgi?answer=1044654269&id=1043284392

The solution is really simple
Code: [Select]#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <process.h>

main(int argc, char *argv[])

{
FILE *fp;
int pid, status, died, i;
time_t now;

fp = fopen("C:\\path\\to\\cmdlog.txt","a+");
time(&now);
fprintf(fp,"Started %s%s", ctime(&now), argv[0]);
for(i=1;i<argc;i++)
fprintf(fp," %s", argv[i]);
fprintf(fp,"\n");
fclose(fp);

argv[0] = "C:\\path\\to\\original-command.exe";
status = spawnv(P_WAIT, "C:\\path\\to\\original-command.exe", argv);

fp = fopen("C:\\path\\to\\cmdlog.txt","a+");
time(&now);
fprintf(fp, "Completed %s\n", ctime(&now));
fclose(fp);

return status;
}

2274.

Solve : COCOA?

Answer»

Hi,

We are being trained on COCOA framework.
Just wanted to ask, is there any SCOPE of learning this framework.

I mean, is it really in DEMAND?

Thanksas its only for MAC development (am I right?)
PROBABLY not, thats why I learned C++

2275.

Solve : note?

Answer»

CAN YOU REINSTALLING WINDOWS 98 WITH OUT THE INTERNET
NNED HELPFIRST press caps lock, SECOND your os should of come with a cd or floppy disk, you should just be able to plug it in and follow the INSTRUCTIONS, if not ask one of your freinds to go on there computer an- wait a MINUTE, if you dont have internet how are you here?Quote from: bossart54 on December 06, 2009, 06:09:11 PM

CAN YOU REINSTALLING WINDOWS 98 WITH OUT THE INTERNET
NNED HELP

An internet connection is not required for the installation of any Windows OS. What version of disc do you have? Windows 98, or Windows 98SE? (installing from each is different)
2276.

Solve : Programming from within a Batch File. I run Vista?

Answer»

I have made a Menu Batch file and I want TWO of the choices on my menu to be: Open Internet Explorer and the other to be: Open Firefox. How WOULD I do that ? @echo off
:loopchoice
Echo 1 Open in Firefox
Echo 2 Open in Internet Explorer
set /p choice=Option:
if "%choice%"=="1" GOTO ff
if "%choice%"=="2" goto ie
cls
echo Error: Incorrect Option
goto loopchoice
:ff
commands
:ie
commands

There.

2277.

Solve : Rename a set of files and move them?

Answer»

Hi

I have a 3 files in C:\test
They are file1.txt, file2.txt and file3.txt

I want to rename them them so they are PREFIXED with the current date AND time (e.g. 200912080626_file1.txt)
and then I want to move them to C:\testarchive

Is that possible?
I think i need a batch file, can it be done with one batch file?Hi & Welcome to the CH forums.

Quote from: icw

I have a 3 files in C:\test
They are file1.txt, file2.txt and file3.txt

Are these the only files in C:\test\ or are these the only .txt files in C:\test\ ?

Hi Dusty

these are the only filesThe inclusion of VB script ALLOWS the script to be used with any date FORMAT. If your permissions do not allow its use please post your date format. When you have finished testing change the Copy command to Move. The script is not fully tested. The final two lines can be removed at your discretion.

Note that no allowance is made for AM or PM so, if you use that time format, there's a remote possibility that you could overwrite files created at a given time AM with files created at the same time PM. Good hunting.

Code: [Select]@echo off
cls
setlocal

:: EXTRACT date/time and set filename prepend. This can be used with
:: any date format.

set vbsfile=%temp%\vbsfile.vbs
(
echo Thisdate = (Date(^)^)
echo DateYear = DatePart("YYYY", Thisdate^)
echo DateMonth = DatePart("M" , Thisdate^)
echo DateDay = DatePart("D" , Thisdate^)
echo TimeHour = HOUR(Time^)
echo TimeMinute = Minute(Time^)
echo Wscript.Echo DateYear^&" "^&DateMonth^&" "^&DateDay^&" "^&Time^
Hour^&" "^&TimeMinute
)>>%vbsfile%

for /f "tokens=1-5" %%A in ('cscript //nologo %vbsfile%') do (
set yyyy=%%A
set mm=%%B
set dd=%%C
set hh=%%D
set mn=%%E
)

Del %vbsfile%

if %mm% lss 10 if %mm:~0,1% neq 0 set mm=0%mm%
if %dd% lss 10 if %dd:~0,1% neq 0 set dd=0%dd%
if %hh% lss 10 if %hh:~0,1% neq 0 set hh=0%hh%
if %mn% lss 10 if %mn:~0,1% neq 0 set mn=0%mn%

set Prepend=%yyyy%%mm%%dd%%hh%%mn%_


:: Move (Copy) files to archive folder.

pushd c:\test\ || echo Pushd failed - job terminated && exit /b

if not exist c:\testarchive md c:\testarchive

for /f "delims=*" %%1 in ('dir /b *.txt') do (
copy %%1 c:\testarchive\%prepend%%%1 > nul
)

popd

:: Display updated content of archive folder.

dir /tw testarchive\
2278.

Solve : Is there anyway to make a vbscript close if it has an error??

Answer»

Is there anything i can add to my vbscript to make it close if it is going to show an error, instead of showing an error.?To be more specific my the vbscript has to locate a file, im very new to vbscripts i just want to make it if it cant find the file then to simply move on to the rest of the function.Use On Error Resume Next, and after trying to access the file:

Code: [Select]If Err =0 then
'rest of ROUTINE
End If
Quote from: BC_Programmer on December 07, 2009, 10:22:13 PM

Use On Error Resume Next, and after trying to access the file:

Code: [Select]If Err =0 then
'rest of routine
End If
on error resume next continues processing. I though he wanted on error goto 0Quote from: gh0std0g74 on December 07, 2009, 10:57:18 PM
on error resume next continues processing. I though he wanted on error goto 0

Quote
Is there anything i can add to my vbscript to make it close if it is going to show an error, instead of showing an error.?

...

i just want to make it if it cant find the file then to simply move on to the rest of the function.

On Error Goto 0 disables error handling ALTOGETHER; the error will be shown and the script stopped.It's not working for me i still get an error, but this time not for the path.

Dim objFileSystem, objOutputFile
Dim strOutputFile

Const OPEN_FILE_FOR_APPENDING = 8

' generate a filename base on the script name
strOutputFile = "C:\bla.txt"
If Err =0 then
'rest of routine
End If
On Error Resume Next

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, _
OPEN_FILE_FOR_APPENDING)

IS this right?

I get an expected statement error in the last sentences.the comma is a comment. the "'rest of routine" comment was not actual code but a comment on how to use it.

the OpenTextFile() method is the main way an error will be thrown. On Error Resume Next continues and stores the error number in err; by using On Error Resume next immediately before the CreateTextFile Method, you can check to see if an error occured opening the file; if not, (err=0) you do whatever you are doing with the file; otherwise, you go on without showing the error dialog.

Another possibility, if this script is being executed in a batch, you can use Cscript instead of WScript. The error will be DISPLAYED on the command LINE and batch processing will continue.I am still ending a file not found error.
This is what i have :

Dim objFileSystem, objOutputFile
Dim strOutputFile

Const OPEN_FILE_FOR_APPENDING = 8

strOutputFile = "C:\bla.txt"
If Err =0 then
End If

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, _
OPEN_FILE_FOR_APPENDING)

objOutputFile.WriteLine(" ")

objOutputFile.Close

Set objFileSystem = NothingCode: [Select]Dim objFileSystem, objOutputFile
Dim strOutputFile

Const OPEN_FILE_FOR_APPENDING = 8

strOutputFile = "C:\bla.txt"

Set objFileSystem = CreateObject("Scripting.fileSystemObject")
If objFileSystem.FileExists( strOutputFile ) Then
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, _
OPEN_FILE_FOR_APPENDING)
objOutputFile.WriteLine(" ")

objOutputFile.Close
Else
MsgBox strOutputFile & " not found"
End If

Set objFileSystem = Nothing
Oldun i tried your scipt, i get a completely seperate error that says "C:\bla.txt not found".Quote from: mikefresia on December 10, 2009, 02:41:22 PM
I am still ending a file not found error.

Quote from: mikefresia on December 10, 2009, 10:49:24 PM
Oldun i tried your scipt, i get a completely seperate error that says "C:\bla.txt not found".

They are the same error. The FIRST time you got the error, it was generated by this statement:
Quote
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, _
OPEN_FILE_FOR_APPENDING)

It could have been written as:
Quote
Set objOutputFile = objFileSystem.OpenTextFile(strOutputFile, _
OPEN_FILE_FOR_APPENDING, True)

to create the file (C:\bla.txt) if it doesn't exist, which apparently it doesn't.

The second time you got the error, it was generated by this statement:
Quote
MsgBox strOutputFile & " not found"

This approach was more direct in that it checked to see if the file existed and if not, generated the error message.

In either case, there was no more code in the script (that we could see), so the script went to end of job. Had there been more code you could use the WScript.Quit statement to end your script at any time.

2279.

Solve : Anyone here code in D?

Answer»

I have started to code in D (finally, a real programming language), and I will say, it is quite nice. It is fairly similar to C. In fact, it gives you access to some of the C libraries. SkyIDE is a great choice for D, because it's just an all around awesome IDE, looks like Visual Studio. If anyone wants to know how to get started, you can PM me. tell me something about D. or give me link to readit myselfQuote from: Bukhari1986 on November 29, 2009, 10:20:05 AM

tell me something about D. or give me link to readit myself

Link HereI can't resit.
Is this about a programming language...
or the grade he got in Computer 101?

Quote from: Geek-9pm on November 29, 2009, 12:59:18 PM

Is this about a programming language...
or the grade he got in Computer 101?


It would be funny except for the fact that you got it off the website .

Quote from: Geek-9pm on November 29, 2009, 12:59:18 PM

I can't resit.



Impressive .

I'm using the to much but it fits so who cares. Glad you have a sense of humor.
Some random quotes...
Quote
...the C standard is nearly 500 pages, and the C++ standard is about 750 pages!
D ...doesn't come with a VM, a religion, or an overriding philosophy. It's a PRACTICAL language for practical programmers ...
# Have a short learning curve for programmers comfortable with ...C or C++.
# Provide low level bare metal access as required.
# Make D substantially easier to implement a compiler for than C++.
http://www.digitalmars.com/d/2.0/overview.html

Quote
# Have a short learning curve for programmers comfortable with ...C or C++.

And for those who have never done C or C++ (me). You only need to know 2 things.

1. ; to execute each line, excluding if ELSE statements and defining FUNCTIONS.

2. Static typing, meaning you have to define each VARIABLE type before defining it.

The rest was a piece of cake.

ive heard of d and always wanted to try it but was to lazy, might as well try it now, what are some good resources, and dont say google cause google is a pile of $#17You can just go to the D website download it. I have made a set of batch utilities, but I'm too lazy to host it on a site or put it up for download .
2280.

Solve : Where is the host file in Windows XP x64??

Answer»

IS it in the same as the regular xp home edition. C:\Windows\System32\drivers\etc?Sorry if this is in the wrong categorie%SYSTEMROOT%\system32\drivers\etc, EVEN in XP x64. Are you having trouble finding it?

have you configured your FOLDER options to "show hidden files and folders", "display the contents of system folders" and not to "hide protected operating system files"?

http://blogs.sepago.de/helge/2009/06/04/where-is-the-hosts-file-on-windows-x64/





Yes i couldnt find it, it was hidden, THANKS alot

2281.

Solve : [C++] Executable does nothing when running simple iostream program?

Answer»

its deprecated, you have to say "using namespace STD"
like this:

#include
using namespace std;
void main()
{
cout << "Hello World!"
}

you're probably following too old tutorialsif you use vham.exe you can make this automatic.
1.just write your source
2.PRESS edit>executable>
3.write your name of your game/program
4.save it typ in dos IE00 CHK
5. if your program has no error it is succesfully else the program will fail like a flashI think this is what you wanted? Your original code does run after doing the compiling. I compiled with M$ visual C++ 2008 express edition (on Vista 32 bit home edition)

1.Open start menu
2. In the search box, type CMD and press Enter when CMD is found
3. open up the folder where your EXE exists if not already there. Then type in name of program.
4. I did the above three STEPS and I see following (and I just saved the FILE as "jack.exe in a folder named C++")

NOTE: don't just double click EXE to attempt running it, actually manually open CMD then run it. Else, the program might just exit too quickly for you to see actually the result. This might be why you think program is not working, or you only see a quick flash and then nothing again IF you are sure that you have followed the appropriate steps to compiling your code via your compiler

Here is screenshot of result:




Here is code I compiled:
Code: [Select]#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
char clr[5] = {'o','h','d','s','c'};
char nmr[10] = {'0','A','J','Q','K','@','#','7','8','9'};

cout << "The Jack of Spades (3;2) is abbreviated: " << clr[3] << "" << nmr[2];


cout << "How Awesome...";

cin.get();
return 0;
}
I got rid of int a, because it is an unused variable as is. Don't know what you wanted use a to do. And I find M$ Visual C++ express edition (the free edition of their professional software) to be relatively good to use.

2282.

Solve : Calling programs from c++?

Answer»

Im trying to call a program from my c++ program, ive got it to work if i put the program im CALLING in c:/ but if i put it in a folder with a SPACE in its name like 'C:/Program Files' it doesnt see anything after the space, if there is a better way to call programs please let me know. Help will be greatly appreciated.

#include
#include

using namespace std;

int main()
{
cout <<"enter: ";
char a[100];
cin.getline(a , 100);
system(a);

system("pause");
}
use quotes around the filename.Boy, my eyesight is very bad.
I can't find the file name that is not in quotes.Quote from: Geek-9pm on December 18, 2009, 10:12:16 PM

Boy, my eyesight is very bad.
I can't find the file name that is not in quotes.

Quote
system(a);

should be system(STRCAT("\"",strcat(a,"\"")))

or something along those lines. regardless... WHATEVER is in a should be quoted.
2283.

Solve : utilizing the ALU?

Answer»

Once I eMailed a college instructor. I was just inquiring about a programming class that was offered at the time. He mentioned that if I want to learn programming, I should learn trigonometry. Of course I didn't understand what the heck that meant. But later I read in Upgrading and Repairing PCs that if you want to take advantage of the Arithmatic Logic Unit in any cpu, code has to be specifically written for it. Since the ALU deals with "more complex" math operations, I could only conclude that this is what the instructor was talking about.. Is this accurate? What is the relationship between mathematics and the field of computer SCIENCE?
Quote

Computer science is broadly concerned with the application of both mathematics and logic to the task of designing and controlling computers. Certain branches of mathematics are of special value in computer science such as boolean algebra and discrete mathematics. One place where math is applied is in the microprocessor unit of a computer which executes a stream of simple operations including arithmetic operations.

Based on the answers I found from WikiAnswers I believe the college instructor is accurate.Not really. the ALU is part of the actual CPU itself- you must mean the FPU, for floating point, which used to be a separate add-on on before the 486DX (so we had the 287 co-processor, 386 coprocessor, etc.

And really, I don't see why you'd need much of a background in trigonometry; certainly high-school trig has been enough for me so far, and I've had a few pretty trig-intensive projects. (my geometry/drawing library, for example).I can see where the instructor was coming from. It's not so much trig per se, more the mindset it encourages and nurtures in an apt PUPIL, to do with thinking logically about problem solving and developing formal proofs that I reckon the teacher was thinking about. Algebra would come in handy too. I know these are dull unfashionable subjects these days.

Well I know Algebra... I've past the prerequisite for taking Trig. at a community college, so I've got basic logical thinking down. I've taken some digital classes also where boolean algebra, binary, hex, and other number systems were emphasized.

thx all Quote
And really, I don't see why you'd need much of a background in trigonometry;
What is that supposed to mean?
Real Life engineering problems are solved using some branch of trigonometry.Quote from: Geek-9pm on December 17, 2009, 01:57:49 PM
What is that supposed to mean?
Real Life engineering problems are solved using some branch of trigonometry.

engineering and programming are different things. a strong background is far from required; I have only gone through high-school and I've used a lot of trig in many of my programs (actually, I only wrote the code once, and reused it thereafter.).

"Real-life engineering" and "programming" aren't synonymous. One is engineering. One is programming. They certainly have an overlap, but the point is, you don't need to be an engineer to program any more then you need to be a programmer to... um.... engineer. (And don't get me started on that whole invented vocation of "Software engineer" it sounds almost like some sort of cover, like "Sanitation Engineer".

Additionally, having a strong grasp of trig- or math, even- is really quite useless when you design a UI. I mean, the users only want it to be easy to use- they don't give a *censored* if the number of pixels between adjoining buttons is a prime number or any of that.

Engineering programmers solve engineering problems. for engineers. Therefore they can expose their users (engineers) to such arcane things as using j for complex numbers or engineering formulae. A Program to simulate the pressure and flow of liquid through a pipe given the pipes diameter, the material of which it is constructed, and the viscosity of the liquid flowing through it may be useful to engineers designing pipes, but is completely useless to the average person (unless they really really really like Mario and wish to examine how quickly he moves through pipes, or something).


Also, I MIGHT add that while such programming jobs are extremely invaluable- you don't hear about them. Really, when somebody invents, say, a new pipe system, or a new material, or a new type of plastic, do they ever say, "And these are the programmers that wrote the program that helped me synthesize this plastic" or anything? No. They get their god *censored* nobel prize and the people responsible for the software that made it possible are discarded like a used diaper. The programmers who get recognition are the ones who deal with ordinary users- and while occasionally this may require some trigonometry; the very mindset of a good programmer makes it easy to absorb this information; and, really, any sort of mathematic study, when the situation requires. which may be the point- the fact is, you don't need a strong background in trigonometry, because the very essence of a programmer means that, where trig is required- they will learn it. It's one thing to learn about trigonometry in a classroom setting, it's quite another to use it and "re-learn" it in a setting were the output isn't simply numbers on an answer sheet but real world results in a program- where errors can be seen nearly instantaneously.

To illustrate my point; again- I only have "officially" a high-school education in... well, formally, anything, I suppose. I would be in a far less intelligent boat if I had never found programming, since it essentially made me revisit the old subjects (well, except english, I suppose, but I've always been pretty good with language), and they gave them a new "face" so to speak, and made them interesting. While Complex numbers were only mentioned in passing in school, I had a firm understanding of them quickly. Why? I wrote a class that performed Complex arithmetic. the Benefit? Now my evaluator supports complex numbers. I was in fact even considering adding HyperComplex and Quaternions, but, I figured that was a bit overboard.

Reiterating once again- it is not WHAT you know that determines wether you'll make a good programmer, but really, it's a matter of how your mind absorbs information; some people's minds don't work in a way that lends itself to formulating instructions for a computer. Which actually works great because their interests usually lie elsewhere.

B, you are arguing about a strong background in trigonometry. What I meant was you need to have a basic understanding of trigonometry and related ideas in order to deal with things in real life. In the real world people have to manage, maintain, modify, re-build and re-create many things about them. They have to have some concept of special reasoning. They have to be able to see things in a three-dimensional world and be able to understand the relationship between mass and size area and volume and so on. Even if a person does not have a formal understanding of these things, he still has to have the concept. A common problem many people have is not understanding the idea of geometric expansion. This is a real world problem. People think that if they know how to build a one-story house, they'll be no problem in building a two-story house, or even a three-story house. Individual has to have some fundamental concept of how things get larger and how their characteristics change in the real world. Oftentimes we use models to explain things or illustrates the ideas. We have to understand the relationships between a model and the full size article. Even if you're not into any kind of building work, let's say you're even just working in on a farm. Even then you have to understand basic concepts of how a calf is going to require more and more food as it gets bigger and bigger. And this requires some basic understanding of math. And if you going to buy more cows and you're going to buy more land, eventually you'll come into a problem that could be easily solved by a basic knowledge of trigonometry. No, I did not mean to say that a person has to have a deep knowledge of these kind of concepts. I meant to say you have to understand the basic idea. And yes, this is also related to algebra.
Not that I'm in favor of drowning students in algebra. It should be made easy to understand and they should understand the concepts. Being able to figure out trick problems is not the goal. Use of mathematical methods is one way to solve problems where we have some known things and some things are not unknown and we try to make an estimate of what the outcome will be.
Programmers make serious errors when trying to estimate the amount of man hours that it will take to complete a project. Hotshot programmers almost always fail to estimate the amount of time it will take to get the program completely debugged, documented and delivered to the user. This has nothing to do with understanding how to make a programmer friendly to the user. The idea here is to not just create a nice graphical user interface, but to be able to debug, refine, verify and catalog it. Some junior programmers have no idea that if they use certain types of functions in their program they're going to eat up all the disk space available. They don't understand the math involved. There's a big difference between a recursive program that makes 32 iterations and a recursive program that makes 48 iterations.
Oh my, this is getting to be a rant. A formal degree in CS or IT requires Mathematics. Higher or basic mathematics train you to think logically in developing programs. It's up to you if you don't want Trigonometry, but in formal education, indeed you need mathematics.

If you're not satisfied enough, try to consult a PhD. or DSC. in Computing/CS.Formally, yes. you will need something like that as a prerequisite. And really- it can only help. but the way it was phrased, it appears that this was an "informal" recommendation:

Quote
He mentioned that if I want to learn programming, I should learn trigonometry.

in my mind, I see a conversation like this:

"hey, I want to learn programming."

"oh really? Well, I think, you should learn trigonometry first."

which is completely baseless; there is no statement of pre-requisites, which their certainly will be- it was basically saying, "well, you need to know trig before you can take programming! Everybody knows you can't parse a string without knowing the Sine Laws!".

Also, completely OT but I personally find formal degrees meaningless. I've met people that supposedly have CS degrees who are about as intelligent as a cantaloupe, and would certainly find competition from one. Now, this obviously is not the case for everybody who goes through it, but it's pretty redundant- the way software is written in academia is a lot different from the way it really is.

Quote
Higher or basic mathematics train you to think logically in developing programs.

I see what you mean here... but that isn't really strictly true; the mindset of a mathematician does not necessarily mean they would be a good programmer, for example.

What's important is analytical thinking and, basically, using a set of tools (functions, statements, control structures) to perform a specific task. This is the easy part. What's important then is finding ways to make it go faster.

A example might be sorting; almost any person who took even the most basic programming course can probably write a bubble sort function in some language; it's really quite basic, and the code flow is easy to follow.

But even programmers in the industry have trouble writing a quick-sort, ot shell-sort function. why? well, for many languages, such as python, sorting has become an atomic action. Sure, understanding the concepts behind it is important, but for most cases, it's enough to know that it sorts. It's not important How it sorts.

Academia finds all sorts of esoteric methods of sorting- this is how the quicksort (or my favourite, the shell sort) came about- through intense study of the problem. However, it's important to realize that the same skills do not necessarily translate to financially sustainable programming in all scenarios.

Basically- I feel that programming is not something that everybody can learn, regardless of the courses taken. Certainly anybody can take a programming course; but that doesn't make anybody a good (or even a mediocre) programmer any more then, say, a course in psychology can make a person a good psychologist. There are a number of different personality traits and aptitudes that are important in becoming a programmer, just as there are a number of important personality traits and aptitudes to becoming a psychologist.

What ends up happening is that the wrong people might want to work in the industry, and they can, but they will have larger barriers to overcome them people who "have the knack" for it.

What does this have to do with the topic? Well, actually, I forgot. Oh well.

Keep going guys. I like this thread.

Quote
"hey, I want to learn programming."
"oh really? Well, I think, you should learn trigonometry first."
which is completely baseless; there is no statement of pre-requisites

But in formal education, this is a prerequisite right?

Maybe it's up to the person if he/she really want to be a programmer regardless of education. He/She can be what he want! :-)

In my opinion, a programmer for me is a gifted person. Hehe. Lots of peeps out there dream to become one but not all are successful. Quote from: geek hoodlum on December 18, 2009, 01:43:59 AM
But in formal education, this is a prerequisite right?

True, I suppose really I'm splitting hairs. What I mean is, it sounds more like a comment that was made colloqiually- a recommendation. Now that I think of it over again, it certainly cannot hurt to take those courses. Heck I wish trig stuff had been fresh in my mind when I was working on my basemetry library. All I could remember was SOHCAHTOA... forget the Sine laws or any of that, heh.

In fact things went reverse for me, oddly. I was able to use my programming abilities to help me in math- since we were supposed to have a graphing calculator (In fact, TBH the whole class seemed like a tutorial on the freaking thing sometimes... "this is how you do standard deviation..." And- they don't even tell you the freakin formula until half-way through that section, and even then it's merely regarded as a "trivial detail". Ridiculous.


Not to say I did badly in the course without my programming- I went through the first 3/4 of the course with just a scientific calculator... I had to look up half the bloody formulae for the course, since, as I just mentioned, it was basically a bunch of lessons on what buttons to push.

Anyway- as I was saying- I made the whole thing a LOT easier then it even was once I had the TI-83, since I wrote a good number of programs that pretty much made the final exam a bunch of mindless button pushing.

I didn't get 100% because I had to skip a few synthetic division questions. strangely I remember WHY I didn't, and never have, had any really grasp of synthetic division- it was because I was writing design specs for programs in grade 10 instead of paying attention .

I've never really considered myself that good with math, but now that I think about it, I might be wrong. I mean I WAS the only one in the course who calculated through the quadratic formula more then once. (thereafter, people all used a graphing calculator program that was provided... I of course wrote my own instead, and a good number of utilities, too.BC is right even if you did Assembly programming for a specific proccessor you wouldn't need any prior knowledge(not including the actual commands and flags of course ) but you would still need some basic knowledge on how it'll actually run from the command structure and sequence, not to mention that ASM is just broken into different bytes, these bytes neccessary to know how they interface with the different parts of the system are basically read by a memory access circuit that 'directs' the bytes to the different sections(ALU, outputs, INPUTS, etc.)

If you were to access the ALU it would be kinda pointless to do so since its already built-in. You would have to learn Binary Logic/Mathematics since thats basically how the Memory, ALU, and other parts work. They use electrical gates that give a output according to the input(Like a proccessor) but they have specific wiring that makes them only output when certain conditions are true.

For example an AND gate takes two(or more) inputs and if all the inputs are true(when a 1 is applied) then the output becomes 1.
The outcomes of the gates is shown on something called a Truth Table:


This is all shown in Binary Math/Logics.
2284.

Solve : uploading & downloading the data from a URL?

Answer»

hai

I NEED to know how to update and download data's from one database to another by hitting URL making to SYNCHRONISE it everytime.Some people said that we can do it by calling an API through an XML programme but i don't know how to do it.Please can anyone GUIDE me in this regard.

Thanx in advance

best wishes
somasundaram.p
try this save the web go to the LOCATION where you saved him. take out files

else

try to edit your saved url so you can plaste the objects to your site

i hope this WORKS :/Quote from: aiko on December 19, 2009, 03:09:07 PM

try this save the web go to the location where you saved him. take out files

else

try to edit your saved url so you can plaste the objects to your site

i hope this works :/
2285.

Solve : .bat file help needed......?

Answer»

If I launch a SIMPLE bat FILE from a path on a network:
\\WinSrv\cr5\Dept400\me\Testing\batFiles\

then the bat executes goes to a Unix path and grabs a file (my question is this) it should then place it in here:
\\WinSrv\cr5\Dept400\me\Testing\batFiles\
Since that was where the bat file was launched from ? But I am not getting that result. Testing it in the C:\ it worked fine from the WinSrv path it did not work.

Is there a better way?

notes: %1 = userID, %2 = userPW, %3 = fileName

Code: [Select]Echo %1> ftpcmd.txt
echo %2>> ftpcmd.txt
echo ascii>> ftpcmd.txt
echo prompt n>>ftpcmd.txt
echo cd /unixPath1/parts/parts2/b/xm/data/>> ftpcmd.txt
echo get %3>> ftpcmd.txt
echo bye >> ftpcmd.txt
ftp -s:ftpcmd.txt 100.11.100.01
del ftpcmd.txt
ren \\WinSrv\cr5\Dept400\me\Testing\batFiles\%3 %3.txt
quit


btw this is a really nice forum! It's got a different look and feel to it........nice job!Your post is hard to understnad.
Are you trying to move a file from your local; machine to a sever on the network?
Where is the batch file?
What is the detonation directory?
This notation:
Quote

notes: %1 = userID, %2 = userPW, %3 = fileName
Is a bit hard to follow. Can you just give the actual invocation? Or something very close. Like MAYBE:
Quote
myupload pinkpatty qwerty mybiki.jpg
You have the path name two different WAYS. Why?
Where did you expect the file to go?
What is the full name of the detonation you want?
Quote
Since that was where the bat file was launched from
Are you sure of that? Quote from: Geek-9pm on DECEMBER 18, 2009, 10:05:22 PM
Your post is hard to understnad.
Are you trying to move a file from your local; machine to a sever on the network?

I am using the get command from Unix server to a windows server; I am working from a pc on a network.
Once I log into Unix I cd /unixPath1/parts/parts2/b/xm/data Needed Is Here/>>

Quote from: Geek-9pm on December 18, 2009, 10:05:22 PM
Where is the batch file?
What is the detonation directory?

\\WinSrv\cr5\Dept400\me\Testing\batFiles\batFileIsHere.bat
\\WinSrv\cr5\Dept400\me\Testing\batFiles\destination Is Here also
I give up.Quote from: Geek-9pm on December 19, 2009, 12:53:47 PM
I give up.

I think I have it now:

Code: [Select]Echo %1> ftpcmd.txt
echo %2>> ftpcmd.txt
echo ascii>> ftpcmd.txt
echo prompt n>>ftpcmd.txt
echo cd /unixPath1/parts/parts2/b/xm/data/>> ftpcmd.txt
echo get "%3" "%3">> ftpcmd.txt
echo bye >> ftpcmd.txt
ftp -s:ftpcmd.txt 100.11.100.01
del ftpcmd.txt
lcd \\WinSrv\cr5\Dept400\me\Testing\batFiles\
ren "%3" "%3.txt"
quit
Glad I was able to help. Quote from: Geek-9pm on December 19, 2009, 06:33:17 PM
Glad I was able to help.

LOL


yeah, no matter how tough things got you never gave up!
2286.

Solve : How to add date to folder in batch-file?

Answer»

I need a little bit help with batch-files: how can I rename a folder in a bat-file so that it CONTAINS a current date - such as folder1_20090108 (or any other date string format)? Without the need of typing the date myself, of course

I'm planning to create a simple batch file that would make a backup copy of one certain folder that contains my school project, and need that date to identify the version.

Cheers

JussiIt's always difficult when we do not know the format of your date which you didn't advise. Here is a rename if your date format is 'day mm/dd/yyyy' - not tested.

Ren folder1 folder1_%date:~-4%%date:~4,2%%date:~7,2%

Renamed folder should be in the format folder1_yyyymmdd

You can substitute Copy for Ren when you copy the folder, no sense in copying then renaming.

Hope this helps.Quote from: Dusty on January 09, 2010, 02:30:47 AM

It's always difficult when we do not know the format of your date which you didn't advise. Here is a rename if your date format is 'day mm/dd/yyyy' - not tested.

Ren folder1 folder1_%date:~-4%%date:~4,2%%date:~7,2%

Renamed folder should be in the format folder1_yyyymmdd

You can substitute Copy for Ren when you copy the folder, no sense in copying then renaming.

Hope this helps.

Thanks for the code. My mistake, I didn't explain the ORDER of numbers at example in my post - I did indeed mean format yyyymmdd.

-JussiDusty MEANS, you need to tell us the local date format you are using. You can see it using the date /t command. For example my local settings make the date look like this

Code: [Select]C:\>date /t
09/01/2010
Or use a vbs / batch hybrid which is locale - independent

Code: [Select]@echo off
Echo Wscript.echo eval(WScript.Arguments(0))>evaluate.vbs
For /f "delims=" %%Y in ( ' cscript //nologo evaluate.vbs "year(date)" ' ) do set yyyy=%%Y
For /f "delims=" %%M in ( ' cscript //nologo evaluate.vbs "month(date)" ' ) do set mm=%%M
For /f "delims=" %%D in ( ' cscript //nologo evaluate.vbs "day(date)" ' ) do set dd=%%D
del evaluate.vbs
if %mm% LSS 10 set mm=0%mm%
if %dd% LSS 10 set dd=0%dd%
set datestamp=%yyyy%%mm%%dd%
echo Datestamp is %datestamp%

Code: [Select]Datestamp is 20100109
2287.

Solve : robot help?

Answer»

i wanna MAKE a robot is this macro good?
CODE: [Select]Check.value ? 0
TmrBreathe.? false
TickStart ? GetTick
)CurrentPos ? 0
)StartPos? Left ; *Shape.Width 2(
PastPos ? 0

If CmdPlay.Tag Then
CmdPlay.Caption ? @[emailprotected]
FrmSystem.Enebled ? CmdPlay.Tag ? 1
else
CmdPlay.Caption ? @[emailprotected]
mSystem.bled ? True
Cmdplay.Tag ? 0
Cmdloop.Tag ? 1
CmdLoop&Click
End if

Do Until CurrentPos |? TrickTiOr Play.Tag / 0
PastPos ? StartPs ; Abs*GtTick / TickStart(
If ChkUDP.Value ? 1 AbsGetTick / TickStart( |? PlayLength Then
Call CmdPl& xt Sub
Ed if
DoEvents
Shape1.Left ? CurrentPos / Shape1.idth - (
If CurrentPos |? 1 And CurrentPos \? TickTime OutPutSig *CurrentPos(
End if
Loop

Done>
If CmdPlay.? 1 Then
CmdPlay.Caption ? @[emailprotected]
CmdPlay.Tag ? 0
System.Enebled ? TrueCrap! Darn, my keyboard does't not WORK good with this forumYour keyboard......?yes USA is a another country and your key BOARD is QWERTY
my keyboard KANOSU i live in japanYou can have two keyboards on one computer and you can switch between languages.

http://msdn.microsoft.com/en-us/goglobal/bb688179.aspx
http://www.microsoft.com/resources/msdn/goglobal/keyboards/kbdusx.htm
http://www.microsoft.com/resources/msdn/goglobal/keyboards/kbdJapan.htm

For the last two links, you will get a pop-up. Don't worry, it is from Microsoft so it is absolutely SAFE. Place you cursor over a key for more information

EDIT: Hey, if you have the right keyboard you switch to English by tapping the Kama key. i've a japanese pc

2288.

Solve : I want to start programming on a Macbook.?

Answer»

So, I am still in high school and want to pursue a career in computer programming. Before I do, I wanted to check out what it is like. I have been reading stuff, and a lot of people start way before they graduate high school Soo, I wanted to know if any one knew any good websites/applications I could get to teach me the fundamentals of programming on my mac. I have OS X 10.4.11 Tiger. Thanks ahead for any help. Macs use the X-Code Program for developing however if you are starting out I would recommend Microsoft Visual Basic which is PC only - If you have an Intel Mac you could set up a dual boot with OSX and Windows so you can use VB.What is your long-term objective?
Do you wish to be an actual programmer?
Oar are you more inclined to manage people and business decisions?
Either way, you do well to find a well-structured study guide.
Are you a good reader? How are your communication skills?
And have you made use of the advice you have in your neighborhood?

First rule of serious study is to not have faith in what you read on the Internet.
Except, of curse, my advice. I would never mislead your. Trust me.
Quote from: camerongray on January 11, 2010, 09:28:16 AM

Macs use the X-Code Program for developing however if you are starting out I would recommend Microsoft Visual Basic which is PC only - If you have an Intel Mac you could set up a dual boot with OSX and Windows so you can use VB.

Um... no. Visual Basic 6 is not cheap, and it's impossible to find. And .NET is even more expensive. And Either way, even with the express version, it doesn't get them any closer to their goal of programming OS-X.


you can use Script LANGUAGES on Mac OS-X; Python, for example. Also, Mac OS-X programs are GENERALLY written using C++; XCode just happens to be a tool used to write C/C++ for the mac OS-X. Just as you don't have to use Microsoft Visual C++ to write Windows Programs, there are FREE alternatives. Since OS-X is based on UNIX, many free alternatives, such as GCC exist.

Personally, I'd start learning programming concepts with a Operating-System neutral language, and then learn about the UI side of things a little later. From what I understand, the OS-X API is called "Cocoa" and while generally accessed from C, I'm sure there are ways to leverage it from python or another script language. Visual Basic is only for programming Windows-based applications; and it will be of little use KNOWING Visual Basic. Python (well ,really, a number of scripting languages, such as perl and so forth, too) are available on almost any platform, so knowing one of then good is enough to do something useful on nearly any operating system. And yes I do sound like ghostdog in this post, but hey, he makes some good points.

Quote from: Geek-9pm on January 11, 2010, 09:39:34 AM
First rule of serious study is to not have faith in what you read on the Internet.

I believe a more appropriate rephrasing would be to not have faith for what you find on the internet at large; most scripting languages, and even compiled languages, have some sort of official, trustable reference material; python.org; w3schools for most web languages; It's the random little web pages started on geocities and angelfire that purport to help you that you want to stay away from.

Additionally, Monsieur geek, you perhaps misread the original post:

Quote
What is your long-term objective?
Do you wish to be an actual programmer?

If you would kindly re-read their first sentence, it pretty much answers your question!

Quote
So, I am still in high school and want to pursue a career in computer programming.

Quote
Quote
So, I am still in high school and want to pursue a career in computer programming.
Tongue
Let's agree on one ting. Something that will GIVE him...
a broad based tool that will lead him to his goal.

Python

Python Programming Language -- Official Website
http://www.python.org/

(I am so glad you did not recommend VB 6.)
2289.

Solve : In need of a sample menu program written in QBASIC?

Answer»

I have just rebuilt an old IBM Aptiva and have put just DOS 6.22 on it. I am going to use this SYSTEM just for old DOS games and would like to have a menu to make it easy for everyone who may use it to choose which game they would like to play. QBASIC is already on here but my problem is that I have not used it in over 25 years and have forgotten how to use it. I have a total of 18 categories that I will have on it, maybe more later as I expand. Some categories to get started with are: Trivia; Board and Card Games; 3D Shooting; Simulation; and Space. Some games to get me started with and their cat.: 3D Shooting; DOOM, DOOM II, Duke Nukem 3D; Simulation; SimTower, SimCity, SimCity 2000; Trivia; Bible Trivia, STAR Trek: TNG, Star Trek; Space; EGA Trek. As for the file path, I know I will have to insert that myself but should be marked so that I know where. Thank you so much in advance.

AndyWhich version of QBASIC?
from dos you can run a QNASIC program this way

QBASIC MENU /RUN

It will load and run MENU.BAS, if it is a valid file.

Code: [Select]10 REM SIMPLE MENU
PRINT "your choice"
PRINT "1 Nuke eem"
PRINT "2 Sim Ciry"
INPUT a
IF a = 1 THEN SHELL "DIR N*"
IF a = 2 THEN SHELL "DIR S*"
GOTO 10
Thank you, that helped a little. I have expaned on that a lot.

AndyWith respect, you could always use "Direct ACCESS 5". I have to use this 1982 software in running VBDOS PROGRAMMES in XP.Quote from: KRAUSS on January 08, 2010, 07:14:39 PM

With respect, you could always use "Direct Access 5". I have to use this 1982 software in running VBDOS programmes in XP.

Where from? It is not built-in
2290.

Solve : Programming language idea (not a question)?

Answer»

Quote from: aiko on December 18, 2009, 02:04:41 PM

i think it is impassible to do this all alone you need someone else you need a lot of people to make commands to program to test and more it's impassible but don't give up it could happen if you have a lot of people to work with and i think it is impassible to do alone

No, it's actually quite "passible". it's a good little one-man project.

yeah i know, but what i mean is
if he/she want to do this you need to have more people else it's to muchRight here!
We will help the OP.
http://en.wikipedia.org/wiki/Tiny_C_Compiler
That is a start. You can see how SOMEBODY else did a very small C INTERPRETER.
cats of course, he does not have to duplicate that effort. That would be pointless. But it should increase him to see how that that individual along with others developed a very small implementation of a language that is considered to be rather difficult.
In the original poster could call his new language almost anything he WANTS. There are no fast and hard rules about how you do something for your own entertainment. As long as it does not infringe on the rights of others.
Also, the language does not even have to be complete. It does not have to pass any academic standard. It does not have to be flawless. If it produces some result that pleases the creator, that is good. WHETHER or not other people would approve should not be the criteria. Now some point, he might want to publish his work. That would be another issue.
A simple interpreter with a built-in line editor can be made in about all I would say, maybe just under 3000 lines of code. I just don't remember. That was a long time ago when I did that.
Quote from: aiko on December 19, 2009, 03:04:23 PM
yeah i know, but what i mean is
if he/she want to do this you need to have more people else it's to much

No. It isn't, actually. It might be overwhelming if they had no design; but they have already planned out a good bit of the project, and once you have a good design the programming behind it often comes a lot easier.

Oh, and I WROTE a far more comprehensive and complicated Script language myself.. one person. It literally took a single night after good design much like the original posters, whereas many of my other whimsy project that I go into without any real plan take ages, and even then I usually end up scrapping it all and starting again with the design stage.Quote
It literally took a single night after
good design much like the original posters
That's right on target!
2291.

Solve : C++ graphics.h?

Answer»

Hello, I was WONDERING how to use GRAPHICS.h in c++, I couldnt find any good tutorials on google, so can anyone help me, I am using BCC55 on Windows XP, thanks.Hello,

I would use other graphics LIBRARIES. The days of BGI graphics are long gone... cool, ill try something ELSE

2292.

Solve : Reading a value from a file, then comparing it??

Answer»

Hello all,

I am trying to have this batch STORE a variable read from a file with value INSIDE of it.
Here is what I have so far, but it seems it cannot set the variable. This is bewildering.
Code: [Select]@echo off
cd %userprofile%
for /f "delims=" %%a in (code.ini) do (
echo %%a
set code= <code.ini
)
ECHO Code is:
ECHO '%code%'
Which results in this:
Code: [Select]a1b2C3d4e5
ECHO is off.
Code is:
''Perhaps I have the syntax wrong?

Any helpful advice would be greatly appreciatedThis is wrong.

Code: [Select]set code= <code.ini
You need help with the set command.
Say this:
help set
And read it over.
for READING and parsing ini files, you can use vbscript
Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject")
strFile = WScript.Arguments.Item(0)
WScript.Echo objFS.OpenTextFile(strFile).ReadLine
usage:
Code: [Select]c:\test> cscript //nologo readline.vbs myini.ini
Set /p var=the above will work for you. QUOTE from: Helpmeh on December 13, 2009, 09:02:04 PM

Set /p var=<file.ini
the above will work for you.

Once again the only useful help posted! You rock helpmeh.Quote from: PPowerHouseK on December 19, 2009, 10:19:09 AM
Once again the only useful help posted! You rock helpmeh.
Thanks. I remember trying to use the set command to get a variable from a file. It was PRETTY brutal.
2293.

Solve : automatic validation?

Answer»

can someone create a program or a batch file where this will answer itself?




6



http://seriouswars.net/macro2.php?action=validate">


One

Two

Three

Four

Five

Six

Seven

Eight

Nine









Yes. There are things that do that.
If you had it, how would you USE it?
Things that do that do not parse the actual HTML code. They just scan the output for places where input is needed and fill in the values.

I think it is called AUTO-Form Fill.
Search Google: Auto-Fill Webbasicly i use macros for everything but this validation - i ALWAYS have to answer it every 20 minutes - if a batch file is CREATED i can set up a scheduler to automatically RUN the batch file.Did you try the thing Google has?yes i tried the auto fill - these do not work i need something that will submit the correct answer at the end of the batch file
2294.

Solve : hspice?

Answer»

hellooooooooooo

does some one know how to implement a cmos full adder ?
I need the hspice code oh wow

having worked on a circuit simulator (a SPICE clone for the Sinclair QL) in the 1980s I can TELL you that you need a much, much more specialised forum than this one, good though it is.

The fact that a quick Google SHOWS a full cmos adder netlist in "SOLUTIONS to homework" at ece.ucsb.edu makes me WONDER why you are asking? And if you are a lazy student? So lazy you cannot Google?

2295.

Solve : shell commands with php?

Answer»

Hello, I am trying to create a screen capture program with Xvfb SERVER, ImageMagick and Khtml2PNG.
I seem to be having some issues and was hoping someone could help me out.

I have everything installed and working on a centos WHM/CPanel system and am able to generate the screen shots and save them to root folder from shell with the following commands.

Xvfb :2 -screen 0 1024x768x24&
export DISPLAY=localhost:2.0
khtml2png2 --SW 200 --sh 150 http://www.example.com example.png

It works 100% fine when you run it from shell.

I have created the following php script to run the exact same commands but get no RESULTS.

$connection = ssh2_connect('xxxxxxxxxxxxxx', 22);
ssh2_auth_password($connection, 'root', 'xxxxxxxxxxxxxx');

$stream = ssh2_exec($connection, 'Xvfb :2 -screen 0 1024x768x24&');
sleep(15);
$stream = ssh2_exec($connection, 'export DISPLAY=localhost:2.0');
sleep(2);
$stream = ssh2_exec($connection, 'khtml2png2 --sw 200 --sh 150 http://www.example.com example.png');
sleep(7);

echo "All done!";
?&GT;


Does anyone know why this would work fine from shell but NOT work at all when I run it from the php script?

Thanks in advance!

2296.

Solve : how to delete exe?

Answer»

i've made a exe file but i can't delete it anymore if i try windows send a MESSAGE box(msgbox "")
you COULD not delete this exe file it is in use by someone...

how to fix it ... it is freaking me out........by a program called tune up it erase it


POST edited for content.Try restarting the computer, then delete it. this all did't workYou could give this a try:
http://www.diamondcs.com.au/freeutilities/dellater.php
try starting in safe mode, start computer then just tap f8 constantly till a menu pops up, choose start in safemode and you should be ABLE to delete it

2297.

Solve : Merge Sort without recursion?

Answer» HI all ,

I NEED to write the merge sort non recursive algorithm .
Can some one plz help me to do that.

THANKS In advanceIs this homework?
Here is some code the shows how to do this.
To really understand it you have to go to your library and ch ck out the book
http://www.irt.org/script/501.htm

Knuth, D. The art of computer programming, vol. 3
SORTING and searching

thanks for reply
I'll check it , thanks
2298.

Solve : Problem With my acer laptop?

Answer»

My acer aspire laptop doesn't play some games such as call of duty 4, it just says 'Video card or driver doesn't support UBYTE4N vertex data' How can i solve this problem? Hello,
Did you Google that?
UBYTE4N
There are a number of references to this all over the Internet. You could've just did a Google by yourselves and found lots of people already had this problem. Anyway, the general story is that your hardware is just not compatible with that game. So, either forget the game, or buy new hardware.
If you think there should be a simpler answer, sorry, it's not likely.

But please do not go away mad. allow me to ask you about the vendor that sold you the software. He should have posted on his website information about the requirements for the game. If not, then you have a valid reason to ask for a refund. This is so even if you are ready open package. Here in the United States, I assume you BOUGHT it from a vendor here in the United States, there are laws regarding information and accuracy in ADVERTISING. If the game had been advertised in such a way as to imply or suggest that it would work on any of the newer COMPUTERS, including yours, then you would have reasonable cause to complain against this vendor.
If that says it's your case, we would like to know who that vendor is so that the rest of us can be aware.
in the future, go to the website http://www.canyourunit.com to see if you can run a gameQuote from: Geek-9pm on December 19, 2009, 01:09:23 PM

If the game had been advertised in such a way as to imply or suggest that it would work on any of the newer computers, including yours, then you would have reasonable cause to complain against this vendor.

I believe the game requirements preclude any sort of laptop configuration that would have integrated Intel GRAPHICS, as is the case here.Meanwhile, BACK at Intel:
http://www.intel.com/support/graphics/sb/CS-028686.htm
2299.

Solve : radix 2 srt division?

Answer»

hello
Does somebody knows about RADIX 2 SRT division ?
I cant understand all of it !

z : dividend
d : divisor
Q : quotient
s : remainder

this is the algorithm(pseudo CODE) :

z = s(0)
for j=1 to k
if 2s(j-1) > 1/2 then
q(j) = 1;
s(j) = 2s(j-1) -d ;
els if s(j-1) <-1/2 then
q(j) = -1;
s(j) = 2s(j-1) +d ;
else
q(j) = 0;
s(j) = 2s(j-1);
end if ;
end for;


and this is an example :


z0.01000101
d0.1010
-d1.0110
=============================
s(0)0.01000101
2s(0)0.1000101>1/2 so q(-1)=1
+(-d)
=============================
s(1)1.1110101
2s(1)1.110101in [-1/2,1/2) so q(-2)=0
=============================
s(2)1.110101
2s(2)1.10101<-1/2 so q(-3)=-1
+d0.1010

=============================
s(3)0.01001
2s(3)0.1001>1/2 so q(-4)=1
+(-d)1.0110
=============================
s(4) 1.1111negative so add to correct
2s(4)0.1010
=============================
s(4)0.1001
s0.0000 1001
q0.10(-1)1uncorrect BSD quotient
q0.0110convert and subtract ulp

i think this is not true : (line 13)
s(2)1.110101
2s(2)1.10101<-1/2 so q(-3)=-1
+d0.1010

and what is "ulp" and how convert 0.1.(-1)1 to 0.0110 ?

THNX

2300.

Solve : Visual Basic, C++, or Java??

Answer»

I have a project I need to create a program for, but first I need to decide what language to learn in order to create the program. I'm considering Basic, C++ or Java, but any other suggestion would be nice. I've been asked if I could do this by some friends who are teachers here. They want to use it in a summer camp they're doing.

About the program:
The program is for a live-action, turn-based RPG of sorts. The program needs to keep TRACK of certain statistics, modifying the values each turn based on user input (values added from things like trade) and computer monitored statistics (levels that fluctuate each turn based on variables), display small pictures alongside text (jpg or other format of images contained in a folder with the program), and some other functions.

Layout:
There will be one main window which lists all of the statistics, has an "end turn" button, and also buttons to access a glossary of terms and to save certain final statistics to a text file for printing from another computer without the program (so printing from the program itself won't be necessary). The program will also need to create a save file, so the program can be closed and resumed later (as the game will take place over 3+ days). A pop-up window will be needed (or change within the same window) for entering of trade information with other players and possibly some other things.

Requirements:
Not many. It just needs to be an executable in the end and run in Windows XP. It doesn't have to be visually stunning or DEMANDING, as I believe the laptops they're using are a bit old, and they're all using XP.

Experience:
My programming experience is with Basic (not Visual Basic, but Basic) which I learnt in high school years ago. I also have a lot of experience with scripting for Neverwinter Nights, Neverwinter Nights 2, and Dragon Age (all pretty similar in their scripting), and from what I understand, that scripting language is supposed to be very similar to C++ or Java.

I have 3 months to learn a language and write this simple (well, seems simple to me) program. Which language would probably be the easiest to accomplish this with? I don't mind buying a book or spending a bit of money, just want to make sure I start down the right road before I GET going on this.if you want any future in this, learn C++, Java is pretty much deadQuote from: robin1232 on December 22, 2009, 04:26:29 PM

if you want any future in this, learn C++, Java is pretty much dead
A few years ago Java was the Great Next Thing!.

Do the project in Visual Basic.

You already have a project defined. So this is not about where the future. It is about getting a job done now that you can do with other people now.

But, if you must, here is a nice tutorial where a simple thing is done in both Visual Basic and C++ and the code is shown. The point is that a needed thing in C++ can be used inside of a program that is mostly in Visual Basic.

http://www.freevbcode.com/ShowCode.Asp?ID=3492

Your choice.
As for me, I like to combine and mix things TOGETHER.
Like Ketchup and mayonnaise.

Nah, I'm busy enough with other things in LIFE. This is mostly a one-off thing, just for this project.

I always studied about the hardware and software side of computers, but never the programming side (aside from what I mentioned before). Just trying to decide which language would be the easiest to learn enough of to accomplish what I need.

Quote from: Geek-9pm on December 22, 2009, 05:25:31 PM
A few years ago Java was the Great Next Thing!.

Do the project in Visual Basic.

You already have a project defined. So this is not about where the future. It is about getting a job done now that you can do with other people now.

But, if you must, here is a nice tutorial where a simple thing is done in both Visual Basic and C++ and the code is shown.

http://www.freevbcode.com/ShowCode.Asp?ID=3492

Your choice.


Thanks Geek.I have to second the Visual Basic idea. a lot easier to learn then C++, and C++ would be overkill anyway.

Basically, it boils down to wether you want to spend twice as long on the project just to have it in C++; Not usually something that is worth it.

And java... well, don't get me started on that "revolutionary" language that changed everything and yet changed nothing all at once.Quote from: BC_Programmer on December 22, 2009, 05:46:24 PM
I have to second the Visual Basic idea. a lot easier to learn then C++, and C++ would be overkill anyway.

Basically, it boils down to wether you want to spend twice as long on the project just to have it in C++; Not usually something that is worth it.

And java... well, don't get me started on that "revolutionary" language that changed everything and yet changed nothing all at once.

Haha yeah, I remember years and years ago a friend of mine (who's a programmer by profession) was going on and on about how Java was the future of programming.

Personally, I don't care about the future of said language, as long as it works for my purposes and I can learn it and complete this before mid-March.

I took a look at a Visual Basic book a few days ago at the bookshop. Seemed easy enough. Think I'll go with that. Thanks for the advice guys.go for Python. Easy to learn and use and you can make games quite easily too. Plus, you can run your game in other platforms as well. Just a reminder. Bill Gates.Microsoft started by doing basic interpreters along, long time ago. And even years after that none of the C. compilers came even close to what you could do with Microsoft basic. Been there, done that. The C. compiler libraries, even the pricey ones, could not compete with the efficiency that Microsoft had put into the compiled basic runtime library. It was industrial quality stuff. It got the job done. The C. compilers at that time were more like academic experiments. At least for personal computers.
Of course, that's all behind us now. Still, Microsoft's visual studio suite still looks an awful lot like visual basic.
in the valuation packages of several different versions of Microsoft visual what ever. In fact, you can download them all and use the tools that you like the best.
However, Microsoft is doing very little to adopt stuff that is closely tied to UNIX.Quote from: Geek-9pm on December 23, 2009, 11:29:35 AM
Microsoft is doing very little to adopt stuff that is closely tied to UNIX.

Like C? Because, you know, it's only what windows is written in, after all.I would have to second the vote for python because it is easy to learn, and in my opinion, a much better language all around than BASIC. If you are intent on learning one of the three you listed, I would go for C++ unless you are totally certain that you will never want to program again besides this one project, and then I guess you could go for BASIC.

"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
--Edsger Dijkstra Quote from: BC_Programmer on December 23, 2009, 11:30:58 AM
Like C? Because, you know, it's only what windows is written in, after all.
My remarks were about the libraries of C. They would not very good. The Microsoft stuff was good, but MS did not release their own libraries to others. Unless you paid the price. The remarks about poor habits of Basic programmers can also apply to some C programmers that create absolute trash code.
Just being able to read and write code does not make you effective in your work. You need piratical skill in solving problems and dealing with exceptional conditions. There is a fallacy that learning a firm set of rules will insure good habits. The good habits, in turn, bring sure success. The is almost true. Bur not true enough.

Case in point.
Look how English language dominates the business world.
I rest my case.
it's the people who can write code but lack the proper brain cells to do so properly that give us the material on thedailywtf.com. Quote
Do you do web?
Microsoft® just launched Microsoft® WebsiteSpark™. It's a must-have program for independent web developers and web development companies, where you get software, support, and biz resources at no upfront cost for three years.
http://thedailywtf.com/spons/9/spark/
Gotta have it Now!