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.

2501.

Solve : visual studio 2010 limited to 50% processor speed??

Answer»

Hey all,

Im doing some heavy calculations on my PC using visual studio 2010 and its taking ages to compute.

when i LOOK at SYSTEM process the PROGRAM is limited to using 50% of my CPU, do you know if there is anyway to increase this? or even better is there a supercomputer available for the public to use when doing heavy calculations>?how are you doing "heavy calculations" with Visual Studio?Quote from: BC_Programmer on January 26, 2011, 04:11:05 AM

how are you doing "heavy calculations" with Visual Studio?

I was WONDERING that.
Curious minds need to know..
2502.

Solve : Vb 2006 problems?

Answer»

Im trying to load "Microsoft Internet CONTROLS" COMPONENT but I got the ERROR "File not found..." etc.. but I managed to fix that by using RegEdit and CHANGING some value. But not it gives me the error ""C:\Window\system32\ieframe.dll" could not be loaded".

I am confuzzeld and need help prontoooo

THANKS!

2503.

Solve : RSS Feed Reader??

Answer»

I want to MAKE a Desktop, gadget-like program which will display my RSS feeds on the desktop, however I have no strong knowledge in programming so this is a problem =\

I have VISUAL Basic, im guessing I would be able to make it with that but not sure how.

Help anyone...?

THANKS Yea, this is the bit when you guys post

>:|QUOTE from: Redcaa on JANUARY 26, 2011, 01:36:49 PM

Yea, this is the bit when you guys post

>:|

OK happy to oblige.

Good luck.






Quote
I want to make a Desktop, gadget-like program which will display my RSS feeds on the desktop, however I have no strong knowledge in programming so this is a problem

I can see how it would be.


2504.

Solve : My first C++ program?

Answer»

i just started to read C++ for dummys and i have coded a CONVERTER for tempature using the tutorial and when i run it through the compiler i get an error on line 13, the complier im using is dev C++ ....

could some one look through the code to see what the mistake is .. i have just started to LEAN C++

Code: [Select]//
// Program to convert temperature from Celsius degree units:
// units into Fahrenheit degree units:
// Farhrenheit = Celsius *(212 - 32)/100 +32
//
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(int nNumberofargs, char* pszArgs[])
{
//ENTER the temperature in Celsius
int celsius;
cout << "Enter the temperature in Celsius :" ;
cin >> celsius;

// calculate cinversion factor for Celsius
// to Fahrenheit
intfactor;
factor = 212 -32;

// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32 ;

//output the results (followed by Newline)
cout << Fahrenheit value is :";
cout << fahrenheit << endl ;

// wait untill user is READY befor terminating program
// to allow the user to see the program results
system( "PAUSE");
RETURN 0;
}
Not knowing much about C++, I found all the corrections on Google (hint, hint)

Code: [Select]//
// Program to convert temperature from Celsius degree units:
// units into Fahrenheit degree units:
// Farhrenheit = Celsius *(212 - 32)/100 +32
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofargs, char* pszArgs[])
{
//enter the temperature in Celsius
int celsius;
cout << "Enter the temperature in Celsius :" ;
cin >> celsius;

// calculate cinversion factor for Celsius
// to Fahrenheit
int factor;
factor = 212 -32;

// use conversion factor to convert Celsius
// into Fahrenheit values
int fahrenheit;
fahrenheit = factor * celsius/100 + 32 ;

//output the results (followed by Newline)
cout << "Fahrenheit value is :";
cout << fahrenheit << endl ;

// wait untill user is ready befor terminating program
// to allow the user to see the program results
system( "PAUSE");
return 0;
}

1) cout and cin require a #include <iostream> statement
2) intfactor - two words; it's a declaration not a variable name
3) RETURN works as lowercase; C++ must be case sensitive

Once the compiler bugs are worked out, the program seems to work. Any plans to convert Fahrenheit to Celsius?

Good luck.

2505.

Solve : Deleting file at first startup?

Answer»

Hello everyone

