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.

1601.

Solve : how to rum binary codes??

Answer»

Hello.
How to run Binary codes?
I know i should place 'em in something like Notepad
but do not know how to run it.
Example-Code:
my name "Milad" in Binary will be:
1001101 1101001 1101100 1100001 1100100
I can place it in a Notepad but, don't know how to see the
result (Milad).
i want write those 0s & 1s, then see Milad.
How, please?
Thank you.Easiest would be a binary to ascii interpreter in which a program reads in a text file that is in binary and then performs the binary to ascii conversion which is not very hard to do.

Do you know how to program in any specific computer languages so I can show you an example in a language you are familiar with?

There is also this here to avoid reinventing the wheel if you dont want to go through making one of your own creation: http://sourceforge.net/projects/ttbconvert/That isn't really "binary code" - It's just ASCII text encoded into binary. You would just need to convert that back to ASCII using a program. There are loads of "Binary to ASCII" converters online, you can even work it out on paper with relative ease.

Actual binary computer code is very low level and while it can be run it requires a deep understanding of how the CPU and memory.etc operate, running it on the raw CPU is very hard to do as you would at that point be pretty much writing an operating system, however there are CPU simulators you can play about with. While it is possible to write this code in binary there is no reason to, the lowest level of code a human would write would be assembly code which is then compiled line-by-line into binary.

That said, it's not an easy task and unless you have or want to learn a very low level view of how the CPU operates, your time would be much better spent learning and using a HIGH level programming language.Good point Camerongray... I assumed that it wasnt low level because of the reference to notepad, and just as you stated it also is not binary code its just the ASCII encoded to Binary.hi. Thank you so much for your advise.
I'm actually a beginner In programming.
I STUDY C language.

I've written a program which gets the binary codes
and convert 'em into ASCII codes.
you know:
binary: 1001101
DECIMAL: 77
result: M
but using Array [?], i could reach WORD.

the truth Is that, I didn't yet compile it. Because I dont access
my computer now.
anyway, it isn't difficult. I have written instructions in my phone and
will compile it as soon as i kiss my computer again.Yes an array would be the best method and either use a space delimiter or set a timing for 7 bit groups to be read out and decoded back to ASCII. The space delimiter with error checking is probably the best method as first shown below. The second method below in which you end up with a smaller text file with binary is not as good, but could be given an error correction routine to avoid getting tripped up, but is more complex to correct for a missing bit or an EXTRA bit etc.