I want to DELETE a file CREATED by automated windows 7 (integrated in windows 7 DVD). Before I added the bold line " del /f /q %systemroot%\setup" to the script below, the computer restarted automatically after windows installation was finished . The script does delete the files in "%systemroot%\setup", but it does not restart automatically after windows installation is over, as it did before adding that line. I know i messed it up (my fault). I'm sure I missed something with the script SYNTAX. What shoul I do to make it work/restart as before?

Thanks in advance

Script:

@ECHO off

for %%A in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z do (
if exist %%A\bootmgr (
if not exist %%A\setup.exe (
echo.
echo Installing to drive %%A
echo.
if exist %%A\menu.lst attrib %%A\menu.lst -h -r -s
if exist %%A\menu.lst ren %%A\menu.lst menu_lst.bak
if exist %%A\grldr attrib %%A\grldr -h -r -s
copy %systemroot%\setup\scripts\grldr %%A\grldr
attrib %%A\grldr +h +s +r
%systemroot%\setup\scripts\bootinst /nt60 %%A
del /f /q %systemroot%\setup)
)
)

shutdown /r

2506.

Solve : Using ogg decoder dll with vb6?

Answer»

I am working on a small game in VB6. All of my sounds are in OGG format. I found a DLL here: http://www.blastbay.com/oggdec.php
I can't get it to work fully with VB. I can get it to decode the OGG and save it as a WAV file, but I need it to play from RAM. I think the problem is that I am getting the declarations wrong because it was INDENTED to be used in C. Can someone help me get this to decode into RAM and play the decoded data through the speakers?

I am sure BC can answer this. . . Right?


Thanks.Anyone know?

I'd rather have an answer saying "I don't know" , not just ignoring my post.I Shall attempt to create VB6 compatible declarations.

I've had great success using two other libraries- BASS and IRRKlang; they aren't public domain like this one, but they aren't a pain to use (they include VB6 declarations and SAMPLES, even).

Quote

I Shall attempt to create VB6 compatible declarations.

Thanks.
You probably already saw this, but the readme file contains the C declarations.Yes, I saw that.

I managed to sort of get the INITIALIZATION routine working, but it always returned 0. The stupid method of using GetProcAddress() is what throws me.

Then I noticed something you've already got it half working- to the point of actually decoding it.

Could you post that

By the way: the DLL only decodes the data; it doesn't actually provide any way to play it.Quote
Could you post that

I just used the function that decodes to a wave file.

Here is the declaration in C:
Code: [Select]BOOL Oggdec_DecodeFile(char* source_filename, char* destination_filename);
Here is what I typed into VB:
Code: [Select]Private Declare Function Oggdec_DecodeFile LIB "blastbay_oggdec.dll" (source_filename As String, destination_filename As String) As Boolean

Private Sub Form_Load()
Oggdec_DecodeFile "blabla.ogg", "blabla2.wav"
End Sub

The problem is that that creates a wav file instead of sound data in memory.

Quote
By the way: the DLL only decodes the data; it doesn't actually provide any way to play it.

Right, but it decodes to raw PCM data which windows is capable of playing out of memory (so I thought).If this proves to be too much of a hassle, I will take a look at that BASS thing you mentioned.Yes, you could play sound directly from memory using PlaySound(filename,SND_MEMORY Or SND_ASYNC)

but... well, there are some issues when you do it that way... Also, I've found that PlaySound() leaks catastrophically for some reason, at least on Vista/7. Then again, getting VB6 programs running well on Vista/7 is like pulling teeth! My Older Visual BASIC 6 "Poing" game just uses WAV files and DirectSound.




Anyway, BASS is more a library for playing sounds then a simple decoder; The reason I bring it up is because all my games sounds are OGG format as well and it works just fine. Personally I wrote several classes (C#) for wrapping the Sound functionality into "drivers" so that I could use a different sound library or add support for more libraries further on; so far I have two- IRRKlang, and BASS.NET.

The BASS downloads contain Visual Basic 6 samples and declarations though, so there should be as much fiddling.

as for the blastbay dll, I don't know. I can get it to call the initialization routine but it never seems to work properly, always returning zero.I think, you can choose a good video converter to help you, just follow me to use RZ Video Converter which can convert any videos or audios between different formats with good quality, hope it can help you. good luck.
2507.

Solve : One installer for multiple application + one start icon?

Answer» HI All,

I very new to windows and this forum and do not even know a bit of what i have to do. My problem is as below:
I have to create an installer which will install three things at once:

* Application server
* Database server
* Web browser


After the installation is done, there should be an icon which should start the application server, database server and open the installed browser when icon is clicked.

How do i achieve this? Can anyone point me to a tutorial link or some example?

Any help would be appreciated.

Thanks in advance.

--
VikramHi. If I were you, I would create a batch file called install.bat. Inside that batch file you could say something like this:

start /wait installer1
start /wait installer2
etc...

Then you would create an archive in 7-zip that CONTAINS all of the setup PROGRAMS and the install.bat file that you created.

In ORDER to do this you need to download and install 7-zip (just use google)
Write the install.bat I told you about.
7-zip all the files into one archive.
Then use my utility found here: http://www.mediafire.com/?ga696x3j2ar4jna
. . .to create an installer SFX.Quote from: Linux711 on January 13, 2011, 09:25:59 AM
Then use my utility found here: http://www.mediafire.com/?ga696x3j2ar4jna

If they have already installed 7-zip they can just use the right-click context menu to turn it into a SFX Archive.Quote
If they have already installed 7-zip they can just use the right-click context menu to turn it into a SFX Archive.

Yes, but it won't work how the OP intended. He wants all three INSTALLERS to run. My version of the SFX allows for a batch file to execute after extraction, and start all the seperate installers.Thank you all for the help. I will try the suggestions and get back if something works or not....

--
VikramBatch file thing worked fine and I also found a free tool which exactly solves my problem.

http://www.jrsoftware.org/isinfo.php

Thank you all for the suggestions.

--
Vikram
2508.

Solve : VB .NET 2010: Auto Scroll to Bottom?

Answer»

Could somebody PLEASE explain to me how to make a MultiLine textbox scroll to the bottom automatically? I am using VB .NET 2010. I just can't figure it out.

%FLEEXYSet the selection start to the end of the textbox and USE the ScrollToCaret() method:

Code: [SELECT]textBox1.SelectionStart=textBox1.Text.Length
textBox1.ScrollToCaret()
You could do other things as WELL, such as saving the original caret position or any selections that were made, depending on when you are triggering this CHANGE and how you are using the textbox.

2509.

Solve : How to Search, Compare, and Replace text in the TextBox in J2ME??

Answer»

Hello, good evening.

I'm having a hard time with this on how to search and compare the STRING array to the TEXTBOX, and REPLACE the text in the textbox.

Here's my code:
Code: [Select]import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Command;

public class TextBoxMIDlet extends MIDlet implements CommandListener
{
private Display display;
private static String[] txtWord = {"txt","spk","lol","np","brb"};
private static String[] realWord = {"text","speak","laugh out loud","no problem","be right back"};
private Command txtspk = new Command("CORRECT Textspeak", Command.ITEM, 0);
private Command exit = new Command("Exit", Command.EXIT, 0);
private TextBox t;

public TextBoxMIDlet() {
display = Display.getDisplay(this);
}

public void startApp() {
t = new TextBox ("TextBox Example", null, 256, TextField.ANY);
t.addCommand(txtspk);
t.addCommand(exit);
t.setCommandListener(this);
display.setCurrent(t);
}

public void pauseApp() {}

public void destroyApp(boolean UNCONDITIONAL){}

public void commandAction(Command command, Displayable displayable)
{
if (command == exit)
{
destroyApp(true);
notifyDestroyed();
}
if (command == txtspk)
{
for(int a = 0; a < txtWord.length; a++)
{
if(t.getString().equalsIgnoreCase(realWord[a]))
{
t = t.getString().substring(realWord[a]);
}
}
System.out.println(t);
}
}
}
I'm having a problem with this this part:
Code: [Select] if (command == txtspk)
{
for(int a = 0; a < txtWord.length; a++)
{
if(t.getString().equalsIgnoreCase(realWord[a]))
{
t = t.getString().substring(realWord[a]);
}
}
System.out.println(t);
}
I don't know how to figure it out. What's the exact syntax should I put there?

Hope someone will help me with this.

Thanks advance.Anyone?Quote from: SHENGTON on January 20, 2011, 09:20:41 AM

Anyone?

Please do NOT bump thread. If anybody feels like answering, they will.

can you not use the String's inbuilt ReplaceAll() method?
2510.

Solve : Trying to create a .exe out of a source?

Answer»

I really dont know much about programming so i'm asking for alot of help. I am trying to convert a SOURCE into a .exe file that anyone can install. The source is the nintendo 64 emulator 1964 version 1.1. Can anyone offer some help with this matter?Pardon me. If you don't know now to do it why would you want to?

People who work with that kind of material have to have a knowledge of what they are doing. I is not the sort of ting that the average computer user would do. Instead, one would download an exe ready to go. One that someone else has already compiled, linked, debugged, tested and evaluated. Otherwise, novice offering a new untested program to others is no favor at all.

http://en.wikipedia.org/wiki/1964_%28emulator%29Quote from: revron on December 28, 2010, 06:12:58 PM

I really dont know much about programming so i'm asking for alot of help. I am trying to convert a source into a .exe file that anyone can install. The source is the nintendo 64 emulator 1964 version 1.1. Can anyone offer some help with this matter?

if you are on a linux system, it's as simple as going into the project folder, and typing ./configure and then MAKE to compile it.

With windows, it's not so simple; you would probably need to download and install gcc, which works best when you have the coreutils installed anyway (and/or msys) and so forth; the Windows Visual Studio "Solution" file doesn't work as far as I can tell.

However geek has a point, specifically since the source release for 1964 1.1 includes the binaries. I am trying to add the new version of 1964 to a emulation website, but the way the uploader is set up is the real problem. It only allows .exe programs to be upoaded. I have a linux laptop if that would help me.Which new version? The official version is 1964 version 1.1

It is already on many sites as an EXE file, so we do not understand what you want to do. The creators of the program do not endorse any new changes, as far as we know about.
Normally the program runs on Windows and is written in C. Compiling the program in Linux may produce unexpected results. I have not looked at the code, but I do believe it makes very specific library calls into Win32.

Nevertheless, the Linux people claim to have a version that works. So before you try to compile, check it out. http://ubuntuforums.org/showthread.php?t=476031

Or Google best n64 emulator for linuxQuote from: revron on December 29, 2010, 04:38:04 PM
I am trying to add the new version of 1964 to a emulation website, but the way the uploader is set up is the real problem. It only allows .exe programs to be upoaded. I have a linux laptop if that would help me.

zip it up and convert the zip to a SFX?Quote from: barrybrother on January 20, 2011, 02:00:27 PM
Enroll in a "C" programming course at your junior college. The college will furnish all computers and the "C" complier.

The complier will convert the "C” source code to an .exe executable. If the source code is not "C", choose the complier that converts (COMPLIES) the source code you have.

p.s. You must decide which programming course and language you need. Good Luck


He want's to compile an already written application. C Compilers are FREELY available and the program in QUESTION has a makefile that works with a variety of different compilers.
2511.

Solve : programming?

Answer»

Dear sir
I want to learn software/programming. I heared that for this we have to start from c language.Is it correct? if yes,
can u suggest me any free tutorial whcih can I download in PDF formate in my computer?I know only word and excel to use.

Thanks
Sandeep


Google.......it finds things


http://www.google.co.uk/search?client=firefox-a&rls=org.mozilla%3Aen-GB%3Aofficial&channel=s&hl=en&source=hp&q=C%2B+tutorial+pdf&btnG=Google+SearchQuote from: sgupadhyay2000 on December 17, 2010, 04:08:12 AM

I heared that for this we have to start from c language.Is it correct?
No. Not even close.

Quote
I know only word and excel to use.
BC is right.
If you know just MS Word and Excel, learn FULLY how to use them.

Advanced features of both are called 'Application Programming.'
This is the kind of programming most people need to learn for work, home and school.some people just learn excel or word religiously. Which means, they are real experts at them and can do all the fancy things that average joes don't really need or probably won't ever notice unless he's told

Many programming/software language exist. C is only one of many and C is only one of many starting choices. the question of "what language is the best to learn first" is rather ridiculous. Nobody asks "What language should I teach my child", because they don't really "teach" the child the language as much as the child grasps the basics on their own with no guidance Just like how they don't have to be taught how to recognize a face.

In the same vein, LEARNING Programming isn't so much about learning a single programming language as much as it is learning a set of concepts that apply and can be applied universally across almost all languages. It doesn't matter what language you "choose" first unless it happens to lack a lot of those concepts (such as for example Minimal BASIC). Computer Programming takes a certain mindset. Not EVERYBODY's Brain is wired in a way that makes it easy to understand for them. They can learn programming but it's a slow and generally painful process, and they generally are not as "driven" and not unexpectedly GET discouraged easier.How about a basic reference.
http://www.csupomona.edu/~hnriley/www/VonN.html
This should be required reading for anyone who wants to know more about computers.While It certainly doesn't hurt, you don't need to know how your instrument works to make music.Quote from: BC_Programmer on December 22, 2010, 02:53:10 PM
While It certainly doesn't hurt, you don't need to know how your instrument works to make music.
Is that what you got from it? OK
I got "Do you even know what your instrument is?"
Is the computer just what John von Neumann, said it would be?
Or is it something else? Does it think? Could it?

Sometime in the future we may not program our computers.
We will talk ton them.
Start working on articulation and modulation now, while your nae young.


Quote from: Geek-9pm on December 22, 2010, 05:08:55 PM
Sometime in the future we may not program our computers.
We will talk ton them.
Copyright 1970.Try to learn from w3schools.com !! its great ...
Quote from: jhonas on January 20, 2011, 12:15:43 AM
Try to learn from w3schools.com !! its great ...

It is, but it does not learn you C programming, which is what the ORIGINAL poster wanted.
2512.

Solve : How to start C programming??

Answer»

After using windows for to make batch files for a while, i decided to upgrade. I now have Ubuntu and am going to learn C programming. How do i start? do i need a program to write the SCRIPTS in, like eclipse for Java or what?
Thanks
PottsieQuote

How do i start?
Open the terminal and type gcc to see if the compiler is installed.
If so, you can proceed to write a program using a text editor and save it as program.c
Then you can use gcc to compile it from the terminal.
If not, you can install it from the package manager.

Quote
do i need a program to write the scripts in, like eclipse for Java or what?
I am not very familier with what is the best IDE.kdevelop is a good IDE for C and C++, it supports other languages too I think.

sudo apt-get install kdevelop at a terminal to install; or use the package manager. For STARTING c programing you should know about the c language keywords, header files, data types. First of all you should start simple program like print hello.

#include < stdio.h>

void main()
{
printf("\nHello World\n");
}
Programming in C is almost programming in assembly.
Learn C++. It is a 'middle' language.It nis much easier to get started.
Unless you are the academic type, I would not recommend SPENDING much time learning C or other low-level-languages.
Have you studied any high-level languages?
If not, why not?
Most work being done today is top-down development.Quote from: Geek-9pm on December 20, 2010, 11:31:54 AM
Programming in C is almost programming in assembly.
Learn C++. It is a 'middle' language.It nis much easier to get started.

um... no it's not. C++ is a superset of C. Therefore by definition it will be harder to learn. It's sort of like saying "don't bother learning basic arithmetic, you should start with calculus"

Quote from: BC_Programmer on December 20, 2010, 12:19:25 PM
um... no it's not. C++ is a superset of C. Therefore by definition it will be harder to learn. It's sort of like saying "don't bother learning basic arithmetic, you should start with calculus"
Yes, I failed arithmetic. And later I failed Algebra.
Set me back so I did not get to take calculus.
Should have skipped arithmetic.Actually, I would say that C and C++ are agreeably close in difficulty to learn. But, for beginners - C is essentially easier to dive in to than C++. As for experienced learners in the programming field, C++ should not be too aggressive.

~DMJ If you are on windows, Microsoft Visual C++ Express Edition is good compiler.


C++ includes the stuff you can do in C. Anyway, cplusplus.com has a great tutorial so you may want to start here!

I agree. cplusplus.com is pretty good. I am on a couple of other sites that I learned on.Quote from: 2x3i5x on December 22, 2010, 12:27:55 PM
C++ includes the stuff ... cplusplus.com has a great tutorial so you may want to start here!
Way to go! Greet link! And it is FREE!I'm new here but I wanted to give my 0.02 worth...

It's generally accepted wisdom that C and C++ are close enough that you may as well start with C++. The major difference is the object model and it's better to get started with objects sooner than later.

I like GEANY for C/C++. It runs on Win and *Nix and it can run C/C++ directly (as long as you have a compiler available).I recommend w3schoos.com is ALSO good !!Quote from: jhonas on January 20, 2011, 12:14:42 AM
I recommend w3schoos.com is also good !!

you are recommending a non-functional website
2513.

Solve : c++ pipe() questions?

Answer»

I WANT write a program that forks a copy of itself. The PARENT should ask the user for an integer. The PARENT should SEND that integer through a pipe to the CHILD. The CHILD should do something with it and send it back through a pipe to the parent. The PARENT should print out the integer.

I know how to fork but I do not know how to communicate with PIPES. Please help by providing me with a good site to READ up on c++ pipes and what the code is to send and receive through pipes in c++.

Thank you

http://www.ecst.csuchico.edu/~hilzer/csci372/pdf/Chapter7.pdf from http://www.unix.com/programming/58138-c-how-use-pipe-fork-stdin-stdout-another-program.html Hope this helps!

2514.

Solve : C++ problem?

Answer»

i made a program to GET the factors for a NUMBER but i get weird answers back such as Quote

20 has these factors 3999008,3999008,0,0,0,0
for an input of 20.
the code is as followsCode: [Select]#include <cstdlib>
#include <iostream>

using namespace std;
void show( int *arr ,int num );

int main(int ARGC, char *argv[])
{
int num=0;
int numfactor=0;
int numarry=0;
char error[20];
cout << "what number do you want to factor: ";
while (!(cin >> num)) {
cout <<"try again";
cin >> error;
}
for (int i=1;i<=num;i++)
if (!(num % i))
numfactor++;
int * factor =new int [numfactor];
for (int i=1;i<=num;i++)
if (!(num % i)) {
cout <<i<<"\n";
factor[numarry];
numarry++;
}
cout <<num << " has these factors ";
show(factor,numfactor);
cout <<"\n";
system("PAUSE");
return EXIT_SUCCESS;
}
void show (int arr[] ,int x)
{
cout <<arr[0];
for (int i=1;i < x;i++)
cout <<","<<arr[i];
}try using longin what variablemy bad, thought you were doing factorials...(but still better to use long in case you want to find factors of very big numbers)

you are using c++ and std namespace, so use endl instead of "\n". also you did not assign values to your factors array
Code: [Select]using namespace std;
void show( int *arr ,int num );

int main(int argc, char *argv[])
{
int num=0;
int numfactor=0;
int numarry=0;
char error[20];
cout << "what number do you want to factor: ";
while (!(cin >> num)) {
cout <<"try again";
cin >> error;
}
for (int i=1;i<=num;i++){
if (!(num % i))
numfactor++;
}
int * factor =new int [numfactor];
for (int i=1;i<=num;i++)
if (!(num % i)) {
cout <<i<<endl;
factor[numarry]=i;
numarry++;
}
cout <<num << " has these factors ";
show(factor,numfactor);
cout <<endl";
return 0;
}
void show (int arr[] ,int x)
{
cout <<arr[0];
for (int i=1;i < x;i++)
cout <<","<<arr[i];
}

thank you THOUGH i have have two questions
1) why should i use endl instead of /n
2)is this the most efficient method of getting factorsyou can see some discussion here and hereQuote from: mat123 on January 06, 2011, 12:08:30 AM
1) why should i use endl instead of /n
"\n" is literal, and while compilers will generally condense all the instances of a single literal into one, you shouldn't assume anything as far as the compiler goes. endl is a constant, already defined specifically for you to use with iostream.