1001101 1001101 with space delimiter to register as MM, and space delimiter used as an end bit read indicator so that it reads in only 7 bits, performs the conversion to ASCII, and then concatenates the next valid binary 7 bit read in of array, until EOF concatenating the print to display the ASCII text result. (( This here would be better in that you can look at the binary text file with your eyes and see were corruption is within a group of 7 bits, as well as if there was corruption in the file of say binary "Hello World" , because of the space delimiter you know that the corruption is contained only within 1 CHARACTER place and it doesnt trip up the rest of the binary decode to ASCII, so if there was a missing bit and your not testing for 7 bits to be read you could end up with "Hello Wo7ld" instead of "Hello World" because the binary for the ( r ) binary place holder is only = decimal of 55 instead of 114. As stated it would be best to go this route and test for 7 bit reads and if its any greater or any lesser than 7 bits print to display a dash - or asterisk * to indicate that there was a failed binary 7 bit conversion for each character place that is broken/corrupt. So instead of getting "Hello Wo7ld" you would instead get "Hello Wo*ld" or "Hello Wo-ld" which stands out as a failed binary read for a single character. )

- OR -

10011011001101 with reading in every 7 bits so that 1001101 is the first group of 7 bits Array ( 0 to 6 ) and then the next group of 7 bits is Array (7 to 13) for the other 1001101, and so on to EOF of the text file containing the ASCII that is in Binary format, and for every group of 7 bits decoded back to ASCII text it concatenates to a single line the output to the display.
(( The only problem I can see with this is that if you had an extra bit or are missing a bit, its completely corrupt from where it gets tripped up with the corruption... so if you had "Hello World" and the corruption of an extra bit or missing a bit in the text file that contains binary, you may see "Hello Wo}à╝♥ instead or lesser ASCII displayed if you missing many bits in the file. ))Thank you so much.
I will keep them in mind.Glad to help!

BTW: Looking back at this after posting earlier I realized that my example of "Hello Wo}à╝♥ is only an example of corruption and actually is in error, by which because you are using only 7 bits for a maximum of 128, you are confined within a readin of 0 to 127 and so you would instead have corruption that shows within the ASCII range of 0 to 127, and so the corruption could appear as "Hello Wof2Cj as confined within the 0-127 range of 7 bits. In order to have extended ASCII showing "Hello Wo}à╝♥ you would need to have 8 bits!

1602.

Solve : Formats in programming. Physics in programming.?

Answer»

Hi.
As i mentioned already, I'm STUDYING C programming language,
and am in chapter 3, which is written by Mr deniss M. ritchie amd Mr brian W. kernighan.
I'm not yet strong ENOUGH to write the programs I wish one day/night to create.

tonight my question is that; if i want to create a Video player,
Or a Music player, Or Photo viewer, Or any reader, Do I have to
Write the Video-Photo-Music-other-FORMAT(s) separately along with the
algorithm of Ui and any other optional things?

There is nothing "Wrong" OR "Wondered" in my head.
I just want to know if there are ways for importing the Formats of anything.
_______________________________________ ________________________________
Apart from that Question; you think it is better for a Programmer
to know about the Laws Of Physics?
To illustrate, the softwares like 3d Max, like Photochap, like Game engines.
Will a programming book teach me about physics?
Or I better open a separate book?

Thank you so much.Theoretically yes, you would need to write the code to handle all the different file formats that you would wish to use. However, in practice stuff like this has already been done by other people who have released their code, you should make a habit of looking for and using this instead of writing your own code to do absolutely everything. Places like GitHub are a good place to look for stuff like this, just make sure you check the licence for the code you are using and deal with it accordingly.

Unless you are writing a program that relies on physics, e.g. a game engine or a physics simulation, there is no need to understand any physics in order to write software, they are completely different areas. A programming book will not teach physics, you will need to learn that separately if you feel you need to know physics for what you are trying to develop.Quote from: m_ilad__ on December 24, 2013, 09:03:25 AM


tonight my question is that; if i want to create a Video player,
Or a Music player, Or Photo viewer, Or any reader, Do I have to
Write the Video-Photo-Music-other-FORMAT(s) separately along with the
algorithm of Ui and any other optional things?
yes. If you are inventing your own algorithm or format. But like cameron SAYS, most popular formats are already done by people. So if you are not doing your own invention, then going for ready available libaries/format would be advisable

Quote from: m_ilad__ on December 24, 2013, 09:03:25 AM
Apart from that Question; you think it is better for a Programmer
to know about the Laws Of Physics?
depends on what you are trying to do. There is no wrong or right. Are you making some physics software for educational purposes? or are you into Science field ? At this techonologically advanced world we live in now, almost every other stuff we do everyday need some sort of computerization. Even Physics. Take Biology for example. Software libraries have been created to bioinformatics. I am sure in the area of Physics, there are some as well.

Quote from: m_ilad__ on December 24, 2013, 09:03:25 AM
Will a programming book teach me about physics?
yes. It depends on the book right? and how its written.? Programming ties in very closely to how humans think. I suck at Physics but lets take example E=mc(squared). Very FAMOUS equation. that book might just have introduced this equation and show you step by step how to write this function, with the main objective of showing how to pass parameters to this function etc. Probably under Chapter 5. Functions. lol

1603.

Solve : Mobile Operating Systems and the limitation in programming languages.?

Answer»

Hi. I'm milAd.
As I mentioned already, I'm studying the C programming language.

Today, My question is that; we know that all programming languages
Have to be translated to the Machine language to perform Tasks, finally.

Also know, An Operating system is a Software Of collection of softwares.
There are examples of operating systems like Windows, Mac, Android, iOS, blackberry OS,
Windows phone, and So.
I check some of 'em out, and foundout that; Android is written in Java and a bit C++, using modified Linux Kernel.
Or, iOS is written in C, C++ and Objective C, using Hybrid (XNU) Kernel, the same in Mac OS.
Or Windows phone is written in C and C++ using Hybrid (NT Kernel).
Big Operating systems Luke windows or mac, might run almost every program written in any language
but If you are a developer of any of for example iOS or Android, you have to use the programming language
that that operating system is written in, and support.
So why is that?! What does "Support" mean 'in here'?
If you create and operating system, what would you do to make it support EVERY programming language?

Thank you so much.what's the name of your text book?It's not a Test-Book and doesn't have a name.
If you can help me, I'll appreciate it.

Suppose that you are going to create mobile OS.
what would you do to make it support the languages like C, C++, Visual basic, java, and all the
Languages that help you to create your application?
For example someone told me you can use Java for the operating systems that support
JVM code that this JVM code is ACTUALLY written in C.
You know, I just wanna get more help and know more.
That's why I came here.Quote from: m_ilad__ on December 25, 2013, 12:16:36 AM

Today, My question is that; we know that all programming languages
Have to be translated to the Machine language to perform Tasks, finally.
'Translated' is perhaps not an entirely ACCURATE description of compilation. Most Compilers perform optimizations in the compilation far beyond any basic "translation". Usually a high-level language compiler can generate code that has better performance than hand-tuned assembly (expert assembly programmers notwithstanding).

Quote
Also know, An Operating system is a Software Of collection of softwares.
An Operating System is the software that supports the system's basic functions. It is not a collection of software, since by that definition, Office suites are Operating Systems.

Quote
Big Operating systems Luke windows or mac, might run almost every program written in any language
but If you are a developer of any of for example iOS or Android, you have to use the programming language
that that operating system is written in, and support.
No, you don't. You can write Mobile Applications on .NET (for example) and have then run on Android, Windows Phone, and iOS using software such as MonoTouch and Xamarin. Only WIndows Phone supports .NET Applications, neither Android nor iOS do, and you can still have that program run on iOS and Android. The idea that you need to use the language that the Systems UI bindings were designed for is ill-conceived; Windows is written in C and it's API is Mostly C with some COM C++, but that doesn't prevent people from using any number of other programming languages. And there are a myriad of frameworks that provide OS support for many mobile systems on a variety of programming languages.


Quote
So why is that?! What does "Support" mean 'in here'?
It means nothing. If this is from a textbook, it seems like USELESS filler.
Quote
If you create and operating system, what would you do to make it support EVERY programming language?

Operating Systems do not support Programming languages. Programming languages support Operating Systems. For example, let's take Python.

Windows has zero built-in support for Python.

But you can install Python, and use Python to create Windows Applications. This is because the UI toolkits support windows.

or take C#. Windows XP has no built-in support for .NET programs, neither does OSX or Linux, but you can develop, compile, and run C# and Visual Basic .NET Applications on all those platforms.Thank you so much, dear friend.
Can you please introduce me some book about creating Operating Systems?
I will appreciate that.
I'm a one who is Strongly interested in creating Operating system.
Im studying C programming language. I love C.
And aslo I'm studying Intel assembly language (32-bit).
I'm always confused and don't know where to go!
I'm one of the BITS here!

What kind of OS-book would you introduce me to?
I want to know ALL about creating Operating systems. (all in details).
Amm....I'm guessing you will tell me keep reading that Assembly language.
Well... It's all about CPU so..
Just.. I'm ready for your advice.
All my problem is that... I need I want to know everything about computer.
But, don't know how do Studies Step-by-Step.

Thank you so much.For an Android novice app maker, here is recommended staring point.
Building Your First App for Android

OR
how to make apps for android - videos
Using C# for apps can work. But never easy.After some thought, it is apparent that my last post did not do enough to address the goals of the OP.
On the assumption that the OP really wants to be productive and not spend too much time in academic pursuit, I would suggest he investigate "Instant Applications for Mobile Devices" as an alternative to learning Eclipse and Java.

There are many tools that allow a novice to simply drag and drop objects into a framework. Many good apps out there non built on such foundations. Yes, they may be slow, but they work and are very compact.

Videos are the way to learn noways. Forget the nooks. Books REQUIRE high-level skills. We all know low to watch a TV. Being doing it for years.
Android Developer Video Hank book is one of many.
Look Here:
How to make apps for android.

This not a joke. People are doing it.



1604.

Solve : Need help..new to command line and batch programming?

Answer»

just new to this forum and need help... beginners tutorials in command line and batch programmikng please.... any LINK would be usefulOne of the BEST - syntax and examples:

HTTP://ss64.com/

Also Google is useful.


i LOVE ss64.
dostips.com has plenty of useful guides as well.We also have a DEDICATED Batch forum (area) in case you run into a problem and need specific help.

1605.

Solve : MSDOS Bat File program to Copy the Next Line if Findstr Line is True?

Answer»

Quote from: briandams on December 28, 2013, 07:25:26 PM

you are using type + for loop? or other methods? how about timing? what are you using to time the script?
Windows Resource kit comes with a program called TIMEIT. Works quite well.Quote from: briandams on December 28, 2013, 07:33:52 PM
its almost a fact that lower level (in the likes of C/C++ ) and how its coded (algorithm) to read big files play a part in performance.

The latter far more so than the former, even in this case.

C# is compiled to IL (Intermediate Language) and is subsequently run on the .NET CLR.

I Created a 8-million and 1 line file consisting of "this is an example line of text, line #" where was of course the current iteration, starting from 0. The resulting size of the file was 382,888,890 Bytes.

A C# Program that simply reads it in and counts lines:

Code: [Select] class Program
{
static void Main(string[] args)
{
Stopwatch watch = new Stopwatch();
watch.Start();
int linecount = 0;
using(StreamReader sw = new StreamReader("D:\\testoutput.txt"))
{
while (!sw.EndOfStream)
{
String currentline = sw.ReadLine();
linecount++;
}
}
watch.Stop();
Console.WriteLine("Finished. Total Time:" + watch.Elapsed.ToString() + ", read " + linecount + " Lines.");
Console.ReadKey();
}
}


Output:

Code: [Select]Finished. Total Time:00:00:07.8800219, read 8000000 Lines.

About 8 seconds to process the entire file.

My VBScript is a bit rusty but I came up with this:

Code: [Select]DIM FSO
Dim TStream
Dim StringRead,CurrentLine
Dim StartTime,EndTime
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TStream = FSO.OpenTextFile("D:\testoutput.txt")
StartTime = Timer
Do While Not TStream.AtEndOfStream
StringRead = TStream.ReadLine()
CurrentLine = CurrentLine + 1
Loop
TStream.Close()
EndTime = Timer
WScript.echo EndTime-StartTime
Which should be functionally similar. It gave me this back:

Code: [Select]47.14844

So the first thought would be that this extra time must be because VBScript is interpreted.

However, I'm not entirely certain this is the case. And this suspicion is proven on some level by inserting the same code into a Visual Basic 6 project. Visual Basic 6 supports compiling to Native code. Doing so yields a time of 55 seconds- almost 10 seconds slower than VBScript. Interestingly, having it compile to P-code, (an intermediate language of sorts) resulting in the program finishing a few seconds faster (53.2 seconds).

For VBScript, all Variables use a 'Variant' Data type. This effectively means that any access or assignment to a variable needs to package and unpackage a OLE_VARIANT structure (internally, of course). Additionally, VBScript is Late-bound, which means that it's access to COM objects (such as the File System Object) are all performed using IDispatch. suffice it to say that this is much slower than an Early Bound call; and pretty much means it has to lookup the method name each time it's used. In this case, that's a problem since there is both Variable access (incrementing the line count) as well as late-bound Method CALLS (both the termination expression as well as the actual ReadLine() method call) being done within the loop body.

Within Visual Basic 6, I made two changes- I referenced the Scripting Runtime (allowing Early Bound calls), and made all variables strongly typed. this reduced processing time to 28.6. Still not as fast as C#; but, the thing is that C# is always interpreted at the IL level, and in this case Visual Basic 6 is compiling to Native code, so clearly "lower-level" doesn't translate directly to faster performance. In this case the C# version is faster simply because the Interpreter is able to use new PROCESSOR features and run in Long mode (rather than the 32-bit WoW), and that would end up changing what the native code output by the Jitter contains. Visual Basic 6 has a Native code compiler but it will always optimize for a Pentium. Even enabling all advanced optimizations and the "favour Pentium Pro" option didn't allow it to run faster than about 26 seconds.

You might think this is related to Visual Basic itself. This appears partly true. Using Visual Studio 2013 and C++ and the following code, with all optimizations set to full and Release:
Code: [Select]#include <string>
#include <algorithm>
#include <vector>
#include <hash_map>
#include <iostream>
#include <fstream>
#include <ctime>

using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string line;
int linecount = 0;
ifstream myfile;
myfile.open("D:\\testoutput.txt");
cout << "processing..." << ENDL;
clock_t startTime = clock();
while (myfile.good()){

getline(myfile, line);
linecount++;

}
cout << double (clock() - startTime)/CLOCKS_PER_SEC << " seconds." << endl;
//cout << (double)(clock() – startTime) / (double) CLOCKS_PER_SEC << " seconds." << endl;
cout << "Finished." << endl;
cout << "processed " << linecount << " lines.";
int test;
cin >> test;
}

resulted in this output:

Code: [Select]processing...
9.535 seconds.
Finished.
processed 8000001 lines.

(This was with ALL optimizations set to full and for speed (/Ox, /Ot)). The only thing I can think of that ACCOUNTS for the small difference would be that the C# program ran in native 64-bit Mode, whereas the C++ is only compiling to 32-bit (by default), but switching the C++ program to x64 caused it to take about twice as long to complete. My guess as to why it's slower than C# in this case would have to be the ifstream library.



Quote from: briandams on December 28, 2013, 07:25:26 PM
you are using type + for loop?

First batch method

@echo off
set Tfile="%1"
setlocal enabledelayedexpansion
set line=1
echo %Tfile%
echo %date% %time%
for /f "delims=" %%L in ('type "%Tfile%"') do (
set /a line+=1
echo %%L | find "Trigger" >nul && goto found
)
:found
echo Found previous
echo %date% %time%
echo Line %line%
set /a sk=%line%-1
for /f "skip=%sk% delims=" %%L in ('type %Tfile%') do (
echo %%L
goto done
)
:done
echo %date% %time%

Quote
or other methods?

Second batch method

@echo off
set Tfile="%1"
echo %Tfile%
echo FIND start %date% %time%
for /f "delims=[] tokens=1*" %%A in ('find /N "Trigger" %Tfile% ^| find "Trigger"') do set triggerlinenumber=%%A
echo FIND end %date% %time%
echo FOR /F start %date% %time%
for /f "skip=%triggerlinenumber% delims=" %%L in ('type %Tfile%') do (
echo %%L
goto done
)
:done
echo FOR /F end %date% %time%

VBScript:

CONST ForReading = 1
strTextFile = wscript.arguments(0)
wscript.echo strTextFile
Set objFSO = CreateObject("Scripting.FileSystemObject")

start = Timer
strData = objFSO.OpenTextFile(strTextFile,ForReading).ReadAll
wscript.echo "Read file " & formatnumber(Timer-start, 4, True) & " secs"
start = Timer
arrLines = Split(strData,vbCrLf)
wscript.echo "Split array " & formatnumber(Timer-start, 4, True) & " secs"

start = Timer
iArrayIndex=0
Do While iArrayIndex <= Ubound(arrLines)
if instr(arrLines(iArrayIndex), "Trigger") > 0 then
Exit Do
End If
iArrayIndex = iArrayIndex + 1
Loop
wscript.echo "Find line " & formatnumber(Timer-start, 4, True) & " secs"
wscript.Echo "Wanted line " & arrLines(iArrayIndex+1)

Quote
how about timing? what are you using to time the script?

Batch:

echo Start %date% %time%
[Command]
echo End %date% %time%

VBScript:

start = Timer
[Code lines]
wscript.echo "Elapsed " & formatnumber(Timer-start, 4, True) & " secs"
1606.

Solve : What is the Best OS for programming C++ and Designing graphics?

Answer»

As my windows 8 is corrupted, I dont have a recovery partition, I wanted to move to another Free Operating System like Linux or Unix. I just wanted to take an advice for professionals about the operating system I wanted to install.Windows 7 is well known. Works good
Linux Mint is reliable. Well supported.
Your choice.
More modern software tools are available in Windows. Fort example, many commercial programs require either C++ or .NET libraries from MICROSOFT ft.

Personally, I stick with MS, but I am no longer working in IT. Many commercial web sites use only Linux and its tools on the servers.
From Windows 8 to "another free operating system"? Like "Linux or Unix"? Neither Windows 8 nor Unix are free. (The name "Unix" properly refers to AT&T’s original UNIX operating system, which is not free.)
There is no best operating system - It really just comes down to personal preference.

Try a bunch of linux distributions out - Ubuntu/Mint/Elementary are great "starter" distros and have good support around them. Linux distributions are obviously free so just download a bunch of them and try them out.camerongray, What you said is right on. This is nor a disagreement, but ans inspection of your point.

The OP needs to consider his objectives, and/or preferences.
In any case, all the stuff over seven years old is already dated.
Does the OP already have some time spent on any traditional programming?
IMHO, if he does not have at least six months s of work in a traditional programming structure, he should re consider is WHOLE objective.

A commended read:
http://radar.oreilly.com/2013/01/the-future-of-programming.html
Quote

Programming is changing. The PC era is coming to an end, and software developers now work with an explosion of devices, job functions, and PROBLEMS that need different approaches from the single machine era. In our age of exploding data, the ability to do some kind of programming is increasingly important to every job, and programming is no longer the sole preserve of an engineering priesthood.
You see, it is not me saying this. As for me. I am now a very old dog. If I were 30 years younger, I would drop C++ like a dead toad.


Stick to the same OS. ( Windows 8 )
You can use Microsoft Visual Studio for Programming in C++,
And for designing, windows 7 or 8 are the best ones.I also agree that why not stick with Windows 8 that the system came with. If this system came with a legal copy of Windows 8, then you can contact the computer manufacturer and purchase replacement system recovery media for usually $35 or less.

As for Linux Distros go, my favorite is MINT KDE and MINT Cinnamon, although if you want to play video games that normally run on Windows, you MAY find that some will work with WINE, while others will degrade thru WINE or wont work at all through WINE.

As far as a title to this discussion which is kind of offset to the initial post, there are some really cool programs written in C++ that were developed under Linux for Linux, however if developing C++ programs from Windows, you will really want to develope them using Windows as the OS to base them from for testing etc. Especially if you are planning on using .NET which is pretty much explicitly Microsoft OS, however there is the Mono Project that ties .Net to Linux http://www.mono-project.com/Main_Page but of which I have not played with mono yet.
1607.

Solve : How can I run pycharm output in a separate terminal window like cmd in windows?

Answer»

Im PRESENTLY using Linux as my OS, I've installed pycharm community software and I want an the output of my code to be in a separate linux terminal.You can just open ANOTHER terminal, MOVE to the directory containing your .py file then type
Code: [Select]python filename.py to run it.

1608.

Solve : what are the Diffetences between all the Editions Of the C programming language??

Answer»

Quote from: m_ilad__ on January 07, 2014, 04:24:24 PM

that "We" couldn't EVEN give the right answer to the main question.
Your question made no sense. There are no "editions" of the C Programming language. The "Editions" you refer to are book Editions. Edits and changes made to the books themselves. I would guess some revisions do actually cover other revisions within the C language, however, as mentioned directly in the preface of the second edition, most of the edifications consist of refining examples and fixing errata. The First version covers C as it was in 1978; there wasn't a standard for it so effectively it went with one of the more standard dialects that were available. the Second Edition made revisions and fixed Errata as well as updating the code where applicable to apply to the newly standardized ANSI C standard. The second edition covers C89. There are no other revisions to that book to cover other versions of the language. Some of the other "editions" which are actually separate books might cover them but since you provide no DETAILS that is guesswork.

Quote
and my not-friend, wouldn't it be better to open a classroom and teach students the things you know?
? not sure where this is coming from. I'm not sure if knowing the difference between different books, different editions of the same books, and the versions of the programming language covered by said books can really be covered in a classroom. Seems like that basic categorization skill ought to be acquired through primary school, at the latest.
Quote
And at the beginning of the class, tell 'em "I know everything and will tell you all even if you wouldn't ASK me or like it" ?
This doesn't seem relevant at all. Borderline trolling trying to incite a response with illogical non-sequiters.
Quote from: m_ilad__ on January 07, 2014, 04:24:24 PM
and my not-friend, wouldn't it be better to open a classroom and teach students the things you know?
And at the beginning of the class, tell 'em "I know everything and will tell you all even if you wouldn't ask me or like it" ?

Oh no, I'm your "Not-Friend" - How can I sleep tonight knowing that!

I do actually help a lot of people with programming (and other subjects) and back when I was in school, during free periods I helped out in the first and second year computing classes. I did not teach pure programming in this (In our education system that starts in third year) but I taught them "Scratch" which I believe is a brilliant learning tool as it teaches kids the concepts of programming and the structure of code, but without errors caused by simple typos. I'd also say that having a small game they can then play and show friends is going to engage them a lot more than having a message print out on the screen. These kids at this point have not chosen to study this computing class, it's compulsory so they are not all that interested in raw-code. But during this I saw some amazing stuff, I saw people pick up stuff so quickly I could see straight away that they were going to be a good programmer including one girl who, without any instruction, removed parts of her "code" in order to help herself locate a bug.

I do not know everything, nor have I ever claimed that I do - There is loads of stuff I don't know, or only know parts of.

Quote
that "We" couldn't even give the right answer to the main question.
That is true, as I did not know the answer to your original question (Which contradicts your claim that "I know everything"). I did however feel that, as a new programmer you were starting on C with no good reason that you were going down the wrong path as there are many jobs and more practical uses with other languages as compared to C. I thought, as a nice person I would just let you know this so that you could make a decision about what was best. You then came out with your ridiculous claim of "Creating the best Mobile-OS of all time, with the highest security system, and with the thousands of apps." I felt that this claim was unrealistic (and still believe it is). As before I saw this as a regular mistake/belief held by new programmers so I felt I should help guide you onto a path that would be a lot better.

Of course you stay stuck in the mindset of "I know best, I won't listen to anyone else, other programmers don't make OSs because they are scared and modern programming languages make programmers stupid" so ignore all this advice given to you.

Oh yeah, and you missed a question again:
Quote
Please, explain why "Hard to read code is better"
Quote
I do actually help a lot of people with programming (and other subjects) and back when I was in school, during free periods I helped out in the first and second year computing classes. I did not teach pure programming in this (In our education system that starts in third year) but I taught them "Scratch" which I believe is a brilliant learning tool as it teaches kids the concepts of programming and the structure of code, but without errors caused by simple typos. I'd also say that having a small game they can then play and show friends is going to engage them a lot more than having a message print out on the screen. These kids at this point have not chosen to study this computing class, it's compulsory so they are not all that interested in raw-code. But during this I saw some amazing stuff, I saw people pick up stuff so quickly I could see straight away that they were going to be a good programmer including one girl who, without any instruction, removed parts of her "code" in order to help herself locate a bug.
Nice work, bud.
wish you successful in your life.
ahh... i may not have enough money to buy a good computer to USE and.... to use a compiler.
the truth is It's months that I haven't used a C compiler. months ago my computer's hard disk terminated!
all programs i wrote is in the paper...
including the program that converts binary codes into decimal and reverse, or hex to binary and reverse, or hex to decimal and reverse, or hex to octal and reverse or octal to binary or reverse and all...
i too wanted show my friends a tiny program like this. but sorry if I dont access to any computer.
[/quote]That is true, as I did not know the answer to your original question (Which contradicts your claim that "I know everything"). I did however feel that, as a new programmer you were starting on C with no good reason that you were going down the wrong path as there are many jobs and more practical uses with other languages as compared to C. I thought, as a nice person I would just let you know this so that you could make a decision about what was best. You then came out with your ridiculous claim of "Creating the best Mobile-OS of all time, with the highest security system, and with the thousands of apps." I felt that this claim was unrealistic (and still believe it is). As before I saw this as a regular mistake/belief held by new programmers so I felt I should help guide you onto a path that would be a lot better.[/quote]
Thank you a lot. you're right but I'll anyway try what I told.

Quote
Please, explain why "Hard to read code is better"
because writing programs In LLL is more challenging and fun.

Quote
This doesn't seem relevant at all. Borderline trolling trying to incite a response with illogical non-sequiters.
no it does.
Quote
Your question made no sense. There are no "editions" of the C
Programming language. The "Editions" you refer to are book
Editions. Edits and changes made to the books themselves. I
would guess some revisions do actually cover other revisions
within the C language, however, as mentioned directly in the
preface of the second edition, most of the edifications
consist of refining examples and fixing errata. The First
version covers C as it was in 1978; there wasn't a standard
for it so effectively it went with one of the more standard
dialects that were available. the Second Edition made
revisions and fixed Errata as well as updating the code where
applicable to apply to the newly standardized ANSI C
standard. The second edition covers C89. There are no other
revisions to that book to cover other versions of the
language. Some of the other "editions" which are actually
separate books might cover them but since you provide no
details that is guesswork.
thanks a lot.Quote from: BC_Programmer on January 07, 2014, 01:09:40 PM
I'm not even sure which compilers would allow Old STYLE C function declaration.
-ansi gcc switch?Quote from: m_ilad__ on January 07, 2014, 03:17:52 PM
hah.
This is hilarious. cause NoOne actually has given an answer to the main Question!
I expected a C experienced programmer to guide me.

Thank you all, anyway.
DONE.
See Reply #8. And that should be your last post that you need to be concerned about. the rest are just not relevant. Please go and do your own stuff.Thank you Geek-9pm, briandams, camerongray, bcprogrammer.

Sorry if i made you sad with my Words. i don't really want to
make anyone sad by talking about what I like.
many biggest projects had been written in C.
And this will keep going even Today.Quote from: m_ilad__ on January 08, 2014, 04:21:35 AM
Thank you Geek-9pm, briandams, camerongray, bcprogrammer.

Sorry if i made you sad with my Words. i don't really want to
make anyone sad by talking about what I like.
many biggest projects had been written in C.
And this will keep going even Today.
Well, don't worry about revisions to C. .As has been mentioned. C is not a standard tool and is not going to have any radical changes. It is needed to maintain existing software. Using it for new projects is your choice.
1609.

Solve : What is a class file for??

Answer»

I am going through recovered files and trying to figure out if I need these. I tried USING a Java decomplier which was JD-Gui. I can't make sense of any of the codes.

Now OBVIOUSLY since they are raw recovered files, they just have numbers for file names. I know lots of programs use Java so I can't even guess what they are for.



Quote

Java decomplier

If the Java is not your code that you are decompiling then this is illegal and we cant help. Oh you mean illegal as in computer terms I'm guessing? Well I can see a code and it looks perfectly normal. I just don't know what it is.
Quote from: JAJsangel on January 08, 2014, 03:04:21 PM
Oh you mean illegal as in computer terms I'm guessing? Well I can see a code and it looks perfectly normal. I just don't know what it is.

Illegal in law terms. If a program is open source, you can download the source code directly from its website. If a program does not have this meaning you have to decompile it, it is "closed source" which likely goes against the program's licence agreement.

What program is this that you are decompiling?I wasn't decompiling any program, just a bunch of random files from when I took my computer to be recovered to figure out if they were useful but I deleted them because apparently class files are just for DEVELOPERS. I wish someone had told me that earlier.

What you say kinda makes sense. I guess I've never really given any thought to Java and what it is.Quote
I tried using a Java decomplier which was JD-Gui.

then

Quote
I wasn't decompiling any program, just a bunch of random files from when I took my computer to be recovered to figure out if they were useful but I deleted them because apparently class files are just for developers.

I'd throw away that decompiler and save the files on a thumb drive or disc in case you ever need them again to refer back to.Quote from: JAJsangel on January 08, 2014, 02:14:55 PM
I am going through recovered files and trying to figure out if I need these. I tried using a Java decomplier which was JD-Gui. I can't make sense of any of the codes.

Now obviously since they are raw recovered files, they just have numbers for file names. I know lots of programs use Java so I can't even guess what they are for.

When you compile a Java program, it creates .class files. These get used by websites and games to run the program or applet.

If they were part of files that were recovered I would guess they were temporary .class files that were stored by the BROWSER to run applets. The browser will save them and run them from a temporary location, and those will be with your temporary internet files.

if I were to guess, I would say this is what those files are for. You seldom find .class files LOOSE in the file system except those that are from your Browser's temporary folder.

1610.

Solve : Python in One Easy Lesson?

Answer»

Thanks Allen. The post was about somebody who made a real serious effort to teach Python quickly to programmers that already have some skills.

Older programming tools are very strict about making declarations as to date type and functions. Python belongs to a set of tools that makes the right guess as to what a human wants n do do with code.

The Arduino controller, and other s like it, is programmed mostly in C. And sometimes in Tiny BASIC or Java. But for many, the style of a language is not as important as to its libraries. Python has a rich set o libraries and is easy to learn.

EDIT: Relevant to Python and Arduino.
Recent articles about Arduino and Python

http://makezine.com/projects/arduino-and-python-learn-serial-programming/

http://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/installing-python-and-pyserial

http://www.wired.co.uk/news/archive/2013-12/06/micro-python

For those of you who don't know what Snake Wrangling is, here is the link to it.
http://www.briggs.net.nz/snake-wrangling-for-kids.html

It is a FREE E-BOOK that helps teach kids to program in python. It makes it very fun for them to learn it. I have my two boys using it.Quote from: Squashman on January 10, 2014, 08:58:18 AM

For those of you who don't know what Snake Wrangling is, here is the link to it.
http://www.briggs.net.nz/snake-wrangling-for-kids.html

It is a FREE E-BOOK that helps teach kids to program in python. It makes it very fun for them to learn it. I have my two boys using it.

Perhaps I'm too pedantic but I'd avoid any source that uses Snake metaphors with Python, because the language was not actually named after the animal, but rather Monty Python's flying Circus. Though in retrospect that's a dumb reason not to use a specific source. I guess it's just liable to make me wonder what else they got wrong. On the other hand I imagine retconning the name temporarily makes it more kid-friendly.

One thing nice about Python is that it is actually pretty tricky to make unreadable. You'd have to put effort into it, because readability constraints are part of the syntax (eg. the spacing for control flow).

On the other hand, one weird thing is that the self reference has to be specified explicitly (I guess since the methods don't have modifiers, it's the only way to differentiate a class method from an instance method), and "special" methods like __getitem__ have those funky underscores to flag them as a special function, but because those are usually accessed using something else they don't typically appear except at declaration. (And they have to be tagged somehow).


Quote
second, the OP does not specifically state its only for Python discussion.

Title: About Python
Reply #1: Python.
Reply #2: Python.
Reply #3: Python.
Reply #4: Python.
Reply #5: Perl.

Thread subjects are not a game of Duck, Duck, Goose.

Quote from: BC_Programmer on January 10, 2014, 10:35:46 AM
Perhaps I'm too pedantic but I'd avoid any source that uses Snake metaphors with Python, because the language was not actually named after the animal, but rather Monty Python's flying Circus. Though in retrospect that's a dumb reason not to use a specific source. I guess it's just liable to make me wonder what else they got wrong. On the other hand I imagine retconning the name temporarily makes it more kid-friendly.

Page 3 of the book.
Quote
Apart from being a snake, Python is also a programming language. However,
it was not named after a legless reptile; rather it is one of the few programming
languages named after a TV show. Monty Python was a British comedy show
popular during the 1970’s (and still popular now, actually), which you have to be a
certain age to find amusing. Anyone below the age of about. . . let’s say 12. . . will
wonder what all the fuss is all about
Quote from: Squashman on January 10, 2014, 10:54:07 AM
Page 3 of the book.

Cool, it was a purposeful/temporary retcon to make it more accessible.Video about Python. From UK, of course.
http://www.mirror.co.uk/news/uk-news/monty-python-dance-remix-johnny-2986720Quote from: BC_Programmer on January 10, 2014, 10:35:46 AM
One thing nice about Python is that it is actually pretty tricky to make unreadable. You'd have to put effort into it, because readability constraints are part of the syntax (eg. the spacing for control flow).
well, because its object oriented, most often times you can write code like this
Code: [Select]method1(**args).method2( **args ).somethingelse( **args)
still, it depends on programmer. If he chooses to write something like this
Code: [Select]f=lambda x="8<:477\02092020162\020\037",y="01001000110100101":reduce(lambda
x,y:x+y,map(lambda y,x:chr(ord(y)*2+x),x,map(int,y)));print f();
or this
Code: [Select] print ''.join('%(pre)s%(num)s %(bot)s on the wall, %(nul)s %(bot)s,\n%(tak)s\n' % (lambda c,b:
{'pre':['','%s %s on the wall.\n\n' % (c,b)][abs(cmp(c,'Ninety-nine'))],
'num':c, 'nul':c.lower(), 'bot':b,
'tak':['Go to the store and buy some more... Ninety-nine %s.' % b,'Take one down, pass it around,'][abs(cmp(x,0))]
})((lambda x,o: [(['Twenty','Thirty','Forty','Fifty',
'Sixty','Seventy','Eighty','Ninety'][x/10-2]+'-'+o.lower()).replace('-no more',''), o][int(x<20)])(x, ['No more','One','Two',
'Three','Four','Five','Six','Seven','Eight',
'Nine','Ten','Eleven','Twelve','Thirteen','Fourteen',
'Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'][[x,x%10][int(x>=20)]]),'bottle%s of beer' % ['','s'][abs(cmp(x,1))])
for x in xrange(99,-1,-1))

some of the things that can lead to unread Python code
- nested lambdas
- redefine functions by assignment
- make an single instance of the % operator used for both modulus and STRING formatting
- same with +, * for addition, string concatenation, etc.
- evade indentation enforcement by writing things in recursive pseudo-functional ways
- do something like foo(bar(), baz()) where bar() redefines foo() and baz()
- litter the code with numeric and string literals that look like they're doing something (but don't)
- cause exceptions solely for the purpose of later extracting obscure data from them

Copied from here

Python code, can be made unreadable! Its all about the programmer! No one can deny that, not even Quantos.
and not to mention, because languages that doesn't have static typing often make it not easy to understand what variables stand for, unless we have good naming convention. eg myvar_int , myvar_str

Quote from: BC_Programmer on January 10, 2014, 10:35:46 AM
On the other hand, one weird thing is that the self reference has to be specified explicitly (I guess since the methods don't have modifiers, it's the only way to differentiate a class method from an instance method), and "special" methods like __getitem__ have those funky underscores to flag them as a special function, but because those are usually accessed using something else they don't typically appear except at declaration. (And they have to be tagged somehow).
all language have their quirks. What matters is, use their syntax correctly and make it do the job. That's more important than ranting.


Quote from: BC_Programmer on January 10, 2014, 10:35:46 AM
Title: About Python
Reply #1: Python.
Reply #2: Python.
Reply #3: Python.
Reply #4: Python.
Reply #5: Perl.

Thread subjects are not a game of Duck, Duck, Goose.
wrong. #2 is game. I didn't post any Perl code , or Java code, or Ruby code, or PHP code. Please, if you want to start this, I am game. The thread just merely says "Python in one easy lesson". Thread author didn't say anything else with regards to discusson on other languages. Why are all these assumptions made that only Python can be DISCUSSED. This is a fact. Don't deny it. If you people don't like my comments, then debate it and refute my points like a knowledgable adult, don't keep giving the excuse that "this thread is only for Python" and only Python can be discussed. FYI, this thread is in a Computer programming forum. Its not in a purely Python forum. And this is also a fact.

What is so hard to understsand that I merely posted a factual comment, that most languages with good RS232 libraries can also do the job ? So difficult to understand that its a general observable, factual comment and you people have to make it sound like a language war.Quote
most languages with good RS232 libraries can also do the job
That is true. Nowadays a serial library ought also have other serial standards. USB 2.0 ought to be in the library for applications using embedded devices. I was mildly pressurized that good libraries on now available in Python and other popular computer languages. In the days of my youth I had write code at the lowest level and integrate it into a higher language.
Quote from: Geek-9pm on January 10, 2014, 07:50:30 PM
That is true. Nowadays a serial library ought also have other serial standards. USB 2.0 ought to be in the library for applications using embedded devices. I was mildly pressurized that good libraries on now available in Python and other popular computer languages. In the days of my youth I had write code at the lowest level and integrate it into a higher language.

at last, some decent discussion. Last time there was cheeseshop, now they call it pypi , the "CPAN" of Python.
1611.

Solve : How to minimize my program into right-bottom's notification area?

Answer»

I wrote a program which can LAUNCH other application programs. I hope my program can minimize into right-bottom's notification area after an application is LAUNCHED automatically. How can I do? Any API I can CALL?Notifications and the Notification Area

short answer: use the API function shell_notifyicon.Thanks. But the CODES are all C++. My program is in C#. They can't be applied to my program.Quote from: Stan HUANG on January 12, 2014, 09:13:22 PM

Thanks. But the codes are all C++. My program is in C#. They can't be applied to my program.

The Windows API is C. You can use P/Invoke.

If you are using Windows Forms you can simply use the Windows Forms NotifyIcon control.
1612.

Solve : Trying To Get MD5 out of a .bat file?

Answer»

Quote from: Salmon Trout on January 15, 2014, 12:31:46 PM

7-zip has AES-256 encryption.
Definitely the best option is to use a 3rd party utility. Either zipping or pgp.

But we actually have a few threads over on the dostips.com site about AES encryption using pure batch. It is painfully slow but I think the guy just wrote it as a proof of concept.Quote from: camerongray on January 15, 2014, 09:43:57 AM
You are new here and have made a really bad first impression.
I might be new here, but i am the only one giving TS what he wants. well i don't need anyone having good impression of me, EXCEPT for TS. I am here to solve TS problem only, not yours.Quote from: briandams on January 15, 2014, 04:38:18 PM
I might be new here, but i am the only one giving TS what he wants. well i don't need anyone having good impression of me, except for TS. I am here to solve TS problem only, not yours.
Brian, please read post 9 of this thread and explain how the TS is going to use MD5SUM to encrypt his text FILE so that nobody can read it and then be able to use md5sum to un-encrypt the file so that it can be readable again.

Just read the whole first page of this entire thread. You will see that the TS is confused on what md5sum is versus encryption.Quote from: briandams on January 15, 2014, 04:38:18 PM
I might be new here, but i am the only one giving TS what he wants. well i don't need anyone having good impression of me, except for TS. I am here to solve TS problem only, not yours.

Few things you need to learn when you are on this forum:

  • Don't take the OP's post at face value - If you realise that the OP has made a mistake then you need to look into it! What the OP SAYS they want is not always what they are really looking for!
  • Learn to respect other members on this forum - You haven't even been here a month and have already been warned about your attitude!
  • Your reputation and people's impression of you on a forum like this really does count - Joining and instantly WALKING around like you own the place and disrespecting other, often very long TIME members or even moderators is not acceptable!
EVERYONE in this thread - please stop addressing each other. Just address the question asked by the OP. Thank you.
1613.

Solve : Batch File to Check MS Patch Updates?

Answer»

Hi, I'm scratching my HEAD at trying to compare a list of expected PATCH updates (Patch_List.txt) against what actually is installed on a computer.

I'm using a combination of "WMIC QFE" and Registry queries to return a list of KB updates - The problem is when I query the QFE list, it doesn't return what I want based on ERRORLEVEL.

In normal CMD tests, the COMMAND returns the expected ERRORLEVEL as 0 as successful, or 1 as unsuccessful. But in the batch file, it always returns 1.

I've used Google searches to spawn this script... Hopefully someone here can fix the script to return the expected results...

CODE: [Select]@ECHO OFF
WMIC QFE GET HOTFIXID>%~dp0QFE_list.txt
FOR /f %%a IN (%~dp0Patch_List.txt) DO (
CALL :PATCH_LIST %%a

)
GOTO :EOF

:PATCH_LIST
REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s /f "%1">NULL
IF %ERRORLEVEL% EQU 0 ECHO %1: INSTALLED
IF %ERRORLEVEL% NEQ 0 (
ECHO FIND %1
FIND /C "%1" %~dp0QFE_List.txt>NULL
IF %ERRORLEVEL% EQU 0 ECHO %1: QFE INSTALLED
IF %ERRORLEVEL% NEQ 0 ECHO %1: **** NOT INSTALLED! ****
)

..Thanks in advance You are inside a Code Block. When you are trying to execute multiple commands inside parentheses you need to use delayed expansion for your variables to work. But because all you are doing is checking the errorlevel inside the code block just use ERROLEVEL

Code: [Select]IF ERRORLEVEL 0 ECHO %1: QFE INSTALLED
IF ERRORLEVEL 1 ECHO %1: **** NOT INSTALLED! ****
If you want to use delayed expansion then you need to do this.
Code: [Select]setlocal enabledelayedexpansion
IF %ERRORLEVEL% NEQ 0 (
ECHO FIND %1
FIND /C "%1" %~dp0QFE_List.txt>NULL
IF !ERRORLEVEL! EQU 0 ECHO %1: QFE INSTALLED
IF !ERRORLEVEL! NEQ 0 ECHO %1: **** NOT INSTALLED! ****
)Thank you for your help - my script works perfectly now...

1614.

Solve : Awk - A nifty little tool for text manipulation and more.?

Answer»

Dealing with date and time is more or less a common task when batch scripting. Awk provides simple date and time function for basic time/date manipulation needs.
1) systime()
2) strftime()
3) mktime()