Quote
2)is this the most efficient method of getting factors

No.

your iterating from 1 to the number, by one every time. first- one will be a factor of any whole number, 2, there is no need to go past the original number divided by 2, since no number B that is larger then Number A/2 will be a factor of A. Also, consider the numbers 2,3,5,7 and 9. if 2 is not a factor, then you KNOW that no multiple of 2 (4,6,8, etc) is a factor either. same with 3 and it's multiples. And that is just for starters.



OK thank you for your help
2515.

Solve : PERL - Is there a better way to write output to file than my batch/perl method?

Answer»

I am curious as to if there is a better way to write an output to a file using PERL than the method that I am using below, which is a mixture of PERL and DOS(batch):

system "echo $a $b $c >>WriteList.txt";


Where variables $a, $b, and $c are passed directly into the Echo output of a DOS Shell batched type of environment which then uses the >> redirection and append to EOF to write the output of PERL's variable strings to text file.

*This does work, but to me it just seems sloppy to have to pass variables outside of PERL into a SYSTEM call which then runs as if you were in DOS. The same SYSTEM(" "); call can also be run in C++ and perform the same passing of variables out of C++ into DOS command lines, BUT C++ has its FILE OPEN, Write, and FILE CLOSE function so that you dont need to perform a SYSTEM Call. So that is why I am thinking that I am running this in an ugly frankensteined state, which just happens to work. And figured I'd check to see if someone with more PERL experience might point out how to perform this without a frankensteined method of mixed guts!

The other thing I have to figure out is why I can only write a maximum of 60,000 lines per hour with this program on both a Pentium 3 (600Mhz) and a Dual-Core Atom. Thinking that maybe the excessive Open/Close >> appending might be hammering the drive and wasting time. But the HD LED does not stay on constant, so I dont think that is the problem. Because if the HD was being flooded with file open/close's I WOULD expect to see a solid LED lit and lots of drive arm rattling..lol

Was thinking that maybe if I printed out 100 lines then wrote to file, it might be more HD friendly and might execute faster, but the CPU on the P3 is pegged at 100% and the Dual-Core Atom is hovering between 53-60% and both when timed were executing the program the same speed pretty much at a little less than 30,000 lines written in 30 minutes. With close to 450,000 lines to write, this is going to take a while, and it seems that even throwing faster processing power at it isnt going to help me for some reason the way that i have it currently executing.Yes, it would be better to read and write files inside of pearl.
http://perl.about.com/od/perltutorials/a/readwritefiles.htm
The above is a basic tutorial on pearl open, read and write. And don't forget to close when done.
Here is one on append.
http://www.pageresource.com/cgirec/ptut15.htmopen the file...
Code: [Select]open(APPENDFILE,">>WriteList.txt") || die("Error opening WriteList.txt");
print to the file
Code: [Select]print APPENDFILE "$a $b $c";
close the file:
Code: [Select]close(APPENDFILE);