1) systime().
This is the the number of seconds since the system epoch. systime is commonly used to create a random number seed.

Code: [Select]C:\>awk "BEGIN{ print systime(); } "
1389169226

2) strftime().
This is a function to format a timestamp based on the contents of the format string. This is useful if you want to create a time stamp on windows.eg To get the full 4-digits year, use the "%Y" format
Code: [Select]C:\>awk "BEGIN{ print strftime(\"%Y\") } "
2014


To get YYYY-MM-DD-HH-mm-ss timestamp
Code: [Select]C:\>awk "BEGIN{ print strftime(\"%Y-%m-%d-%H-%M-%S\") } "
2014-01-08-16-24-23

you can then capture the results in the usual DOS for loop.


3) mktime( date specs )
"date specs" argument to mktime is a string of the form YYYY MM DD HH MM SS.
YYYY = full year
MM = month, 1 to 12
DD = day, 1 to 31
HH = hour, 0 to 23
mm = minute, 0 to 59
SS = seconds, 0 to 59
mktime will create a timestamp similar to systime()
eg
Code: [Select]C:\>awk "BEGIN{string=\"2014 01 01 0 0 0\"; print mktime(string) } "
1388505600

mktime is commonly use to get time difference. eg compare the date "2014 01 01 0 0 0 " against today's date and get their difference (in secs)

Code: [Select]C:\>awk "BEGIN{string=\"2014 01 01 0 0 0\"; s=mktime(string); print (systime() - s) } "
664866
this is useful if for example, you are PARSING a log file and filtering the date/time column for a specific date.


to be continued

- brianadamsSometimes you many want to merge a collection of similar items. eg
Code: [Select]C_1,KOG0155
C_1,KOG0306
C_2,KOG3259
C_3,KOG0931
C_2,KOG3638
C_4,KOG0956
C_6,KOG0155
C_1,KOG0306
C_3,KOG3259
C_4,KOG0931
C_5,KOG3638
C_1,KOG0956

to become something like this:
Code: [Select]C_1,KOG0155 ,KOG0306,KOG0306,KOG0956
C_2,KOG3259, KOG3638
C_3,KOG0931, KOG3259
C_4,KOG0956, KOG0931
C_6,KOG0155
C_5,KOG3638

You can make use of associative arrays in awk

Code: [Select]C:\>awk -F"," "{ array[$1] = array[$1]\",\"$2 }END{ for(idx in array) print idx, a[idx]}"
C_3 ,KOG0931,KOG3259
C_4 ,KOG0956,KOG0931
C_5 ,KOG3638
C_6 ,KOG0155
C_1 ,KOG0155,KOG0306,KOG0306,KOG0956
C_2 ,KOG3259,KOG3638
Lots of awk stuff lately from you.
Quote from: briandams on January 16, 2014, 06:22:54 AM


That's how you can call an external DOS command and have it displayed inside awk program itself.

getline returns 1 if it finds a record, and 0 if the end of the file is encountered. If there is some error in getting a record, such as a file that cannot be opened, then getline returns -1. It is generally good practice to always explicitly test for >0 while reading a file or handling input from pipes.

to be continued

- brianadams
The error is stored within AWK's error variable. It does not pass the error back to the calling batch file or CMD window you have open.Quote from: Squashman on January 16, 2014, 08:49:21 AM
The error is stored within AWK's error variable. It does not pass the error back to the calling batch file or CMD window you have open.


awk internally doesn't have a mechanism for CHECKING file existence such as -f test for linux. so most of the time if you want to do that then have to make a system call , OR to call getline and check -1.
Code: [Select]
C:\>awk "BEGIN{ x=getline < \"ddd\" ; print x }"
-1
ERRNO is just a string internal for awk.
Code: [Select]C:\>awk "BEGIN{ getline < \"ddd\" ; print ERRNO }"
No such file or directory