If you are looping in some way as you output the data or otherwise are outputting more then once per script run you should open the file early on, perform all the writes on it, and then close it.


By the way, shelling out to any other application to perform a task is always going to be slower then performing that same task in the same environment. Setting up Process INFORMATION and starting a new task is a very expensive operation. Also, doing it that way is a rather ugly kludge.if you are using Perl, then use Perl. There is no need to use batch any more than calling the Perl interpreter to run your Perl script.
Always looks at the documentation for what you need. And I suggest you dive deeper into the language (if you want) because it can practically replace batch for what you are doing. Plus, there are humongous amount of libraries you can use to do other complex stuff, eg big integer maths, pdf generation, HTML parsing , etc...Quote from: Geek-9pm on December 29, 2010, 08:50:24 PM

Yes, it would be better to read and write files inside of pearl.
its Perl.Perl was originally named "Pearl," after the Parable of the Pearl from the Gospel .

But I guess you are to young to know that.
Quote from: Geek-9pm on December 29, 2010, 10:43:07 PM
Perl was originally named "Pearl," after the Parable of the Pearl from the Gospel .

But I guess you are to young to know that.

Wrong. Being "named" and being "OFFICIALLY used" are two different things. Before Perl, there's also a PEARL language (since 1977). after that, Larry changed the spelling to Perl. Get that in your head.Quote from: ghostdog74 on December 29, 2010, 11:03:30 PM
Wrong. Being "named" and being "officially used" are two different things. Before Perl, there's also a PEARL language (since 1977). after that, Larry changed the spelling to Perl. Get that in your head.
You are right.
He wanted 'Pearl' but changed it to 'Perl' before the official release.
Thanks everyone for the useful info...plus also about the Perl name history =) never knew PERL has been around since 1977. To just think I might have been able to play with PERL on my TRS-80 way way back..lolSorry for the confusion I started...
Quote
A pearl is a round shiny object produced by mollusks and used in jewelry.