so it doesn't get returned to DOS errorlevel. you can capture it though using exit().
Code: [Select]C:\>awk "BEGIN{ x=getline < \"ddd\" ; exit(x) }"
C:\>echo %errorlevel%
-1

or
Code: [Select]C:\> awk "BEGIN{ if ((\"ddd\" | getline) <= 0 ) exit(-1) ; }" 2>nul
C:\>echo %errorlevel%
-1
Quote from: briandams on January 16, 2014, 09:03:05 AM

awk internally doesn't have a mechanism for checking file existence such as -f test for linux. so most of the time if you want to do that then have to make a system call , OR to call getline and check -1.

Then why not use the shells built-in functionality to check for the file existence before running your AWK command.

Code: [Select]IF EXIST foo.txt awk.........Quote from: briandams on January 16, 2014, 09:03:05 AM
Quote
The error is stored within AWK's error variable. It does not pass the error back to the calling batch file or CMD window you have open.
awk internally doesn't have a mechanism for checking file existence such as -f test for linux. so most of the time if you want to do that then have to make a system call , OR to call getline and check -1.

I can see copy-pasting your POSTS from another forum practically verbatim, because they had never really been posted here so could be valuable to some.But when responses like the above are copy-pasted verbatim to rather different questions, that's just a bit weird, I think.
Quote from: BC_Programmer on January 16, 2014, 10:42:34 AM
copy-pasting your posts from another forum

I wondered about that.
Quote from: Squashman on January 16, 2014, 09:42:31 AM
Then why not use the shells built-in functionality to check for the file existence before running your AWK command.

Code: [Select]IF EXIST foo.txt awk.........
this can be done in awk as well as shown in the examples but if you want to do it in the shell , thats up to individual.Quote from: BC_Programmer on January 16, 2014, 10:42:34 AM
But when responses like the above are copy-pasted verbatim to rather different questions, that's just a bit weird, I think.

The author for that dostips thread is yours truly . Hence I can copy and paste all I want. I don't have a blog, if not, i would just redirect readers there. That's not a different question. I just felt the response for the question look a bit similar as i had answered it in dostips. hence the copy and paste. Quote from: Salmon Trout on January 16, 2014, 11:12:34 AM
I wondered about that.

as explained. I am the original author of that dostip thread. Not that hard to start a free blog or free website.Sometimes you may need to filter a file using keywords from another file. say you have file1.txt and file2.txt
Code: [Select]
C:\>type file1.txt
cheese
milk
sausage

C:\>type file2.txt
milk
cheese
popcorn
pasta
milk
sausage
cheese
melon

you want to filter file2.txt with file1.txt such that only those not matching remains. eg
Code: [Select]popcorn
pasta
melon

We can do this with awk one liner.
Code: [Select]C:\>awk "FNR==NR{ a[$1] ;next} { if ( !($0 in a) ) { print } }" file1.txt file2.txt
popcorn
pasta
melon

Explanation:
FNR==NR : FNR means the number of records read so FAR. NR means the TOTAL number of records read from all files. Hence, the idiom FNR==NR means to read all the records from the first file and store to array.
When awk finish processing the first file, the FNR and NR would be different values, so the 2nd file will be processed. In this case the
Code: [Select] if ( !($0 in a) ) { print }
statement just says to compare the item inside the array and print the record if not found.
Here are some commonly used one liners for file/text parsing

1) Deleting last line of a file
2) Deleting first line of file
3) Print a range of lines
4) Print lines not in a range
5) Concatenating two files
6) Transposing a file
7) Print first and last line
8) Print the line above and below a pattern
9) Print all lines until a matched pattern
10) Print from a matched pattern till the end of file


1) Deleting last line of a file
Code: [Select]C:\>type myFile.txt
CAT
MAT
RAT

C:\>awk "BEGIN{ RS=\"\0\"} { for(i=1;i<NF;i++) print $i } " myFile.txt
CAT
MAT


2) Deleting first line of file
Code: [Select]C:\> awk "NR>1 { print } " myFile.txt
MAT
RAT


3) Print a range of lines. eg print line 3 to line 5
Code: [Select]C:\> type myFile.txt
CAT
MAT
RAT
BAT
TAT
DAT
PAT

C:\> awk "NR==3,NR==5{ print } " myFile.txt
RAT
BAT
TAT

4) Print lines not in a range . eg don't print lines number 3 to 5
Code: [Select]C:\>awk "!(NR>=3 && NR<=5) { print }" myFile.txt
CAT
MAT
DAT
PAT

5) Concatenating two files
Code: [Select]C:\>awk "{print}" file1 file2 > newFile.txt


6) Transposing a file
Code: [Select]C:\> awk "BEGIN{ORS=\" \"}{print}" myFile.txt
CAT MAT RAT BAT TAT DAT PAT

7) Print first and last line
Code: [Select]C:\> awk "NR==1;END{print}" myFile.txt
CAT
PAT

8) Print the line above and below a pattern. eg Search for "RAT" and print the lines above and below
Code: [Select]C:\> type myFile.txt
CAT
MAT
RAT
BAT
TAT
DAT
PAT

C:\> awk "/RAT/{print y;print;f=1;next}f{print;f=0}{y=$0}" myFile.txt
MAT
RAT
BAT


9) Print all lines until a matched pattern
. eg Print until the word "BAT" is found
Code: [Select]C:\> awk "/BAT/{exit}{print}" myFile.txt

10) Print from a matched pattern till the end of file
Code: [Select]C:\> awk "/TAT/,0" myFile.txt
TAT
DAT
PAT
1615.

Solve : Homework Help c#?

Answer»

Okay, so I havent taken c# in over a year and a half and im really no good at it. Im not really looking for a solution just ideas and some syntax error help.
Heres what I am trying to do:
Write a C# program to simulate the drawing from a deck of 52 porker cards valued from 1 to 13 with 4 suits. One round of drawing consists of randomly pull any 4 cards from the 52-card deck. Therefore, the same card cannot appeared more than once. The program will perform 10,000 rounds of drawing and tallying the frequencies of the following possible results for the 4 cards pulled: (a)the 4 cards are having the same suit, (b)the 4 cards are from the 4 different suits, (c)the 4 cards are having the same value, (d)3 cards have the same value, (e)EXACTLY 2 different pairs of 2 same-value cards, and (f)only 2 cards have the same value. Notice that (b) may occured together with (c) - (f).

This is what I have so far:
using System;

namespace ConsoleApplication3
{

class Program
{
int[] ranArr = new int[4];

STATIC int GenerateRandomNum()
{
int cleanRandNum;
Random ran = new Random();
cleanRandNum = ran.Next(1, 53);

return cleanRandNum;
}
static void Main(string[] args)
{



int[] crdv = new int[4]; //1-13

int[] crds = new int[4];//1-4


int idx, randNum;

//Draw 4 cards

for (idx = 0; idx < crdv.Length; idx++)
{
//randNum = ran.Next(1, 53);



Console.Write(randNum + ", "); //Getting a syntax error for this int randNum and the one below. Use of unassigned local variable 'randNum'

crdv[idx] = randNum % 13; //Remander value Heart = 1, Spades = 2, Diamonds = 3, Clubs = 4
if (crdv[idx] != 0)
crds[idx] = randNum / 13 + 1;
else crds[idx] = randNum / 13;
if (crdv[idx] == 0) crdv[idx] = 13;

//crdv[idx] = ran.Next(1, 13);//Card values Ace-King
//crds[idx] = ran.Next(1, 5);//Card Suits (H,C,S,D)

}

// Array.Sort(crdv);//Sorts values

// Array.Sort(crds);//Sorts Suits

foreach (int val in crdv)
Console.Write(val + ", ");

Console.WriteLine();



foreach (int suit in crds)
Console.Write(suit + ", "); //Spade=1,Hearts=2,Clubs=3,Diamonds=4

Console.Read();

}

}

}

From some lessons I took online at the MS C# academy, they say to try to read it like a paragraph. The thing is that Im not really understanding what I am doing lol. The program above is the assignment we have been working on in class. I just need to KNOW I am heading in the right direction and if not where to fix it and how. The commented out section is what we started with before adding other stuff in. I just commented those out so I wouldnt lose them since the program ran with them.

Thanks for any and all help!

1616.

Solve : Clip is black on Windows Movie Maker?

Answer»

I have a DELL Studio with Vista...I've worked on a few projects before and had no problem with Movie Maker until now. I published a project, uploaded it to youtube, and noticed it goes black with no SOUNDS at the same spot every time and then picks up again after 30 seconds of that. I watched the project file on my computer and, sure enough, it goes black in the same place....I redowloaded the original video clips and attempted to recreate the project in Movie Maker, but now the entire clip that I imported is black! I've already "cleared filters" and updated device DRIVERS and that didn't work. I even downloaded a free trial of a different movie editor but the clip is going black in that one too! The two other imported clips work HOWEVER....if this helps, the clip that's going black is lengthy-25 min. Help please!

1617.

Solve : Deploying SDL application?

Answer»

Hi. I am USING Visual STUDIO 2008 Pro and I have recently got into working with SDL for graphics and video. I just got done with making a simple menu-style program using mouse events and I want to deploy it to my own computer. I've read the VS documentation for creating a Setup and Deployment Project for deploying my program, and everything goes ok until I try to run it afterwards. After I open up the application, the SDL window pops up, but with no display, and an error message comes up along with it saying something along the lines of "Something didn't go right, Windows is looking for a solution for the problem" or something like that. My program uses SDL_image.h, and SDL_ttf.h, along with the SDL.h header files. I'm just thinking I didn't go through the setup and deployment PROCESS correctly, like I discluded something I wasn't supposed to. all help is APPRECIATED and thank you for TAKING your time in reading this topic.

1618.

Solve : VBA Macro Help in Excel?

Answer»

All,

I have a worksheet (attached). I am trying (and failing) to WRITE VBA Macro that when it runs, it automatically filters a column containing names. I need it to show only the rows where certain names are found in the Column. I have been able to get it to show with single names, but for some reason, it wont return the row if there is more than one name in the column.

For Example:
Column A
Thomas Smith
Thomas Smith, Jane Doe
John Doe
John Doe, Jimmy Jack
Sara Stealth
Sara Stealth, Jenny Dim

When the macro runs, it returns just the rows that are bolded, but should return all rows....here is the Code

Sub MACRO1()
ActiveSheet.Range("$A$3:$K$143").AutoFilter Field:=6, Criteria1:=Array("Thomas Smith", _
"Jane Doe", "John Doe", "Jimmy Jack", "Sara Stealth", "Jenny Dim"), Operator:=xlFilterValues
End Sub
Did you try using Wildcards?I did, I have to admit that I am not knowledgable of the formatting of wildcards, but whatever combination I tried to use it ended up not returning the row...for instance if i tried to use a wildcard for Thomas Smith, it would not return anything with Thomas Smith whereas before it would at least return rows with Thomas Smith being the only entry. Doesn't seem to like using Wildcards when there is more than 2 entries in the array.

If I chop down the array to this.
Code: [Select]Sub NameFilter()
ActiveSheet.Range("$A$1:$K$143").AutoFilter Field:=1, Criteria1:=Array("*Thomas Smith*", _
"*John Doe*"), Operator:=xlFilterValues
End SubThe output is this.
Thomas Smith
Thomas Smith, Jane Doe
John Doe
John Doe, Jimmy Jack

If I add a 3rd entry to the arrary:
Code: [Select]Sub NameFilter()
ActiveSheet.Range("$A$1:$K$143").AutoFilter Field:=1, Criteria1:=Array("*Thomas Smith*", _
"*John Doe*" , "Sarah Stealth"), Operator:=xlFilterValues
End SubNothing will output.

You might have to try and build the array on the fly with the cells you actually want to display. Physically look at each cell for your search terms and if it finds your search terms in the cell add that cells contents to the array.

Testing on Excel 2007


I haven't worked with macros for a long time but I simply had this thought about this scenario. You say "When the macro runs, it returns just the rows that are bolded, but should return all rows ...". As we can see, you have two names, i.e. two full (first and last name pairs), in some cells, separated by a comma. Excel is returning the first name from the cell where that name matches a name contained in the macro. So, the comma separator is preventing the names after a comma from being displayed. That seems to be a key point that needs to be resolved. I don't have the solution; just making an observation. soybean,
The issue is that the whole Cell contents need to be matched. When you turn on the filter option manually for a column you will see that the options for filter are both names combined with the comma because that is what is in the cell contents. You can match with a Wildcard but then you are limited to two search terms in the arrary

It wouldn't be that hard to loop through the entire column and search for the Names in each cell and then put the cell contents into the Array. I do something similar with VBscript but the syntax for VBA is a bit different so I am not sure how to code it for them.Squashman, could you possibly givea start to it or post your vbscript...like I said I am very inexperienced in VBA and have exhausted my knowledge and google searches. Quote from: tdrob28 on January 24, 2014, 12:54:31 PM

Squashman, could you possibly givea start to it or post your vbscript...like I said I am very inexperienced in VBA and have exhausted my knowledge and google searches.
I am very new to vbscript as well and have never done much vba besides just recording a macro.
I have some code at work so I will have to get BACK to you on monday.
1619.

Solve : build on debug visual studio 2010 C++ not working anymore?

Answer»

Hi,

When i used to start debugging my program, visual studios 2010 used to build my program then start debugging.

This is DONE by default, i havent changed any settings but for some reason it DOESNT auto build anymore and i have to build, then debug.

i KNOW it only takes a few seconds but i dont do this once a week and its very irritating.

any HELP would be greatly appreciated.

Khas

1620.

Solve : Batch File - Combination of WMIC and NET USE to gather Local User Properties?

Answer»

Hello, I am trying to output the local user accounts and their properties by using WMIC QUERIES to get a list of Local accounts and then run the NET USE command against the account name for the properties. However, the LocalAccounts.txt with the user account names in is not been read by the FOR command.

The weird thing is if I create my own TEXT file called LocalAccounts.txt with the same DATA it works. It just doesn't seem to like what is generated from the WMIC command..?

Can someone help solve?

Thanks
Tom

Code: [Select]@ECHO OFF
WMIC PATH WIN32_USERACCOUNT WHERE LOCALACCOUNT=TRUE GET Name>"%~dp0LocalAccounts.txt"
FOR /f "usebackq delims=|" %%a IN ("%~dp0LocalAccounts.txt") DO (

CALL :USER_INFO %%a

)
IF EXIST "%~dp0LocalAccounts.txt" DEL /F "%~dp0LocalAccounts.txt"
GOTO :EOF
:USER_INFO
NET USER %1
ECHO.
try this

Code: [Select]for /F .... ( 'WMIC PATH WIN32_USERACCOUNT WHERE LOCALACCOUNT=TRUE get /all /format:csv' ) do (
...
)

use delims as ","This can be called 'string substitution'. Of course you can do that in Notepad, but not from the command line. SED runs from a command and can be inside batch file. When done, SED goes BACK to the batch file.

1621.

Solve : Pointer to an array (c programming)?

Answer»

Hi folks,

I am confuse on this topic. What is relevant of pointer to an array.
I thought that array itself is a pointer. Which keep track of it's memory addresses.
If we print it using %u it will print the address and if we USE %d it will print the value in it.
Example
#include
void main()
{
INT s[2][2] = { {12,34},{56,78}};
int (*p)[2]; /* please explain this with more accuracy*/
int i,j*pint; /* please explain this with more accuracy*/
for (i=0;1<2;i++)
{ p = &s;
pint = (int*)p;
printf("/n");
for(j=0;j<2;j++) printf("%d",*(pint+j));
}
}

output

12 34
56 78

Thank you please do explain it with Lehman language. I would be greatfull.

Regards
Vishu
One post per question please. I duplicated the original and am MOVING this to the correct forum.Please LET me know the details

1622.

Solve : GW-Basic without 64k memory limit?

Answer»

Was wondering if ANYONE knew if there were any editor/compilers out there that support the old language of GW-Basic but without the original 64k memory limit to work with?Quote from: DaveLembke on August 05, 2010, 03:52:40 PM

Was wondering if anyone knew if there were any editor/compilers out there that support the old language of GW-Basic but without the original 64k memory limit to work with?

I think freeBASIC can still interpret and run the old Street BASIC dialects from BASICA and GW-BASIC.If your OS will support it, I believe the QBasic interpreter will run GW-BASIC programs but in order to load them they need to be in ASCII FORMAT - that is, saved from GW-BASIC with the ,a option.

QBasic allows 64K memory for code PER subroutine and 64K for data. Arrays, fixed-length strings, and user-defined types get 64K each. There is 64K of memory available for CODE per SUBroutine and 64K of memory for DATA. You can also have far arrays of numerics, fixed-length strings, and user- defined types of up to 64K each.

You can download QBasic free from Microsoft:

http://download.microsoft.com/download/win95upg/tool_s/1.0/w95/en-us/olddos.exe



Not very accurate after only 10000 ITERATIONS...


Thanks everyone... QBasic would definately do it and I wasnt aware of it being free for download. I figured like GW-Basic on DOS 2.11 that it was only available on a floppy disk of DOS. My floppies are long gone, but its cool that I will be able to run some old programs through a legal downloadable COPY of QBasic.

Many Thanks!!!QBasic is on any Windows 95/98/ME install CD.
1623.

Solve : batch programming add partial file name to column in csv?

Answer»

Hope someone would help me on BATCH programming please!

File name: Customer_call_list.csv
How to ADD partial file name: "call" to a new column up to EOF?

Here is the CONTENT of Customer_call_list.csv (in EXCEL comma delimited)

Customer Date
A 1/1/14
B 1/8/14
C 1/18/14
D 1/28/14


Thank you very much!

1624.

Solve : Database backup script issue?

Answer»

Hello everyone,

I created a batch script with the help of others and modified it to fit my needs. Anyways the first portion of the script works, it creates the backup, and compress it properly but the issue i am having is trying to delete the .bak file after its been compressed, so All i want to see is the zip file. I have searched long and hard for this answer but can't seem to get it right.


@echo Creating Backup folder located in c:/
MKDIR C:\Backups
If exist "C:\Backups" ECHO Directory EXISTS!
@echo Backing up your Database....This may take awhile.....
sqlcmd -S Servername\sqlinstancename -i backupDBscript.sql
SET SQL_Backup_script=C:\Path to file
SET MY_Path=C:\path to backup
set mydate=%date:~4,2%%date:~7,2%%date:~10,4%
for %%x in (*.bak) do cscript "%SQL_Backup_script%\zip.vbs" "%MY_PATH%\%%x" "%MY_PATH%\DB_%mydate%.zip"
del /Q/R "C:\Backups\*.bak"
@pauseI did add del "C:\Backups\*.bak" /q in a test batch file that worked but when i put it in the original batch file it didn't delete it
/R is not a VALID parameter or switch for the DEL command in batch code (command-line). /Q makes it run quietly without prompt and /F would force it to delete read-only files if that is what you were trying to achieve. What might help you while you are learning is to open command prompt and simply type the command you want help on and follow it with [space] /? (i.e. DEL /?)

Try DEL /Q /F "C:\Backups\*.bak"That didn't work :/bumpbump
bumpity bumpI am confused as to why you are hard coding the path C:\backup. Shouldn't all your .bak files be in the MY_PATH directory?
The code you were given should work as long as your .bak files are in that folder.
Code: [Select] DEL /Q /F "C:\Backups\*.bak"I was placing file in WRONG path Thanks guys!

1625.

Solve : getline doesnt work in c++?

Answer»

Hi,

Im trying to read in a string that contains spaces and for some reason it doesnt PAUSE for me to input. im using Visual Studio 2010 and my GETLINE is:

string tempMessage

getline(cin, tempMessage);

any IDEAS would be great.

Thanks,
KhasDo you have any code above this code that USES

cin >> somevar

if you use "cin >>" and that input contains a newline then getline won't stop, because cin >> leaves the newline in the input stream, which is the FIRST thing the getline will see when it gets called.

To fix this, before calling getline use

Code: [Select]cin.ignore();
http://www.cplusplus.com/reference/iostream/istream/ignore/

That works perfectly,

Thank you soooo much

1626.

Solve : how to install Apache,MYSQL & PHP on windows 7 32 bit os??

Answer»

I tried to install AMP but i failed . Please HELP me step by step as i am a BEGINNER . Also help me in configuring them. How to CONFIGURE Apache, MYSQL & PHP.Assuming this is for development use and not production hosting (Which you wouldn't want to do on WINDOWS 7) then the easiest way is to use a BUNDLE such as WampServer http://www.wampserver.com/en/. This is a single installer that will set up everything for you. It would also be a good idea to remove anything you already have installed such as Apache, PHP and MySQL before installing this to prevent issues.Or XAMPP

1627.

Solve : what languge??

Answer»

Hi guys
I want to write a program that looks at video footage and recognizes number plates.
I don't know which language would be best. I should say that I'm a beginner.
Any suggestions would be great also are there any good programming books out there.

MickQuote from: mickeyloveswift on February 05, 2014, 11:29:27 AM

Hi guys
I want to write a program that looks at video footage and recognizes number plates.
I don't know which language would be best. I should say that I'm a beginner.
Any suggestions would be great also are there any good programming books out there.

Mick
What you a seeking may be beyond l your skill.
Your question implies you do not have a basic training in computer languages and how t hey are used. Making a machine., a computer, read like a human requires a thing called AI. Here is an canticle about that.

http://en.wikipedia.org/wiki/Artificial_intelligence
Quote
Artificial intelligence (AI) is the intelligence exhibited by machines or software, and the branch of computer science that develops machines and software with intelligence. Major AI researchers and textbooks define the field as "the study and design of intelligent agents",[1] where an intelligent agent is a system that perceives its environment and takes actions that maximize its chances of success.[2] John McCarthy, who coined the term in 1955,[3] defines it as "the science and engineering of making intelligent machines".[4]

AI research is highly technical and specialised, and is deeply divided into subfields that often fail to communicate with each other.[5] Some of the division is due to social and cultural factors: subfields have grown up around particular institutions and the work of individual researchers. AI research is also divided by several technical issues. Some subfields focus on the solution of specific problems. Others focus on one of several possible approaches or on the use of a particular tool or towards the accomplishment of particular applications.
...
Maybe somebody said that you can do anything with computers. Wello, not really everything. But a lot of advancement has been make. Another thing you want to look at is OCR.
Optical character recognition
http://en.wikipedia.org/wiki/Optical_character_recognition
Quote
Optical Character Recognition, usually abbreviated to OCR, is the mechanical or electronic conversion of scanned or photoed images of typewritten or printed text into machine-encoded/computer-readable text. It is widely used as a form of data entry from some sort of original paper data source, whether passport documents, invoices, bank statement, receipts, business card, mail, or any number of printed records. It is a common method of digitizing printed texts so that they can be electronically edited, searched, stored more compactly, displayed on-line, and used in machine processes such as machine translation, text-to-speech, key data extraction and text mining. OCR is a field of research in pattern recognition, artificial intelligence and computer vision.
For more, follow the links given above.
Are you going to write your own OCR ENGINE? If you are clever enough to do that, you would surely already have a pretty good idea what language would be appropriate. If you are going to use a scripting language to string together various tools e.g. Tesseract, then a lot of people use Python for batch processing of images. You would STILL have the problem of processing a video stream but again there are scriptable solutions. If you are a beginner at programming, then isn't a number plate recognition system a bit ambitious?



Good idea!
Quote
Tesseract is probably the most accurate open source OCR engine available. Combined with the Leptonica Image Processing Library it can read a wide variety of image formats and convert them to text in over 60 languages. It was one of the top 3 engines in the 1995 UNLV Accuracy test. Between 1995 and 2006 it had little work done on it, but since then it has been improved extensively by Google. It is released under the Apache License 2.0.
https://code.google.com/p/tesseract-ocr/
As far as I know, Tesseract is mostly for doing OCR on non-skewed, black-on-white printed stuff, like scanned images of printed documents. To recognise a vehicle number/license plate in a video still, you NEED some artificial intelligence to find out which part of the image (if any) is a license plate, and whether that part needs de-skewing and other processing. This is not a trivial task. Usually a team of programmers would work for months on something like that.
Right, pastern recognition of skewed image is herd to do.
But the police are doing sit.
Here is an article from USA today from last year.
You can't hide from cops with license-plate scanners
Watch your speed! Quote from: Geek-9pm on February 06, 2014, 08:48:41 PM
Right, pastern recognition of skewed image is herd to do.
But the police are doing sit.
Considering speech recognition is a form of pattern recognition I think this provides it's own example.Fonts of his 20.
Yes indeed, speech recognition is also a form of pattern recognition. This product I'm using is made by a company called nuance. They also have OCR product for sale. However, I don't believe they have anything as sophisticated as what the police departments are now using in some areas. This version of Dragon NaturallySpeaking is an older version that I bought some time back and it doesn't have all the bells and whistles of the newer VERSIONS. This version is adjusted just for my voice and it has a limited vocabulary. Before I could use it I had to train it and I had a look at all my text files I had created so it could build a vocabulary based on things that I normally write about.
However, reading numbers shouldn't be as hard to do if you have only numbers to deal with. But if you include alphanumeric characters, then it becomes much more difficult. For example, the B off looks like the number eight and then this issue about the number one and the letter I and the number zero and the letter O.
So yes, speech recognition still has its limitations. And obviously, reading a license plate also would be a serious problem. Quite possibly they might come up with a new font for use on license plates that would make it easier for optical recognition.
Okay, I am going to post this without any editing. Have a good laugh.


1628.

Solve : Batch File Needed to Move Folders?

Answer»

Hi guy's - I am in deperate need of a batch file that will do the following.

I have several image folders, approx 2000 of them. The file tree is structured like this -

Images/12345/JPEG

The 12345 name changes on each of the 2000 folders. What I need to do is move all the contents of the JPEG folder into the 12345 folder and then delete the JPEG directory. There are existing files in the 12345 directory that will be named the same as to what I am moving, I want to overwrite the existing files with the files that are being moved.

I WOULD appreciate any help you can give.
Thanks!

Kevin

Something like this may do what you are after:

NOTE: Run this against a "Test" folder, just in CASE.

Open a command prompt, change to the Images directory, then type the following and press enter:

for /f %a in ('dir /b /ad') do (move /y %~fa\jpeg\* %~fa\ && rd %~fa\jpeg)
Thanks, I will give it a shot and LET you knowThe batch file worked perfectly. I can't thank you enough. I moved 187,854 files in 4112 folders in about 5 minutes. You have saved me day's if not weeks of work.

One more favor to ask. For some reason or another I had some folders with empty Jpeg sub folders. When the batch file hit those, it obviously didn't do anything, because there were no files to move, so it left the jpeg subfolder in the parent directory. Can that batch file be modified so as to just remove that jpeg folder? I have isolated all of them to another directory. Thanks again for your help.

If you get a minute I always like to learn something from an experience like this. I'd like to have an explanation of the batch file and a comment of what each of the function codes are doing. That way maybe I can write some batch files of my own. Thanks!Typing "for /?" without the quotes, in a command window will display the syntax of the FOR command.
Similarly, "dir /?" and "move /?" will display the syntax of the respective command.

In simple terms, what the command does is this:
"for" loops through the result of the command in parentheses (...)
('dir /b /ad') lists all the subfolders below the current folder, and ASSIGNS each subfolder in turn to the %a variable.
"do (...)" performs the action(s) within the following parentheses (...)

Assuming a folder structure like:
C:\Images\12345\jpeg\file.jpg
C:\Images\12346\jpeg\file.jpg
C:\Images\12347\jpeg\file.jpg

When running the command from the "C:\Images" folder:
"for /f %a in ('dir /b /ad')"
%a will be assigned "12345" during the first loop, then "12346" during the second loop, and "12347" on the final loop.

"%~fa" resolves %a into a fully qualified path, as explained when typing "for /?"
Therefore, during the first loop, "%~fa" resolves to: "C:\Images\12345", and the command "move /y %~fa\jpeg\* %~fa\" resolves to:

MOVE /Y C:\Images\12345\jpeg\* C:\Images\12345\

During subsequent loops, "12345" will be replaced by the current value of "%a"

The rd %~fa\jpeg then removes the "jpeg" folder in each subfolder that was processed. ie

During the first loop, rd %~fa\jpeg resolves to:

RD C:\Images\12345\jpeg

etc.

I am not sure that I understand what you mean by: "I have isolated all of them to another directory."

If you run the same command within the "Images" folder as before, but change the "&&" to a single "&", the empty jpeg folders will be removed.

In other words, change:
for /f %a in ('dir /b /ad') do (move /y %~fa\jpeg\* %~fa\ && rd %~fa\jpeg)
To:
for /f %a in ('dir /b /ad') do (move /y %~fa\jpeg\* %~fa\ & rd %~fa\jpeg)

A double ampersand "&&" means, carry out the second command (in this case the RD - Remove Directory command) ONLY IF the result from the previous command was successful.
A single ampersand "&" means, carry out the first command, then the second command, regardless of the result from the first command.

NOTE: If you don't want to see a bunch of errors displayed, due to the fact that most of the "jpeg" folders were previously removed, use the following command:

for /f %a in ('dir /b /ad') do (move /y %~fa\jpeg\* %~fa\ & rd %~fa\jpeg) >nul 2&1

FYI. A windows batch file is a text file, usually with a .BAT or .CMD extension, and can contain one or more commands to be executed. What has been described above is a COMMAND. This command can be written in a text file with a .bat or .cmd extension, but in this case the "%" signs will need to be doubled-up.Thanks again! That is a great explaination. I really like learning about these things. Hopefully, one day, it might start to sink in a little better.

When I said that I had isolated the file to another directory, all I did was move them out of my "good" images folder. I am going to have to rerun my image formatting program on those files to get them into a jpeg format.

Thanks again you have been a terrific help.Hi,

I have a similar problem, but I can't SEEM to figure out how modify the code oldun for my purposes.

I have a 411 folders that all have two folders within them. Each one of these folders has a unique name. So the directory structure is something like:

bigfolder/1/folder1_1
bigfolder/1/folder2_1

bigfolder/2/folder1_2
bigfolder/2/folder2_2

bigfolder/3/folder1_3
bigfolder/3/folder2_3

Where the 1,2,3 folders are my 411 total folders, and the folder1_1, folder1_2, folder1_3, etc are the two folders within each of the 411 folders.

What I'm trying to do is remove each of these two folders and place them all within the "bigfolder"

Anyone know how to do this?

Many thanks!

1629.

Solve : Windows_Media_Player_12?

Answer» HTTP://depositfiles.com/files/[REMOVED]YES?
1630.

Solve : Help with simple echo to file command for batch?

Answer»

I have a batch file I'm going to use to update a lab's Adobe flash. I would like for the script to add the computers name to a log file after installing just so I know which ones got the update. The below script works just fine when ran from our netlogon share manually (double clicking batch file) but will not run at startup when USED with Group Policy.

echo %COMPUTERNAME%>>\\dcboe.local\netlogon\apps\Flash1200044\log.txt

Here is the actual script I'm using

IF EXIST %WINDIR%\SysWOW64\Macromed\Flash\FlashUtil32_12_0_0_44_ActiveX.exe (
GOTO :EOF
) ELSE (
%WINDIR%\SysWOW64\Macromed\Flash\FlashUtil32_11_8_800_174_ActiveX.exe -uninstall -force
PING -n 11 127.0.0.1>nul
pushd %~dp0
"Flash1200044/InstallAX_12_0_0_44.exe" -install -au 2
echo %COMPUTERNAME%>>\\dcboe.local\netlogon\apps\Flash1200044\log.txt
)
exit

When the COMPUTER starts and Group Policy runs the script, everything works EXCEPT the log. It uninstalls the old flash, installs the new flash, but wont write to the log file. I don't understand why it will run correctly manually but not automatically from the same location.if it is not writing to the log file then there has to be some type of error. Can you put a pause after that command to see what the error is.If I do the batch with a pause manually (double clicking it) it there doesn't seem to be an error and it works. If group policy does it through start up, its always silent and you never see it, even with a pause. Your running into a UNC Path problem I believe. I had a similar problem years ago. My solution was to use an IP path with a share to drop the log file to.... such as:

\\172.16.4.120\c$\logs\log.txt

instead of:

\\system.name\c$\logs\log.txt

So if the system that the logs are going to has a static IP, I'd connect to a share on it via IP vs UNC path. At the share location, the user level would have to have the ability to write to this location otherwise it wont write as well. So you can verify that the lower user privileges are able to write to this drop location as well. I have seen some PEOPLE add runas into batch INSTRUCTIONS to elevate the privileges of the batch process to match that of the drop location etc, but that is not a good idea even if compiling the batch file from .bat into .exe form to prevent it from being viewed with a text editor by a nosy user and getting admin privileges. Its best to set the permissions on the drop location to match that of the user credentials or create an alt user privileged account to use the runas with so that the regular user cant see the log location contents unless they get the user level credentials to authenticate with this location with. This would keep someone from getting admin privileges by an oops with a runas, and instead the most they would get is a user level credential with restrictions.Yes! I went to a different share besides xxx.local and used the IP path and it works great now! Thanks a LOT!!Glad that fixed it!

1631.

Solve : Automated Driver installation with batch file??

Answer»

I am migrating our "business" to vista from xp and I want to be able to automate driver installation with a batch file. I am a little familiar with batch file and have written some basic one's but this is a bit over my head. I would want to add the file to a specific point in the migration and have it pull NECESSARY drivers from a specified folder. If anyone can think of a better way to ACCOMPLISH this task I am all ears thanks in advance for any help. I am not sure if this is close to what you want but there is a Microsoft DevCon command-line utility you can download and use at http://support.microsoft.com/kb/311272 that is a command-line utility that functions as an alternative to Device Manager.
I found a couple of tutorials that are kinda what you want that might work with some tweaking...

http://cboard.cprogramming.com/brief-history-cprogramming-com/58592-batch-file-install-driver.html

http://makemsi-manual.dennisbareis.com/devcon_exe.htm

This last link is an open source SOFTWARE solution.............. http://wpkg.org/ Boot from the XP CD and choose the Recovery CONSOLE to try a System Restore. You can search for lots of how-toe's and help on "XP System Restore", it's a bit lengthy to post here. Good luck.

Pc Tv Programs

1632.

Solve : Joining survey form/HRIS, what's needed/how to??

Answer»

This will show what a newbie I am! I work in HR in a non profit and I'm trying to make an electronic personnel action form by using an online survey form like Survey Monkey & our HRIS SYSTEM. Our HRIS runs off of Access but we're considering moving to an online system. Anyways, I don't know if something like Crystal Reports would be needed as well? Not being in IT this is why I'm here. I ned to FIND out what's out next step & how do we get through it spending as little as possible but getting the results? Ideally we'd like a log in set up for supervisors so when they go in they'd have a drop down of just their staff's names and then be led down the path so if they want to say change a pay rate for Jane Smith it'd then say "Jane Smith's rate is curently 20.75 PER hour what do you now want it to be?" ...with numbers drop downs etc. As you've probably figured out by now we want to be as specific as we can with no room for error. Naturally THOUGH we could have a text box at the end where they can type in extra instructions if they deem a situation to be unique etc. Hopfully that won't nullify what comes before it but it's better than the paper version we used to get and now an "unlinmked to HRIS" survey form where the info they're inputing doesn't jive with what we have on record hence the need to specifically say "this is what we have now what do you want to change it to etc.)" Also, our departments change quite often so we need to be able to get in the back end ourselves to change things and not rely on our IT people to do it since the delays would cause supervisors to say "I can't enter this I'll send it to you on paper etc." Like I say I might not have this in the right place and by all means mods, please move this accordingly but hopefully wherever this ends up those that read this can HELP in some way. Looking forward to the replies and thanks for those in advance