Pearl may also REFER to:
# Pearl (given name)
# Bruce Pearl (born 1960), head basketball coach - University of Tennessee
# Daniel Pearl (1963–2002), American journalist who was kidnapped and murdered in Pakistan
Canada
* Pearl, Ontario

[edit] Hungary
* Gyöngyös, a town whose name means "Made of Pearls"

[edit] Iceland
* The Pearl (Perlan), a 1991 landmark building in Reykjavík, Iceland
# The Pearl, an 1867 legal case; see: List of United States Supreme Court cases, volume 72
# Polar Environment Atmospheric RESEARCH Laboratory, an Arctic Atmospheric laboratory at Eureka, Nunavut, Canada
# Pearl (color), a pale tint of off-white. It is a representation of the average color of a pearl
# Pearl (radio play), a 1978 radio play by award-winning English playwright John Arden
# Pearl (DART station)
....

Wall discovered the existing PEARL programming language before Perl's official release and changed the spelling of the name.

When referring to the language, the name is normally capitalized (Perl) as a proper noun.

Larry Wall began work on Perl in 1987, while working as a programmer at Unisys,[7] and released version 1.0 to the comp.sources.misc newsgroup on December 18, 1987.[8] The language expanded rapidly over the next few years.

Perl 2, released in 1988, featured a better regular expression engine. Perl 3, released in 1989, added support for binary data streams.

http://en.wikipedia.org/wiki/Perl

Perl can refer to:
* Perl, a programming language.

Place names
* Perl, Germany, a municipality in Saarland, Germany

Last names
* Hille Perl, a German musician who performs the viola da gamba and the lirone
* Martin Lewis Perl, an American physicist and Nobel Prize laureate

A Pearl by any other name would be a Rosa.Quote from: DaveLembke on January 01, 2011, 03:11:10 PM
Thanks everyone for the useful info...plus also about the Perl name history =) never knew PERL has been around since 1977. To just think I might have been able to play with PERL on my TRS-80 way way back..lol

There was no Perl in 1977...Pearl is very young, and has a problem...
http://www.funnyordie.com/videos/74/the-landlord-from-will-ferrell-and-adam-ghost-panther-mckayWell 1987 I guess vs 1977..lol...thx for posting correction