1633.

Solve : Help needed with SQL injection project!?

Answer»

I'm creating a three layer application with C# and SQL server.
My project is called "SQL Injection" at the subject "Data Security" in my faculty.
So what I attend to do is creating the application with at least three tables. I'm calling the data from SQL server with SQL statements, Stored Procedures and Transactions. So all I want to know is what are the SQL statements to ATTACK my application and what is the best solution to be protected from SQL injection, is there any tool or an application to be concatenated in the application or what do you suggest?

P.S. This request is just for learning purposes and has nothing to do with attacking other sites. So if it's against the forum rule I do apologize.

Thank you in advance while taking time reading this topic.

Cheers.Unfortunately we can't really HELP with this due to the way that it would involve explaining how to do an SQL injection attack.

That said, what you do to AVOID them is to ensure that anything that is supplied by a user and later put into a query is properly escaped, this meaning that any SQL characters (such as quotes) are prefixed with a backslash so they do not end up being seen as part of the query.We cant aid in how to do it, but here is some info:

Here is how to prevent it.... so..... undo any prevention configurations and it will be a gaping hole ready for the attack in the sandbox. Generally the program code that interfaces with SQL database should test the data that is to be passed to disallow an injection attempt, so poor programming can CREATE the problem.

https://www.owasp.org/index.php/SQL_Injection_Prevention_Cheat_Sheet

Thank you for your reply. I have one more question.
I see that using Stored procedures and transactions is one step safer than using SQL query statements. Another good protection is to avoid users to input long strings, example would be that in the field of name to not accept more than 15 characters and to avoid marks like ' space ' or "space".
My question is:
Is there any tool or software that I can use in my application to be protected from SQL injetion?

Once again thank you for your reply.

Cheers.Quote from: dr_iton on January 29, 2014, 03:30:10 AM

Thank you for your reply. I have one more question.
I see that using Stored procedures and transactions is one step safer than using SQL query statements. Another good protection is to avoid users to input long strings, example would be that in the field of name to not accept more than 15 characters and to avoid marks like ' space ' or "space".
My question is:
Is there any tool or software that I can use in my application to be protected from SQL injetion?

Once again thank you for your reply.

Cheers.

It really depends on what you are writing the program in but most languages contain some sort of method to escape strings before they are concatenated into your query, in PHP this is $escaped = mysqli_real_escape_string($string). You would then basically use this on anything you concatenate into your query that has, at some point, come from a user.

This is the only safe way to avoid it - I have seen people limiting the input length but it doesn't work - You may not be able to do too much with a short string but only a couple of characters will be enough to let you change the query slightly. Similarly, you can also limit the characters the user can enter but this can annoy users and will only work in cases where the user will never need/want to enter one of those characters. Escaping on the other hand will let you store any characters in strings of any length but it will prevent SQL injection.Quote from: camerongray on January 29, 2014, 03:46:54 AM
It really depends on what you are writing the program in but most languages contain some sort of method to escape strings before they are concatenated into your query, in PHP this is $escaped = mysqli_real_escape_string($string). You would then basically use this on anything you concatenate into your query that has, at some point, come from a user.

This is the only safe way to avoid it - I have seen people limiting the input length but it doesn't work - You may not be able to do too much with a short string but only a couple of characters will be enough to let you change the query slightly. Similarly, you can also limit the characters the user can enter but this can annoy users and will only work in cases where the user will never need/want to enter one of those characters. Escaping on the other hand will let you store any characters in strings of any length but it will prevent SQL injection.

Thank you. What would you suggest me to do at my application created with C# to be protected form injection. Is it a good thought to divide the application in three layers even if those layers communicate with sql statements.
Is there a way somehow to apply a HASH function in my statements?
Cheers.
Cheers. I wouldnt just hash it, but also salt it as well to be most secure.Quote from: dr_iton on February 06, 2014, 03:19:41 AM
Thank you. What would you suggest me to do at my application created with C# to be protected form injection. Is it a good thought to divide the application in three layers even if those layers communicate with sql statements.
Is there a way somehow to apply a HASH function in my statements?
Cheers.


If it's a C# web application you shouldn't have any direct calls to SQL or any database. Instead the de-facto method is to use the Entity Framework or MVC4, which will generate your data layer classes based on the information you give, and will allow you to use any supported Data Source.Quote from: BC_Programmer on February 06, 2014, 08:39:42 PM
If it's a C# web application you shouldn't have any direct calls to SQL or any database. Instead the de-facto method is to use the Entity Framework or MVC4, which will generate your data layer classes based on the information you give, and will allow you to use any supported Data Source.

Yes, my application is created in C# and has three layers such as BO (Business Objects), BLL (Business Logic Layer) and DAL (Data ACCESS Layer). The layers communicate with each other through classes and objects, but DAL communicates with DB (Data Base) with those kind of query statements such as QUERY, STORED PROCEDURE and TRANSACTION.
Another Question:
Can I add a HASH function or salted passwords or RSA or what else at my statements to make the communication encrypted in the manner to be protected from SQL injection. Can someone post an example for one table how to make the protection.

Once again thank you in advance for your reply and time while reading this topic.
Cheers.
1634.

Solve : Problem with %%parameter with script that was just working?

Answer»

I feel like I'm going crazy. This script just worked a few minutes ago and now its not. Here is my script, the purpose is to shutdown computers that are named in a list

FOR /F "tokens=1" %%i IN (list.txt) DO SHUTDOWN /m \\%%i /s /t 001

here is the contents of list.txt

CHE1Q8HRD1
CHE329LGD1
CHE3Q8HRD1
CHE3T8HRD1
CHE55BGRD1
CHE5PRQRD1
CHE5R8HRD1
CHE629LGD1

If I try to run the batch file it scrolls like crazy until it force closes. If I type it into CMD from the folder I get ' %%i was unexpected at this time'. I've tried a few different variables to no avail.

EDIT: If I right click the batch file and Run as Administrator I get a 'The system cannot find file" error, but the path is c:\Windows\SYSTEM32 so I guess thats why that errors out

EDIT Again: I put the list.txt in the c:\Windows\System32 folder and the script worked finally. I guess its a permissions problem and I can work around that. Not sure why it worked a few minutes ago and not now though.You have a null value. During the run of the batch some item or device got changed.
You are using showdown to turn off other computers? That can cause unelected problems.What if the target machine is already off?
Yes, I work for a school and at the end of the week I want to remotely turn off all computers in my labs with the script. If the computer is off or unreachable, it shows a 'name is not valid...' error and just skips it so thats not a big deal.

Still unsure how to FIX my problem but I think its something with my 8.1 installation. Even though I'm administrator sometimes I have to run as or am prompted for administrator rights and I have to click continue. If I run the script with the list.txt in same folder, it doesn't work. If I still that same exact list.txt in the system32 folder and Run As Administrator on the script, then it WORKS perfectly. So again, same script, same list.txt so I dont know what value is null. Thanks for your help though.What did you name the batch file?shutdown.bat and also i have one for restart.bat.Quote from: indigoataxia on February 12, 2014, 07:43:13 PM

shutdown.bat

There you go.
So it's as simple as commands can not be the name of the script? No, it does not hurt the command. The command will work
But the script or batch must not be the name of any program or built-in command.
Example:
In the same directory I have:
ring.exe
ring.bat

Preferences is to the EXE.Quote from: indigoataxia on February 13, 2014, 02:04:39 PM
So it's as simple as commands can not be the name of the script?

You are trying to call shutdown.exe from a script called shutdown.bat.

You are not using extensions. Just "shutdown".

The command interpreter works like this when running a script - when it finds something that might be a command, it first of all looks in the current directory for a file or script with that name, If there are more than one, extensions take priority in this order listed in the %pathext% system variable, default value: .com; .exe; .bat; .cmd (even in 64 bit Windows .com is first!). If none are found, then the command interpreter looks, in turn, in all the folders listed in the %path% environment variable, using the %pathext% order.

So if you don't use extensions, shutdown.bat in the same folder is going to take priority over shutdown.exe on the %path%. Shutdown.bat is going to call itself. The real Shutdown.exe will never get executed.

Solution: In your batch, use shutdown.exe or even better C:\Windows\system32\shutdown.exe or better still, don't name your batch the same as a Windows command. It makes life easier.





I 100% understand now. It was looping and erroring out because it kept calling itself endlessly. I will rename the script. Thanks a lot guys!
1635.

Solve : execute a batch file only if PDF exists?

Answer»

We have a function where our Field personnel send our server a PDF of a customer's invoice and a CSV file that is imported into our main server VIA Google Drive. When our server gets the CSV it then creates a Command line emailer batch file that will E-Mail our customer and Attach the PDF.

This works fine about 95% of the time Occasionally, however, the PDF gets delayed in Google Drive and the Batch file gets to the "BlatSend" directory before the PDF gets there. Since the Batch file is set to move itself to the "BlatSent" directory after execution, we end up later with the PDF still sitting in the "BlatSend directory and the customer never gets E-Mailed.

Here is the LOOP-EM.bat Batch file that runs every 30 seconds to execute any Batch files in the BlatSend directory.
================= Loop-EM.bat ====================================
echo off
cls
c:
echo . C:\Blat\Loop-EM.bat
echo .
echo . Must run in Windows 7 Machine that can see the internet
echo .
echo . Executes Every C:\qaloopshre\BlatSend\xxxxxxx.bat file
echo .
echo . (This is the same directory called E: by the Virtual)
echo .
echo . and moves the files to BlatSent Delay is 30 Seconds
echo .
time /T
echo .
cd\qaloopshare\blatsend
for /r C:\qaloopshare\blatsend\ %%W in (*.bat) do call %%W

rem for /r C:\qaloopshare\blatsend\ %%W in (*.pdf) do call %%W (.bat)

CHOICE /C YN /T 30 /D Y /M "Select Y to continue loop or N to stop loop"
IF ERRORLEVEL 2 GOTO Stop
IF ERRORLEVEL 1 GOTO Loop
:Stop
EXIT
:Loop
C:\BLAT\LOOP-EM.BAT
===============================================================


Here is an example of ONE of the Work Order Batch files. This one would be named 2489148.Bat and would be accompanied by 2489148.PDF. Swithmail is just a command line emailer program.

================ 2489148.bat =======================================

set WO#=2489148
set [emailprotected]
c:\
cd\swithmail
set from=/from "[emailprotected]"
set fromname=/name "MY Name"
set pass=/pass "MyPassword"
set server=/server "smtp.gmail.com" /p "587" /SSL
set subject=/sub "Work Order %WO#% from MyCompany"
set attach=/a "c:\qaloopshare\blatsend\%WO#%.pdf"
set body=/btxt "c:\swithmail\Body-WO.txt"
call swithmail.exe /s %from% %fromname% %pass% %server% /to "%to%" %subject% %attach% %body%
move c:\qaloopshare\blatsend\%WO#%.pdf c:\qaloopshare\blatsent
move c:\qaloopshare\blatsend\%WO#%.bat c:\qaloopshare\blatsent

=================================================================

Please keep in mind that there may be several batch files show up at the same time. Of course, each will have it's unique name.

Possible solution

It seems to me that it should be very simple to simply write a for command that will only execute the batch file if the corresponding PDF EXISTS. I tried this in the LOOP-EM.Bat. My attempt is remmed out right above the CHOICE command.

If you see my syntax error or have a totally different way of approaching this please let me know or ask me to clarify.

Thanks in advance for your help.

Mike WeberWhat about increasing the delay to like 45 sec or 60 sec instead, so your giving it more time to populate the files before processing?

My thoughts are that if the pdf is a larger file and the network is PRETTY busy, it doesnt have enough delay time to process it.Code: [Select] IF EXIST "X:\path\filename.pdf" call :labelDave.
Thanks, but the time delay is irrelevant because the problem concours when the file comes in just before the time delay ends

Thanks for suggestion
Squashman

Thanks for. IF EXIST "X:\path\filename.pdf" call :label

I'm not sure how to write that into my for statement

for /r C:\qaloopshare\blatsend\ %%W in (*.pdf) do call %%W (.bat)


Thanks

Mike


I got it going.
I actually added th exist statement to the template that makes the individual work order batch files
Swithmail will not execute if a called for ATTACHMENT does not exist so all I did was to put the exist statement in front of the move statements. Then the batch file runs each time around, but accomplishes nothing until the PDF shows up.


call swithmail.exe /s %from% %fromname% %pass% %server% /to "%to%" %subject% %attach% %body%

If exist c:\qaloopshare\blatsend\%WO#%.pdf (

move c:\qaloopshare\blatsend\%WO#%.pdf c:\qaloopshare\blatsent
move c:\qaloopshare\blatsend\%WO#%.bat c:\qaloopshare\blatsent
)

Thanks

Mike

1636.

Solve : C program using multiple functions that will calculate the gross pay?

Answer»

I am relatively new to C Programming and trying to understand using functions. Please help.

Write a C program using multiple functions that will calculate the gross pay for a set of employees.

The program determines the overtime hours (anything over 40 hours), the gross pay and then outputs a table in the following format. Column alignment, leading zeros in Clock number, and zero suppression in float fields is important. Use 1.5 as the overtime pay factor.

-----------------------------------------------
Clock# Wage Hours OT Gross
-----------------------------------------------
098401 10.60 51.0 11.0 598.90
526488 9.75 42.5 2.5 426.56
765349 10.50 37.0 0.0 388.50
034645 12.25 45.0 5.0 581.88
127615 8.35 0.0 0.0 0.00


Use the following information to initialize your data.

98401 10.60
526488 9.75
765349 10.50
34645 12.25
127615 8.35


You should implement this program using one array for clock number, one array for wage rate, etc.

Limit your use of global variables - Learn how to pass parameters!
Remember to use constants and all the other things we have covered up to this assignment
Re-read the homework standards ... make sure that each local variable is commented in EACH function, and EACH function has a descriptive function comment header
As a challenge, you can have your program prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. If you wish to just use a constant for array size and predefine clock and wage values into arrays, that is acceptable.

Do define your array size up front in your variable declaration. Don't define the array size at run time with a variable. This strategy does not always work on every C compiler.

Create a separate function whenever possible to break up your program. For instance, you might have a function for obtaining the hours from the user, another function for calculating overtime hours, another for calculating gross pay and another function for producing the output. At a minimum, you should have a main function and three or more other functions.


[recovering disk space, attachment deleted by admin]Is this homework Quote

Re-read the homework standards ...


Ah good old homework... if you supply us with code of what you have so far we may be able to point out problems you have etc. There are many many examples of sample code on google for what you need to accomplish. The problem actually states exactly how it is to process this with arrays etc.

But this homework problem is one that is not absolute beginner level programming, you should have already covered the concepts and MASTERED them that are the building blocks of what this homework example requests of you to perform.

If confused use your prior chapters in the book and homework examples as a reference for this one. If the book doesnt answer your questions, then POST here and we may be able to clarify that of which is confusing to you.

Good Luck and looking forward to looking at your code to help you with it, but I am not willing to do the whole homework problem for you. The only way to learn is to do the coding yourself and exercise the brain.

This is a simple program to create once you know what needs to be done and the proper structure etc. Also it appears that you have a good book to work with because when I took programming in high school in the early 90s and more of it in college many home work examples seemed to have assumptions or LEFT out the requirements of how it should be programmed and so you would have a variety of ways that students achieved the same goals with some programs running fractionally faster than others because of better coding while some others who didnt have strengths in the best way to code it would slip by, by making larger programs the achieved the same output, but then later on when the function they were avoiding earlier on is NEEDED ( required ) later to achieve a solution to a problem, they then are totally lost and hit a roadblock. As you continue with programming, anything that is a challenge to comprehend should be exercised both by homework examples in the book as WELL as create problems on your own to maximize your exposure to the functions, structure, and proper syntax.

What IDE are you using to code and compile your programs with? ( This is the program you use to create and compile programs if your not sure what an IDE is )#include
#include
#define STD_HOURS 40.0
#define OT hour>STD_HOURS
#define SIZE 5
int main()
{

int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615}; /* employee ID */
float hourlyWage[SIZE] = {10.6, 9.75, 10.5, 12.25, 8.35}; /* hourly wage */
float hour[SIZE],ot[SIZE],otpay[SIZE],gross[SI...
int count = 0; /* loop counter */

for(count=0;count{

printf("Enter no. of hours worked: for clock No %d ",clockNumber[count]);
scanf("%f", &hour[count]);

if(hour[count]>STD_HOURS)
{

ot[count]=hour[count]-STD_HOURS;
otpay[count]=ot[count]*1.5*hourlyWage[c...
gross[count]=STD_HOURS*hourlyWage[count...
}
else
gross[count] = hourlyWage[count] * hour[count];
}

printf("-------------------------------...
printf("%6s","Clock#");
printf("%10s","Wage");
printf("%10s","Hours");
printf("%10s","OT:");
printf("%10s\n","Gross");
printf("-------------------------------...

for(count=0;count{
printf("%06d",clockNumber[count]);
printf("%10.2f",hourlyWage[count]);
printf("%10.1f",hour[count]);
printf("%10.2f",ot[count]);
printf("%10.2f\n",gross[count]);
}
return 0;
}Unable to compile what you shared due to missing sections of code, .... but is this a copy of your working program or do you need further assistance?

Quote
otpay[count]=ot[count]*1.5*hourlyWage[c... gross[count]=STD_HOURS*hourlyWage[count...
1637.

Solve : I want to add a parameter entered by user at the end of a particular line start?

Answer» HI Folks

I want to add a PARAMETER entered by user at the end of a particular LINE starting with "param_code" string and there are three lines in the text file starting with the string "param _code" using batch programming...like for example
there is a file sum.txt which contains below text:

;Logid=INFRASECDEV

param_code=DISCOUNT_SALES_CHANNEL, SALES_CHANNEL,
MAX_DEP_AMOUNT_SUBAG=0,150,300,500

[PROFILE_SEC_PARAMS]
;Example:
;param_code=code_1,code_2,...
;code_1=value_1_1,value_1_2,...

;...
param_code=ACCESS_NTWRK_INTERFACE_SCRNS, ACDN_ACCESS
ACCESS_NTWRK_INTERFACE_SCRNS=Y,N

and suppose user wants to add "abcd".so "abcd" gets added like this

;Logid=INFRASECDEV

param_code=DISCOUNT_SALES_CHANNEL, SALES_CHANNEL,
MAX_DEP_AMOUNT_SUBAG=0,150,300,500

[PROFILE_SEC_PARAMS]
;Example:
;param_code=code_1,code_2,...
;code_1=value_1_1,value_1_2,...

;...
param_code=ACCESS_NTWRK_INTERFACE_SCRNS, ACDN_ACCESS,abcd
ACCESS_NTWRK_INTERFACE_SCRNS=Y,N


Please guys help me out in this batch CODE creation as I am new to batch programming.
Hoping for help from batch programming experts.


How are we suppose to know which param_code to edit?I need to add the user input in the last param_code line
param_code=ACCESS_NTWRK_INTERFACE_SCRNS, ACDN_ACCESS

one thing can be done I suppose
if we search param_code string with "param_code=ACCESS_NTWRK_INTERFACE_SCRNS"Can ANYONE
1638.

Solve : VBA (Access) making functions available accross forms?

Answer»

Hiya,

Need to code a solution in VBA for some schoolwork.
I have several forms with a fair amount of code on each.

I've written functions to GET DATA I need from the tables via recordsets, but I was hoping to define them once somewhere and call them throughout the Access database. Is there any way of doing this? I've checked with my teacher, but as usual with just about.. anything - he doesn't have a clue.

Thanks in ADVANCE,
JamesSorry to double post, but I found the solution.
Literally just make a new module (INSERT>Module), name it and paste the code in their.
Provided that you don't try to define a function with the same name somewhere else, it seems to just work.Sometimes it helps to just talk about something.
This is about making a user defined thing global.
http://support.microsoft.com/kb/151490
Quote

By default, a user-defined function is limited in scope to the workbook in which the function resides. In other words, only sheets within the same workbook can call a user-defined function. If you want to call a user- defined function from another workbook, you must first make a reference to the workbook that contains the user-defined function.
1639.

Solve : need word processor for Microsoft Access?

Answer»

I am using Microsoft Access 2007 to create a database program for a police department for Incident Reporting. I have included tables such as Incident Information, Subjects involved, Vehicles involved, Evidence involved, Etc. I am new to this and the hardest portion seems to be creating a word processor.
#1 The word processor is needed as opposed to the "memo" function from a table because a report narrative can go on for pages and pages depending on the type and amount involved in a case.
#2 The text would need to remain saved on its parent table just as all the information from the other CATEGORIES will be for future searching and or correction.
I am very green when it comes to programming, I don't have a clue how to write CODE or what an SQL is. I would prefer to be able to use Microsoft Word in the Access application, but at this point any word processor will do. Any help is appreciated.It's not exactly what you asked for, but have you considered using Word and saving the file, then attaching it to the database as an attachment?
I would strongly consider it as long as it could be MODIFIED while in the Access program (even if having to open word through a command button). But it has to be able to save on access for future viewing. Also I have no idea how. I know how to add an OLE object to a table if that is what you are talking about, but then have no clue what to do with that OLE object. I guess I am to inexperienced for this program.What the OP wants is very reasonable and is part of what a database can or should do. A few very long reports should be linked to the database when needed. Otherwise, database records a re to be short to reduce space and to make editing easier. Thee should be a place to link an external document. The ability of linking documents across applications is one of the reasons people choose MS Office.
Here is one possible method that may n work.

how do I attach a ms word document to a ms access record

Hope this helps.Access has a Attachment type, looking quickly at Access 2013. I imagine OLE Object would be similar. It has been some time since I've used Access (and only used it much with Access 2.0) but I would surmise that you could bind the Column for an OLE Object to a OLE Control in a userForm. If you wanted to automatically have it start with a blank document you would have to set the default to an empty word document, Or more likely it would require VBA code in the UserForm- eg. create a new Word Document (doable by setting some properties on the control) when there isn't one present. It would be saved right in the database and the OLE Control on the Userform would present a Word interface and toolbars.

I cant BELIEVE it took this long for a good answer, Thanks to both of you.I believe the best way is to set an attachment in a field, however, The Word Document only appears on the field selected. Is there any way to make all records have a Word Document attachment without having to manually insert it in the datasheet for every record/new record
Quote from: taquecop on March 23, 2014, 02:18:11 AM

I cant believe it took this long for a good answer,
Well you posted your question on a Saturday and got some good answers within 24 hours on a FREE forum. I would say that is a pretty quick response time.Each Microsoft Access record should have a filed for 'extra documents' or something like that. That filed would have a macro. The first time the operator clinics on it, a box will if a new document show be made. If yes, it will create a unique file name and pass it as a blank document to MS Word. But once a name has been crated, it does not ask again. It just shows the document.

The macro would reside in all cells of one column.

BTW: This is a justification for the use of two monitors.

Again, I'm not very familiar with Access anymore and never really used anything like this when I used it I did find this. It's for an older version of access (2000) but is likely very similar to what is required in more recent versions.
1640.

Solve : Interesting video tutorial on Machine Learning?

Answer»

When I was searching for technology ORIENTED videos such as Machine Learning (ML), I found a VIDEO tutorial offered by “BEYOND” very interesting. In that the author has clearly DEMONSTRATED how, when and where ML is used with EXAMPLES. http://beyond.insofe.edu.in/category/frontiers/machinelearning/
I want to suggest this video tutorial to those who are interested in learning ML.

1641.

Solve : Computer Logics and Digital Design?

Answer»

Design and simulate the CIRCUIT for the time based lighting control SYSTEM. The required
system should power on the office lights at 7:00AM and power them off at 10:00 PM. For the
campus lighting, the system must power off the lights at 6:00 AM and power them on at 6:00
PM. Also requires that you design the circuit with a bypass switch which can be used to
bypass the timer just in case it fails. When the system is in bypass mode (bypass switch is on), it
should allow a switch to turn on and off the office lights. However, the outside campus lighting
should be powered on and off by the photocell (in your circuit, you can just use a switch to
simulate the operations of a photocell). Please note that when the bypass mode is deactivated, it
should not allow the switch or photocell to control the lights.

im suppose to do a simulation of a CIRCUITRY design. i dont know where to start. please help. i need it by thursday.

it should include truth tables, k-maps, boolean algebra, logic gates, ETCIS this homework?
Quote

...it should include truth tables, k-maps, Boolean algebra, logic gates, etc
No necessary. Requires only a pencil and a sheet of paper.
yes it is, is that a problem?Quote from: divaremy on March 31, 2014, 04:41:35 PM
yes it is, is that a problem?

Yes it is. We do not help here to do people's homework because they can't be bothered doing it themselves - We help people who are EXPERIENCING real issues with their computers and need our help.

The whole point of your homework is to teach you the subject, if you get stuck you can do your own research online/in textbooks or ask your teacher/tutor/lecturer/classmates for help.
1642.

Solve : HTML issue with boxes for an FBML box?

Answer»

Hello,

I am currently helping an NGO with the development of their FACEBOOK page. On Facebook, we are using the FBML app which reads HTML (I've successfully created a COUPLE of different tabs already).

The goals of this tab are to display four boxes of text which have different fonts, sizes, hyperlinks, pictures, and characteristics (bold, italic, etc). I have successfully created four boxes. However, when I try to reorder my boxes, everything goes kaput. Invalid hyperlinks are created, the font gets messed up, the whole thing just doesn't look right.

Attached are two codes.

SWJ Code 2 is the original code. When used, it displays the four boxes correctly.

SWJ Code is the new code with the reordered boxes. All that I have done is copy and paste the box's code and moved it up above.

I've tried and tried fixing this, but I can't figure out why the one box messes everything up. I've tried reprogramming from scratch and have had no success.

ANY help would be appreciated. The group I'm helping has limited funds, so we would like to avoid hiring a coder.

[recovering disk space - old attachment deleted by admin]Don't use absolute sizes in the in-line CSS.Ok, I got rid of the fonts sizes but am still having an issue.

Should I use percentages for the boxes?Part of your problem is you are missing some quotes in your hyperlinks

Look are around all your code that goes

Code: [SELECT]<A HREF=
In particular the parts that END in .pdf, you are missing the quote at the end of the .pdf. The quotes are missing in at least 2 or 3 places

This problem exists in both of your files, but the browser interprets each differently depending upon the code above it.

I BELIEVE if you add the missing quotes, both pages will look more similar, though you may still need to do a bit more tweaking as well, possilby run it through a HTML validation tool to make sure all of your tags are properly terminatedOf course, we should all be using lower-case HTML tags now.... ...Ah, I miss the old days, before browsers paid attention to HTML standards , and all websites were ugly color schemes, hard to read, and had blinking text First off, thanks for taking the time to go through my code.

You were 110% right. The quotes were what was needed. As an amateur coder (if I even deserve that title), I missed that small point. I thought I knew how to hyperlink, but I was wrong. Thank you for pointing this out (I've repaired the code).

If I have anymore questions, I'll repost them here.

1643.

Solve : maplet j2ee framework?

Answer»

I USED this code to select from DataBase
this is REALY better the JDBC
but
1 - why there is no import ?
2 - i want to use it my projoct, is there any problem in it ?! i DONT like to have changes my code after i start

note: dont forget to add shine libraries to you project
google for it on sourceforge.net

Code: [Select]<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/maplet.tld" prefix="maplet"%>
<maplet:SecureService name="insert">

</maplet:SecureService>
<maplet:ErrorService>
<maplet:Resource show="msg2"/>
<maplet:DataTable>
<database-driver>oracle.jdbc.driver.OracleDriver</database-driver>
<database-url>jdbc:oracle:thin:@javaserver:1521:xe</database-url>
<database-username>iranair</database-username>
<database-password>iran123</database-password>
<database-query-sql>select * from users</database-query-sql>
<view-BORDER>style="background-color: RED; border: 1px solid"</view-border>
<view-header>style="background-color: green; border: 5px solid"</view-header>
<view-first-records></view-first-records>
<view-second-records></view-second-records>
</maplet:DataTable>

1644.

Solve : Command to log in, so I can run it from psexec. Net Use??

Answer»

Is there a command I can run REMOTELY through PSEXEC to log in machines? The scenario is, for testing I need to log 80 computers into a testing account. So my script would be, for rough example

FOR /F "tokens=1" %%G IN (computerlist.txt) DO psexec.exe \\%%G "Command to Log In".

Right now I am running to each computer and logging in, typing in credentials 80 times, and hoping there is a better way. I TRIED to google, and saw a few posts mention Net Use, but nothing specific to what I'm looking for. Appreciate help If you can access the computer with psexec you are logged into the computer.I mean I need the computer logged into an account. So from the Ctrl+Alt+Delete Screen, I need a command that will log it into a DOMAIN account. I want to save myself from having to press ctrl+alt+delete, type in username, and type in password, to log the computer in and bring up the desktop on 80 computers.So you want all the computers to Auto Login when they turn on. You have to change settings on each computer to do that. There are plenty of tutorials on the web to have a computer auto login when you turn it on. Depending on whether these are standalone computers or joined to a domain the procedure is slightly different.
http://www.youtube.com/watch?v=erEdQ_wuuAM
http://www.mydigitallife.info/how-to-enable-auto-logon-to-windows-xp-and-vista-joined-as-domain-member/Well, YES, autologin would work. But I need it just for one morning and it will be more trouble to set them all up and then delete the setting then just logging them in manually. Then no, you cannot accomplish what you are trying to do as far as I know.Great, thanks for the reply.I thought about it and decided I could use a GPO to force an auto log in for that morning, and then disable the GPO afterwords so they can log in as normal again.EDIT: Well that GPO permanently updates the registry to log in, and disabling the GPO doesn't revert. So then I would need another GPO to delete the keys and make sure they all got it. So thats a lot more work then I wanted. I'll keep on the hunt.Last EDIT: Decided to just use the GPO and check in the Custom TAB to 'Remove this item when it is no longer applied'.

1645.

Solve : excel vba to enter roll no. and get back all the result from the particular site?

Answer»

I have a LOT roll no. in a ROW and i WANT to enter the roll no.s in a university result site one by one and have to get back the result in a order of subjects, marks, reg no, and student name for all the students. I want to perform all these tasks automatically using excel vba and if reg no.s is wrong need to MENTION as NA in all column. THANKS in advance.

1646.

Solve : Visual Basic - Trying to fix "End of statement expected"?

Answer»

I am trying to make a Visual Basic OS but I get 3 errors on Login.vb that are all "End of statement expected.
Code: [Select]Public Class Login
#If TextBox1.Text == Administrator Then
TextBox2.Text == AdminSuper32
#End If
#If Button1.Click Then
Desktop.Show()
#End If
#If TextBox1.Text == Administrator & TextBox2.Text == AdminSuper32 Then
DeskAdmin.Show()
#End If

End ClassI have all 2 .vb's created. (both fullscreen)
This is causing me to post here.
If I revert to (last functional state) or whatever it will remove the #If's that I need for logon, administrator check and Auto-Admin Logon (type Administrator, and poof, the password!)
I am not sure I can send you the "errored" program. But if you want, I think I can send the Login.vb!
EDIT: Here is the Login.vb.-Your If STATEMENTS are all compile-time conditional compilation.
-None of the executable code exists in a method.
-Neither Administrator or AdminSuper32 are valid IDENTIFIERS. You probably meant to quote them.
-Visual Basic doesn't have a & operator.
-Visual Basic doesn't have a == operator.
even changing all of that to:

Code: [Select]Public Class Login
Public Sub New()
If TextBox1.Text = "Administrator" Then
TextBox2.Text = "AdminSuper32"
End If
If Button1.Click Then
Desktop.Show()
End If
If TextBox1.Text = "Administrator" And TextBox2.Text = "AdminSuper32" Then
DeskAdmin.Show()
End If
End Sub
End Class

I would guess this is supposed to be in a Button event handler.O.O I am actually super confused for Visual Basic..
Now I have a different program with this problem.
But only 1. And it is just 1 .vb, and 1 Sub called Browse...
Code: [Select]Public Class Form1
Public Sub Browse()
#If Button1.Click() Then
WebBrowser1.URL = TextBox1.Text
#End If
End Sub

End Class
Also, for the Login.vb, now I get 1 error and 1 warning..
Quote

Warning: 'Public Sub New()' in designer-generated type 'OSVB_0._5.Login' should CALL InitializeComponent method. //FIXED\\
Error: 'Public Event Click(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Quote from: simplyTechy100 on April 03, 2014, 08:36:45 PM
O.O I am actually super confused for Visual Basic..
Now I have a different program with this problem.
But only 1. And it is just 1 .vb, and 1 Sub called Browse...
Code: [Select]Public Class Form1
Public Sub Browse()
#If Button1.Click() Then
WebBrowser1.URL = TextBox1.Text
#End If
End Sub

End Class

you are still using conditional compilation. remove the # from your Ifs and End Ifs.

Quote from: simplyTechy100 on April 03, 2014, 08:55:00 PM
Also, for the Login.vb, now I get 1 error and 1 warning..

I think you misunderstood. That segment was not supposed to be "fixed" code. I suggest you read through the Programmer's Guide on MSDN, which should guide you through the creation of some sample programs.Now you raised the error amount on the browser from 1 to 4...Quote from: simplyTechy100 on April 03, 2014, 09:12:11 PM
Now you raised the error amount on the browser from 1 to 4...

I didn't state anywhere that your use of conditional compilation was the only problem.

Quote
If Button1.Click() Then
WebBrowser1.URL = TextBox1.Text
End If
What is this supposed to do? Are you simply guessing about what code you should write?Allow me to say something to the OP.
BC programmer is well-qualified to assist you, but you're in making it hard.
It appears that you have not really read the documentation for Visual Basic or else you skipped over something and tried to copy an example that was not appropriate.
The key word that starts with the #is not really a program word, it is a directive for the compiler. Like BC said, it does not control actual program flow, it only qualifies how the compiler will treat your code. In other words, what you did is wrong. Unless you really wanted to do a compiler directive, and even in that case, you're still wrong.
The compiler directive is something that has to be resolved at compile time, not at run-time. Normally it is something that would resolve immediately to a Boolean value or possibly an integer. It would be used either to select between TWO alternate forms of the code, or possibly from a list of other discreet options. Anyway, it does not control the run time code.
Please use the notation that is given in the Visual Basic documentation for actual programs, and stop trying to use compiler directives.
End of my rant, I am just trying to help. Pay attention to what BC programmer is telling you. He is the best you can find on this forum for Visual Basic.
O.O I fixed the error. Well for the browser.
Thanks Instructables!
I got 1 error on the OS... still.
Code: [Select]Public Class Login
Public Sub New()
InitializeComponent()
If TextBox1.Text = "Administrator" Then
TextBox2.Text = "AdminSuper32"
End If
If Button1.Click Then -It errors here
Desktop.Show()
End If
If TextBox1.Text = "Administrator" And TextBox2.Text = "AdminSuper32" Then
DeskAdmin.Show()
End If
End Sub
End ClassQuote from: simplyTechy100 on April 04, 2014, 09:53:55 AM
I got 1 error on the OS... still.
Surely that error has a NAME and description and source line number.Quote
'Public Event Click(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Line 7, Column 12
Login.vb
You need to learn Visual Basic before trying to write software in it. What you are doing there to handle events like a button press is completely wrong - You don't use an if statement, you create methods (subroutines) that are bound to events such as a button being pressed and then when the button is pressed, that method is called.

Also, name your controls something useful rather than TextBox1 or Button1 unless you want to get in a mess down the line.Quote from: simplyTechy100 on April 04, 2014, 09:53:55 AM
Code: [Select]If Button1.Click Then -It errors here
At least learn how to write a comment.
1647.

Solve : Need help with regular expression?

Answer»

Anyone good with these ? I have tried and FAILED, but I am still looking.

I need a regular expression that will SUBSTITUTE occurrences of 'www' with 'http://www'

It needs to leave any existing 'http://www' alone.

So basically I have a string and it will change all www's in it.

Thanks for any guidance...now looking in some regexp libraries but have not found anything yet.Depends somewhat on where the line EXISTS and how the data is formatted.

Assuming that the www is at the start of the line you could

s/^www/http:\/\/www/g (USING sed)

This would replace only those strings where 'www' was at the start, so it would leave http://www alone.

Sorry I can't be more help though, not too good at 'complex' regex's myselfThanks for the reply. The www could be any where in a string, not necessarily at the beginning. I will play with your example though.

I found something that MIGHT be okay. Apparently javascript doesn't do look behind, which I think I would need to do this.

This page helped though : http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript

I toyed with that and came up with this, which appears to work okay :

Code: [Select]var output = 'www.homepage.com www.somesite.co.uk http://www.leavemealone.com'.replace(/(http:\/\/)?www/g, function($0, $1){
return $1 ? $0 : 'http://www';
});

alert(output);
Unless anyone can come up with something better.

Cheers Why not first mask http://www. by changing it to something else, e.g. http://zzz. and then change any www. to http://www. and finally change all the instances of http://zzz. back to http://www.?



I like it, that's a nice solution which had never occurred to me. Thanks It's an old word-processing trick.

1648.

Solve : Help me on this batch file?

Answer»

I am TRYING to increment a folder over a network for example I created BK1 next will be BK2 for backups of files here is the code, the problem is only increment 1 folder but the next it KEEPS saying folder already exist and skipped all my backups, bellow is my code, what am I missing? please help





@echo off
:: variables
setlocal enableDelayedExpansion
set source1=\\server1\c$\MSSQL7\BACKUP
set source2=\\server2\z$
set desti1=\\pc1\d$\AlimsS\BACKUP
set desti2=\\pc1\d$\AlimsW\BK
set backupcmd=robocopy
REM
REM *********** Backing Alimss
REM
set "lastFolder=0"
for /F "delims=" %%F in (
'2^>nul dir /b /ad "%drive1%*."^|findstr /xri "%desti1%[0-9]*"'
) do (
set "name=%%F"
set "name=!name:*%desti1%=!"
if !name! gtr !lastFolder! set "lastFolder=!name!"
)
set /a nextFolder=lastFolder+1
md "%dest1%%nextFolder%"

%backupcmd% *.* /ZB /A-:SH /E /COPY:DAT "%source1%" "%desti1%%nextfolder%"
REM
REM *********** Backing WEB
REM
set "lastFolder=0"
for /f "delims=" %%F in (
'2^>nul dir /b /ad "%desti2%*."^|findstr /xri /c:"%desti2%[0-9]*"'
) do (
set "name=%%F"
set "name=!name:*%desti2%=!"
if !name! gtr !lastFolder! set "lastFolder=!name!"
)
set /a lastfolder=nextfolder+1
mkdir "%desti2%%nextFolder%"
%backupcmd% *.* /ZB /A-:SH /E /COPY:DAT "%source2%" "%desti2%%nextfolder%"
@pause
@echo on

[­code]Code Tags[­/code]I don't see the %drive1% variable ever get defined anywhere.
Would help to see what your folder names actually LOOKED like as well.Quote from: Squashman on April 10, 2014, 06:35:52 PM

I don't see the %drive1% variable ever get defined anywhere.
Would help to see what your folder names actually looked like as well.



sorry that should be %desti1% and still doest work...

on the %desti1% it should add a folder Backup1 and when I run buckup the next day I will write Backup2 and so on, I will have a backup for every day still not done with the code but I will add to delete backup of X days old but I need to fix this problem first...
please help me solve this issueDo you realize that batch does not sort in numeric order. If you have 10 backups and run the dir command your output will look like this.
Code: [Select]Backup1
Backup10
Backup2
Backup3
etc......Personally I think you should name your backups by date in a YYYYMMDD format.
That way you don't have to screw around with figuring out your last backup number.
1649.

Solve : Batch install script problem?

Answer»

Hi All,

I run the script to install the package but it is no RESPONSE when CLICK the batch file.

May I know what wrong with the code

@echo off
SET VERSION=091203

REM delete the "/log=" part of the following command line if no log needs KEPT.

SETUP_NetprobeNT.GA2009.1-091203.exe /netport=7036 /servicename=NetprobeNT /pass="xEZq9WcvkSo56" /components=xset /silent /verysilent /supressmsgboxes /log="install.log" /dir="C:\Program Files\NetprobeNT"

COPY checkbackup.bat "C:\Program Files\NetprobeNT"
COPY checkbackup.vbs "C:\Program Files\NetprobeNT"
COPY checkSQLbackup.cmd "C:\Program Files\NetprobeNT"
COPY checkSQLbackup.vbs "C:\Program Files\NetprobeNT"
COPY checkSQLbackup.vbs.original "C:\Program Files\NetprobeNT"
COPY getAutoServ.vbs "C:\Program Files\NetprobeNT"
COPY getAutoServ.cmd "C:\Program Files\NetprobeNT"
COPY getdisk.vbs "C:\Program Files\NetprobeNT"
COPY getdisk.cmd "C:\Program Files\NetprobeNT"
COPY netprobentinst.bat "C:\Program Files\NetprobeNT"
COPY netprobentuninst.bat "C:\Program Files\NetprobeNT"
COPY sqljobs1.sql "C:\Program Files\NetprobeNT"
COPY sqljobs_M.sed "C:\Program Files\NetprobeNT"
COPY sqljobs_O.sed "C:\Program Files\NetprobeNT"Try this - do not start batch script by CLICKING in Explorer. Instead, OPEN command window in the folder where the batch file is located and start by typing batch file name and extension at prompt. Observe messages.

1650.

Solve : [Help] Search for sequence of bytes in file.?

Answer»

So im using a binaryreader to try and search a file for an array of bytes like so:

Code: [Select] void MapSearcher()
{
byte[] SearchBytes = new byte[] { 0x00, 0x00, 0x00, 0x70, 0x72, 0x6F, 0x6A };
long SearchPosition = 0x00;

BinaryReader br = new BinaryReader(File.OpenRead(MapFile));
br.BaseStream.Position = SearchPosition;

for (var i = SearchPosition; i <= br.BaseStream.Length; )
{
try
{
if (br.ReadByte() == 0x00)
{
if (br.ReadByte() == 0x00)
{
if (br.ReadByte() == 0x00)
{
if (br.ReadByte() == 0x70)
{
if (br.ReadByte() == 0x72)
{
if (br.ReadByte() == 0x6F)
{
if (br.ReadByte() == 0x6A)
{
byte[] Position = BitConverter.GetBytes(br.BaseStream.Position - 4); //-4 Because ive searched past my start mark and this is the position i NEED
Array.Reverse(Position);

output.AppendText("0x" + BitConverter.ToString(Position).Replace("00-00-00-00-0", "").Replace("-", "") + "\n"); //Offset Position Found
}
}
}
}
}
}
}
}
CATCH { break; }
}
MessageBox.Show("The application is done searching your file.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
br.Close();
}

This works and all but i need it to be usable for searching different things. I cant REALLY find any helpful info and i can figure it out for myself so im asking for your help.Alright so i came up with a new method of searching but the old one is like 4 times faster because it only needs to search up until something is invalid and doesn't have to track back, if you have a better way of doing this then let me know.
Code: [Select] void ByteArraySearcher()
{
byte[] SearchBytes = new byte[] { 0x00, 0x00, 0x00, 0x70, 0x72, 0x6F, 0x6A };
long SearchPosition = 0x00;

BinaryReader br = new BinaryReader(File.OpenRead(MapFile));
br.BaseStream.Position = SearchPosition;

for (var i = SearchPosition; i <= br.BaseStream.Length; i++)
{
byte[] ReadBytes = br.ReadBytes(SearchBytes.Length);
if (BitConverter.ToString(ReadBytes) == BitConverter.ToString(SearchBytes)) //Must convert both byte arrays to STRING to COMPARE correctly for some odd reason
{
byte[] Position = BitConverter.GetBytes(br.BaseStream.Position - SearchBytes);
Array.Reverse(Position);
output.AppendText(BitConverter.ToString(Position).Replace("00-00-00-00-0", "").Replace("-", "") + "\n");
}
else
{
br.BaseStream.Position = br.BaseStream.Position - SearchBytes.Length + 1; //Go forward 1 byte and search again
}
}
br.Close();
if (ShowMessage == true)
{
MessageBox.Show("The application is done searching your file.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
Code: [Select] /// <summary>
/// Retrieves the first location of the specified sequence of bytes in the given stream.
/// </summary>
/// <param name="source">Stream to search.</param>
/// <param name="sequence">Sequence to look for.</param>
/// <returns>Byte position of the start of the first sequence.</returns>
private static long FindInStream(Stream source, byte[] sequence)
{
int byteposition;
if (sequence.Length == 0) return -1;
using (BinaryReader br = new BinaryReader(source))
{
try
{
while (true)
{
byte readbyte = br.ReadByte();
if (readbyte == sequence[0])
{
bool foundmatch = true;
for (int i = 1; i < sequence.Length; i++)
{
if (sequence[i] != br.ReadByte())
{
foundmatch = false;
break;
}
}
if (foundmatch) return br.BaseStream.Position - sequence.Length;
}
}
}
catch (EndOfStreamException exx)
{
return -1;
}
}
}
Quote from: BC_Programmer on April 17, 2014, 11:02:20 PM

Code: [Select] /// <summary>
/// Retrieves the first location of the specified sequence of bytes in the given stream.
/// </summary>
/// <param name="source">Stream to search.</param>
/// <param name="sequence">Sequence to look for.</param>
/// <returns>Byte position of the start of the first sequence.</returns>
private static long FindInStream(Stream source, byte[] sequence)
{
int byteposition;
if (sequence.Length == 0) return -1;
using (BinaryReader br = new BinaryReader(source))
{
try
{
while (true)
{
byte readbyte = br.ReadByte();
if (readbyte == sequence[0])
{
bool foundmatch = true;
for (int i = 1; i < sequence.Length; i++)
{
if (sequence[i] != br.ReadByte())
{
foundmatch = false;
break;
}
}
if (foundmatch) return br.BaseStream.Position - sequence.Length;
}
}
}
catch (EndOfStreamException exx)
{
return -1;
}
}
}
Why thank you good sir, while extremely fast, im finding myself sort from what im getting from my second method. There are 2 occurrences that this and my 1st post were not catching towards the end of my file and im not really sure why.Quote from: DaftHacker on April 18, 2014, 02:56:03 AM
Why thank you good sir, while extremely fast, im finding myself sort from what im getting from my second method. There are 2 occurrences that this and my 1st post were not catching towards the end of my file and im not really sure why.

"Retrieves the first location"

The one I wrote only finds the first location of the given byte sequence. You would have to seek in the stream before calling it to change the position that it starts the search from.