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.

1851.

Solve : Wordpress learn?

Answer»

my own websites that will teach me everything about www.From understanding the parts to knowing how they WORK. Lectures, classes, interactive, whatever. Any good references would be greatly appreciated. The LINK does not work.
You said 'WordPress' in the title.
Do you want to learn WordPress? If so just GO to:
http://wordpress.org
Or just Google WordPress tutorials
Ohm you NEED to KNOW that WordPress is a server side application. Which means that is not a direct Windows application. I has to have a server.




1852.

Solve : SQL database fix?

Answer»

We have a legal program that USES SQL express 2005. Somehow the company is saying our database has become corrupted and needs to be sent to a company to be rebuilt or fixed. The database sits on an external hard drive. We had to reload windows on the machine that it sits on. when we tried to reattach the database afterwards, we couldn't. Is there a cheap or software out there that I can use to fix it? I can't help you in regards to fixing the database but would suggest regular backups in the future to guard against this happening again. If the database gets updated frequently, it may need to be backed up daily in ORDER to prevent losing data.

Good luck in recovering the database. So you have only the .mdf and .ldf files?
The only thing left to try is:
1) take a copy of the ORIGINAL .mdf file (it's far better if it's the file as it looked BEFORE you attempted to attach it -- the attach attempt itself will modify the file)
2) if the db has only the one primary FG, attempt to do a "sp_attach_single_file_db" on the file.
If it has multiple fgs, primary and one or more secondaries, you will have to use CREATE DATABASE ... WITH ATTACH_REBUILD_LOG

For example, select "New Query" from withn Express, then issue this command:

EXEC sp_attach_single_file_db 'Db_Attach_Test',
'x:\path\to\primary\data\file\primarydatafile.mdf'
Of the programs I can recommend to you SQL Server Recovery TOOLBOX if the above suggestion don't help. I hope everything works out for you. http://www.oemailrecovery.com/sql_recovery.html
Also have a look this Recommended actions
http://itknowledgeexchange.techtarget.com/itanswers/it-seems-our-sql-database-is-corrupted/

1853.

Solve : Debugging Scripts?

Answer»

got this message concerning
Unresponsive script . Do I DEBUG, continue, etc.
What does it MEAN, & how do I HANDLE it ?
THANKS !

1854.

Solve : Which language would suit my reguirement??

Answer»

What programming LANGUAGE would allow me to create a utility where i can open up and USE WINDOWS applications within that program?

Thanks You're going to need to explain what you are trying to do in more DETAIL, what you've asked isn't very CLEAR.

1855.

Solve : Create headers in a CSV file using Clarion 6.3?

Answer»

I have written a ROUTINE in CW 6.3 to create a CSV file and it works fine. I, HOWEVER, have to add a header and footer to the CSV file.
Is there maybe an example around?

THANKS

1856.

Solve : Need help with UNIX script?

Answer»

I'm writing a UNIX shell script and I need to WRITE a code USING a text file. For each LINE in the text file, the third field ranges from 2 through 6.

2=Sparkling, 3=Foritified, 4=Sweet, 5=White, and 6=Red. I need to make it so that if the third field is a 2, it would add 1 to the COUNTER "Sparkling" and so on. How can I do this? Thank you for any help

1857.

Solve : Adobe issues?

Answer»

I suddenly have ASK installed as homepage. Which I don't want. I believe I must have installed some version of Adobe to cause that ?
Do I need Adobe & any of it's versions at all ?
You need adobe for some WEB sites that offer video. But a video can be sent out without using Adobe. It is up to the web site.
For example, Netflix now uses Silver LIGHT, which is better than Adobe anyway.
In any case, when you get Adobe, make SURE it is really from Adobe and do not ACCEPT the extras promotions.
Ok, but can't I just uninstall Ask ?Sure. Does it appear in Programs & Features?

1858.

Solve : how can i become a programmer?

Answer»

my name is dsymaryon,
please i want to learn how to program and be a good programmer!

dsymaryon, welcome to the forum.

It takes about two years for some people to learn how to program. But it all depends on how much time and motivation you have.
Do you have good reading skills? There are many good books about programming. But you don't have to buy the books. Some are at your local library. Others are free on the Internet.

Have you computer you can use? What kind?

Are in in school now? Have you raked to a school counselor? Does your school have a computer club? Do you have friends or relatives that program?

Before I and give more exact advise, I would have to know some more things about you. Like your age, your hobbies and your BEST subjects in school.


Are you sure you have the aptitude to be a programmer? Programming requires a very logical thought process that some people don't seem to possess. If you are currently in school, ask your counselor if you can take tests that will show what aptitude strengths you have and then go from there. The best thing you can do really is to just try it and see how you get on, the only way you can really learn to program is by doing it, it just takes a lot of practice. I'd recommend starting off with something simple like Python, jumping straight into something like Java or C++ is a massive leap that introduces far too many confusing concepts.

It won't be a quick process though, it can take a couple of years of practice before you will be able to write a large scale system that works well.

I'd recommend starting off with some sort of proper tutorial such as Codecademy which provides an entirely online environment for running the code that you will write. It's not the most exciting thing in the world but will teach you the basics you need to learn. From there you can then look into making more interesting projects. It's important that you don't learn to write code by following "tutorials" that essentially give you the code that you need since it's all too easy to just blindly copy it without thinking about what it does. Sites such as Codecademy on the other hand introduce the concepts and make you think about how to solve the challenges.

The Codecademy Python tutorial can be found here: https://www.codecademy.com/tracks/pythonAnyone can become a programmer and claim to be one.... however a really good programmer is not that easy to be if you have a weaknesses in attributes that need to be strong for a programmer.

Biggest question I have is.... what specific types of programming interest you?... as for the program language suggestion may depend deeply on your programming goals.

Have you ever looked at any good properly programmed and functional if run source code before and tried to figure out what it does and why through a reverse engineering process?

I also agree with Cameron that you would want to work with a language such as Python and go from there. Then once you get the basics down of coding and reuse of objects and nested loops and logic conditions, then you can get into advanced Python with multidimensional arrays and Local and Global Variables etc, and either stick with python or move on to a more complex ide.

Being a programmer is NOT easy! You need to be very good with math, logic, and keeping track of what is going on and why. Flow charts are very useful as well as comment lines in your code to keep track of what is going on and dependencies. As well as need to be able to think outside of the box to avoid painting yourself into a corner with your code because you didnt see the whole picture when going into programming it all up. Expect to spend hours on end of just coding and debugging. Expect to mess around with your own code or others code on a daily basis and continually learn from others code as well as personal experiences with your own.

I have been programming since 1985 at age of 10 on Basic. I self taught myself from TRS-80 magazines that had code examples in them which I would take the time to type it exactly as I saw it in the magazine and then run it. Many times I would typo and the program would fail to operate or would operate and I would get unexpected results. I had a TRS-80 Model 1 with only 16k RAM I made my own programs at times and ran out of memory. This gave me a good basis to build my programming skills from....however it also while giving me a grasp of concepts taught me very bad programming with what is called Spaghetti code. I was so use to just using redirection of GOTO statements that when i wanted to jump to another section of code, i would just use goto statements everywhere. For a programmer other then myself they would have had a headache trying to follow my code. I then moved on to GW-Basic which had sounds and colors which made making games fun. I then moved on to QBasic although because QBasic had legacy support for handling GW-Basic ( basic ) I found myself many times just reverting back to old habits with GW-Basic coding of Basic instead of learning the better QBasic methods. In college in 1998 I dove into C++. I had a choice of C++ or VB. I chose C++ because I wanted to be able to program cross platform and wanted to go for the harder language and one that most of the video games out there was programmed from. My dream at one point was to be a Game Developer Programmer. Soon however I quickly realized that I was in over my head mainly because its very very difficult to make video games solo with no digital ART skills and mathematical computer physics skills to create formulas that would render to make an imaginary world come to life. Instead I focused on IT/MIS and used my programming skills to make band aid fixes to join data between 2 pieces of software or very specific custom programs that there is no off the shelf or download option for. I have also posted some projects onto github for others to use my C++ source code to tweak it or compile it and use it for themselves as is with no liability for any damages that result from use of my programs.

These days I do not code on a regular basis. The last program I wrote was 2 weeks ago, and before that about 3 weeks before that. I often find myself looking online for code examples and then implementing that into my source code for advanced concepts that are new to me or I am not familiar with enough to just code on the fly. So I am more of a hobby programmer. Additionally I had difficulty sticking with only 1 language. I wanted to be familiar with all and so I went for all. This need of having to know all, even though I never will is probably my biggest mistake as for if I took all that time and focused on just 1 language I would be further ahead in my skills for C++.

I am familiar with:
C++
C#
C
Basic
GW-Basic
QBasic
VB ( Visual Basic )
Perl
Python
PHP
Ruby
Batch
Java Script
HTML

and my favorites are C++, C#, Perl, Python, PHP.

Why I like each one:

C++ ... you can do just about anything you can think of with it if you can grasp the concepts and have the ability to think it all up and code it properly. It supports multiple platforms. You can compile the program and distribute it.

C# ... it is so much easier than C++. It has lots of strengths over C++....mainly Rapid Development using the IDE

Perl ... I can code up a program in 5 minutes that could take me 30 minutes or longer to achieve with C++. It has many built in strengths. It compiles on the fly so you just launch your .PL file and its runs or crashes if you has issues. It has good support for server side scripting for dynamic web pages.

Python ... Its like Perl but I feel more advanced. It supports Linux VERY WELL so if your coding for the Linux open source community, it plays well with Linux.

PHP ... Server Side scripting is very good. Has some strengths above that of Perl for the same programming needs.All of these suggestions are good, but it is really hard to learn to program reading a book or books.

Look around the house, at work, of from friends on something that you want to make easier. For me I was a youth bowling coach back in the late 70s and with regular work and coaching it put a strain on me to make sure I had the standing sheets and doing other chores required. So I created a program to help me do it. Start small and expand as you grow more comfortable.

Now I started with BASIC, it is easier to learn and can be done quicker than trying to learn C or any other language. You can download a free version of Visual Studio from Microsoft and there you have C++, C#, and BASIC all in one package. But I found something that will help make it easier, there is a free program called QB64, a Quick BASIC clone. It runs in Windows or if you have Linux you can use it in Wine. There are free clones in many languages, Pascal, Fortran, Cobol, C, and C++, along with BASIC.

It is unfortunate that today we don't have the constraints that we had back in the late 70s and early 80s when you had to create a powerful application and it had to fit on a 360k floppy. Today many programmers will go crazy with needless code because there is no limits on what you can put on a disc. When OS/2 was released along with the IBM /2, Bill Gates bragged about it took 3 million lines of code to create OS/2, 3 million. All of us programmers standing in the back of the room shook our heads at 3 million lines of code.Quote from: OldTimeCoder on January 12, 2016, 04:42:52 PM

All of these suggestions are good, but it is really hard to learn to program reading a book or books.
Books/ Programmer's guides make a good reference, but I agree, one cannot merely read them and know how to program. I myself taught myself with the Visual Basic 2.0 manuals over a summer break- but I did this by deciding what to make (a straightforward HTML color selector for the tag) and using the books as a reference for how to do so. That is- the Programmer's Guide had "tutorials" of sorts but I didn't see the value in animating a butterfly across a window.

Nowadays I try to get more familiar with programming languages I've not used much by using the problems on Project Euler or by creating an Anagram search program to find algorithms in a dictionary file. Which is pretty useless, but I already know how to program in other languages. I agree that when first learning to program it is very useful to create something useful because then the programmer is a user of their own software.

Quote
You can download a free version of Visual Studio from Microsoft and there you have C++, C#, and BASIC all in one package.

It should be noted that Visual Studio does not support BASIC; rather the language it supports is Visual Basic .NET. It shares syntax and keywords with many BASIC dialects but it is quite a different platform and language. The reason I mention this is that BASIC tends to be associated with, uh, it's acronym, but realistically I don't think the language supported by .NET for Visual Basic is really intended for Beginners- not in the same sense as with BASIC. Kemeny and Kurtz would probably be rolling in their grave to hear the two associated.

That is not to suggest that it is a bad idea to use Visual Studio- C# and Visual Basic are as good as any other language, IMO. My advice to those who are trying to "choose" which language/platform to start with is that what they start with is less important then the fact that they actually get started.

Quote
But I found something that will help make it easier, there is a free program called QB64, a Quick BASIC clone.
FreeBASIC is another good alternative. I believe it might be a better option for Linux as (iirc) it can be run natively under Linux as well.

Quote
It is unfortunate that today we don't have the constraints that we had back in the late 70s and early 80s when you had to create a powerful application and it had to fit on a 360k floppy. Today many programmers will go crazy with needless code because there is no limits on what you can put on a disc. When OS/2 was released along with the IBM /2, Bill Gates bragged about it took 3 million lines of code to create OS/2, 3 million. All of us programmers standing in the back of the room shook our heads at 3 million lines of code.
I can't find a reasonable source for the quote but I don't doubt that somebody said it. How many lines of code a product had was some weird chest-beating in the 90's.

Even nowadays anything older than a few years "should be upgraded"- but it makes no sense to do that if it already works. The software I work on is a C#, Windows equivalent to the old BASIC product. It worked well enough since the 80's and while it's hardly perfect, it was enough for them to do business. The reason we are making a new version is that it stopped serving that task because the OS vendor won't INVESTIGATE, let alone patch a serious network stack problem.

Any time I mention my work on a programming forum, it's all "Dude, you should use WPF" and "OMG, Windows Forms, you poor *censored*!" or "So you are accessing Postgres directly? You should be using Entity framework".

It's just a litter of pointless buzzwords. Using those new technologies doesn't make the product better! Usually it just adds a bunch of pointless busiwork. Almost makes you think it's a conspiracy by developers so they can expand their estimates! . "Oh, yeah, FINE, Mr. Manager, sure we COULD just read the value from the database, but the proper way is to create a data adapter intermediary segmented accessor class, and construct instances using a multipattern segmented assembly factory. Then we can utilize jQuery and pattern-swap over the NoSQL MONGODB while asynchronously AJAXing a nearby Universal platform. And I'm not going to be responsible for problems that ARISE because we didn't write an appropriate universal segmented multipattern buffered adapter."
This thread just keeps going on.

Now about books and computers. Long before productive computers were built, books existed and laid the foundation for the ideas that led to computers.
If you go to a public library you will see a well organized collection of information that humans have acquired over the years. For a single individual, or even a group of persons, this would take many many years to acquire.

Books help you understand the reasons that people can either hate or love computers. There are books about computers that are not really about computers, but about why people want computers.
Here are a couple of books about computers that are not programming textbooks.

Computer power and human reason.
https://en.wikipedia.org/wiki/Computer_Power_and_Human_Reason

The Soul of a New Machine.
https://en.wikipedia.org/wiki/The_Soul_of_a_New_Machine

Anybody interested in computer science can benefit by reading either of the two publications listed above.
Quote from: BC_Programmer on January 12, 2016, 08:32:26 PM
It should be noted that Visual Studio does not support BASIC; rather the language it supports is Visual Basic .NET. It shares syntax and keywords with many BASIC dialects but it is quite a different platform and language. The reason I mention this is that BASIC tends to be associated with, uh, it's acronym, but realistically I don't think the language supported by .NET for Visual Basic is really intended for Beginners- not in the same sense as with BASIC. Kemeny and Kurtz would probably be rolling in their grave to hear the two associated.

That is not to suggest that it is a bad idea to use Visual Studio- C# and Visual Basic are as good as any other language, IMO. My advice to those who are trying to "choose" which language/platform to start with is that what they start with is less important then the fact that they actually get started.
FreeBASIC is another good alternative. I believe it might be a better option for Linux as (iirc) it can be run natively under Linux as well.
I can't find a reasonable source for the quote but I don't doubt that somebody said it. How many lines of code a product had was some weird chest-beating in the 90's.

Even nowadays anything older than a few years "should be upgraded"- but it makes no sense to do that if it already works. The software I work on is a C#, Windows equivalent to the old BASIC product. It worked well enough since the 80's and while it's hardly perfect, it was enough for them to do business. The reason we are making a new version is that it stopped serving that task because the OS vendor won't investigate, let alone patch a serious network stack problem.

Any time I mention my work on a programming forum, it's all "Dude, you should use WPF" and "OMG, Windows Forms, you poor *censored*!" or "So you are accessing Postgres directly? You should be using Entity framework".

It's just a litter of pointless buzzwords. Using those new technologies doesn't make the product better! Usually it just adds a bunch of pointless busiwork. Almost makes you think it's a conspiracy by developers so they can expand their estimates! . "Oh, yeah, fine, Mr. Manager, sure we COULD just read the value from the database, but the proper way is to create a data adapter intermediary segmented accessor class, and construct instances using a multipattern segmented assembly factory. Then we can utilize jQuery and pattern-swap over the NoSQL MONGODB while asynchronously AJAXing a nearby Universal platform. And I'm not going to be responsible for problems that arise because we didn't write an appropriate universal segmented multipattern buffered adapter."

The fella asked a question and I did not see a really good answer to it. I gave some suggestions, he is a beginner. I'm sure you have your favorite software just as I have my favorites but that means nothing to a beginner.

If you started programming in 85 or somewhere around there you had 1.44 & 1.2 meg floppies to work with. When I started in 80 my best had to go in a 160k floppy. Even working in the 90s and early 2000 anything I wrote I made to fit on a 360k floppy, and had to fit within 1.2meg with program, manuals, data structures, and any drivers. I taught some programming classes in the junior college and kids just went wild, redundant code or routines that did nothing. I'm sure you have seen some of that.

As far as the message that Bill Gates gave, I was there when Microsoft and IBM brought out OS/2 and the new IBM /2 computers systems with a new bus that did not last long.Perhaps I've misunderstood- I was merely trying to engage in friendly discussion on the subject.Visual Studio is free for educational and personal use. It does require some time to learn how to use it, *censored* is worth the effort. The OP hasn't been back since October. I'd suggest you are talking to yourselves at this point.
1859.

Solve : Install a Reg edit by script?

Answer»

Hi All,
I am looking to find a way to install a regedit on about 30 machines. I have the change I WANT to make I just don't know how to have a machine install the change without having to login to each machine. Any ideas?

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_ALLOW_USER32_EXCEPTION_HANDLER_HARDENING]
"iexplore.exe"=dword:00000001


Thanks

https://support.microsoft.com/en-us/kb/264584

Warning: The instruction below is not the instruction for you to run but only an example from this website in syntax. You might be able to write a batch file that has 30 of these instructions with each having their own \\remoteworkstation I would ASSUME you replace with actual name of the computer such as \\Dell1 \\Dell2 etc.

Quote

In Windows XP and in Windows Server 2003, you must enclose the value in quotation marks. For example, you could use the FOLLOWING script to call AUoptions.txt.

regini.exe -m \\remoteworkstation auoptions.txt HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update "ConfigVer"= REG_DWORD 1 "AUOptions"= REG_DWORD 4 "ScheduledInstallDay"= REG_DWORD 0 "ScheduledInstallTime"= REG_DWORD 1

I am not sure if this will work on systems that are not already logged in. I was expecting there to be a user/password line in this to authenticate with the remote system. Maybe as long as your system admin on the one system you start this from and all other systems have the same system admin account on them with same password it will pass thru authenticate without need for a runas instruction. Be very careful as for this can mess up a registry fast if you mess up info tp pass to it. If you have 2 computers that are not important, I'd perfect the script on the 2 unimportant systems first to make sure it works and then make it for all 30 and run it. You could also be careful and save a backup copy of the registries of all 30 systems too to revert back if there are PROBLEMS after running the script.
1860.

Solve : php radio button link?

Answer»

I want to select a row from mysqli dropdown,
click on button & link to "target"(format - www.somesite.com).
change 2 fields in the sql (via lastused.php) code follows:
My dropdown works, can't figure out the button code.
My dropdown code follows:
Any help?

Code: [Select]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>

<SCRIPT language=JavaScript>
<!-- CLOCK --
var timerID = null
var timerRunning = false

function stopclock()
{ if(timerRunning) clearTimeout(timerID) timerRunning = false }

function startclock()
{ stopclock() showtime() }

function showtime()
{
var now = new DATE()
var hours = now.getHours()
var MINUTES = now.getMinutes()
var seconds = now.getSeconds()
var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " P.M." : " A.M."
document.clock.face.value = timeValue
timerID = setTimeout("showtime()",1000)
timerRunning = true
}
//-->
</SCRIPT>

</head>
<BODY onload="startclock()"><center>
<FORM NAME=clock method="post" action="" onsubmit=0>
<INPUT size=11 value=....Initializing.... name=face>
<FORM name=lastused method="post" action="">

<?php
echo"<center>";echodate('m/d/y');echo"</center>";
$id="''";
$con=mysqli_connect("localhost","root","cookie","homedb");
//==============checkconnection
if(mysqli_errno($con))
{echo"Can'tConnecttomySQL:".mysqli_connect_error();}
else
{echo"</br>";}
//==========Thiscreatesthedropdownboxusingrecordsinthetable
echo"<selectname='target'>";
echo'<optionvalue="">'.'---selectemailaccount---'.'</option>';
$query=mysqli_query($con,"SELECTtargetFROMemailtbl");
$query_display=mysqli_query($con,"SELECT*FROMemailtbl");
while($row=mysqli_fetch_array($query))
{echo"<optionclass=highlightvalue='".$row['target']."'>".$row['target']
.'</option>';}
echo'</select>';
?>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php
nclude('lastused.php');//*********codefollows******************

error_reporting(E_ALL^E_NOTICE);
//error_reporting(0);
$con=mysqli_connect("localhost","root","cookie","homedb");
if(mysqli_errno($con))
{echo"Can'tConnecttomySQL:".mysqli_connect_error();}
if(isset($_POST['target']))
{
$id=$_POST['id'];
$lastused=$_POST['lastused'];
$name=$_POST['target'];
$fetch="SELECTtarget,username,password,emailused,lastused,purpose,savedFROMemailtblWHEREtarget='".$name."'";
$result=mysqli_query($con,$fetch);
if(!$result)
{echo"Error:".(mysqli_error($con));}

//===============================thisdisplaysthetable

echo'<tableborder="1">'.'<tr>'.'<tdbgcolor="#FFD47F"align="center">'.'emailmenu'.'</td>'.'</tr>';
echo'<tr>'.'<td>'.'<tableborder="1">'.'<tr>'.'<tdbgcolor="#ccffff">'.'target'.'</td>'.'<tdbgcolor="#ccffff">'.'username'.'</td>'.'<tdbgcolor="#ccffff">'.'password'.'</td>'.'<tdbgcolor="#ccffff">'.'emailused'.'</td>'.'<tdbgcolor="#FFD47F">'.'lastused'.'</td>'.'<tdbgcolor="#ccffff">'.'purpose'.'</td>'.'<tdbgcolor="#ccffff">'.'saved'.'</td>'.'</tr>';
while($data=mysqli_fetch_row($result))
{echo("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td><td>$data[5]</td><td>$data[6]</td></tr>");}
echo'</table>'.'</td>'.'</tr>'.'</table>';
}
?>
</body></html>=======================================================
Code: [Select]<?php
//lastused.php
$dbconnect=mysqli_connect('localhost','root','cookie')ordie(mysqli_error($dbconnect));
$result=mysqli_query($dbconnect,"SELECT*FROMemailtbl");
if(!empty($_POST['lastused']))
{
$update=mysqli_query($dbconnect,"UPDATEemailtblSETvisits=visits+1,
lastused='NOW()'WHERElastused='$lastused'");
if($update==false)
{die("UPDATEFAILED:".mysqli_error($dbconnect));}
}
?>

1861.

Solve : Crypt & UnCrypt - C++ Programming - Sharing Project?

Answer»

Decided to share a project I was playing with. During the cold winter months I like to dive into programming and had been thinking about playing around with scrambling and crypting info for a while. These Crypt and unCrypt programs are not complex and are very basic crypt with character substitution. This is pretty easy to crack to decrypt because its just substitution and repeat characters also show as repeats in the crypted form.

From here on I plan on making it even more complex where there are more than one key so it starts from multiple places in the Random Algorithm and each character within the string that is input is assigned to substitution from a different shuffled group of characters meaning that if you saw 2 characters alike paired, you will not be able to decrypt it so easily because a pair of characters are unlikely to be substitution for the same character.

I am using the Bloodshed Dev C++ 4.9.9.2 IDE. If you use a different IDE you might need to edit it some. Such as I use to program using Borland C++ 5.02 IDE years ago and when taking that source code to Microsoft C++ 6.0 I had to edit it some to get it to compile.

The code shared works and I need to clean it up, but still has some commented out debug and a -1 offset for a mistake I made which I plan to correct to remove the -1 offset. The mistake was that arrays start at 0 and not 1. I wrote the lengthy IF ELSE logic without having even created my array yet and right away I knew there was a problem when I got a mismatch between my input and output. The quick fix vs going through and editing all my IF statements was to just place a -1 offset so that it targets the array for the correct character place from the string. Once I fix the IF statements I can remove this -1 offset band aid.

These crypt and uncrypt programs support only these characters:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm [emailprotected]#$%^&*()_-+=?<>:\/~.,;

And this character ` is used as an option to end the program, however you can also end it by closing the window or keystroke kill command.

You can add more characters if necessary, but in doing so you need to add the IF statements to support the additional characters.

The array size I set to 128. It could be set to the bare MINIMUM but 128 is ok because it only wastes a very small amount of RAM.

If anyone has any suggestions to improve the code or wants to build on from this, please feel free to do so and share changes here with notation or comments in the code. Lastly I am not a professional programmer its more of a hobby, so if your a professional programmer and you see something that is like nails on a chalk board in my code, I'm sorry and it wasnt done intentionally to be painful to read in the source, its just that there are many ways to achieve the same desired output and programming is sort of like an art and everyone has their own style sort of. My style seems to follow an abstract Rube Goldberg at times as for I need my code to do something and at times I will achieve my goal and once compiled no one would really know the difference really, but the source code tends to be blocked together of different pieces that make it work which may not be the most efficient or hold to a coding standard.

Crypt v1.01
Code: [Select]#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
// 12/30/2015 - Added string random shuffle
// 12/31/2015 - Added custom seed for random shuffle so seed acts a crypt key
// 1/4/2016 - Added ability to enter string and have while loop process
// 1/5/2016 - Added characters , and ; to supported characters which were missing from v1.00
using namespace std;

int main(int argc, char *argv[])
{

int seed1=0;
int code1=0;
int code2=0;
int point1=0;
int processed=0;
int run=1;
char ch1;
cout<<" Crypt Version 1.01\n\n";
cout<<"XXXXXXXXXXXXXXXXXXXXX\n";
cout<<" Enter Integer Seed: \n"; // Asks user to input integer seed
cout<<"XXXXXXXXXXXXXXXXXXXXX\n\n";
cin >> seed1; // Input user seed
cout<<"\n\n"<<"Crypt String Key =\n\n";

//cout << "Jumble: ";
//Initialize Valid Characters for String Shuffle Output
//Note Bug corrected with blank space for \ by use of escape character proceeding
string str="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";

//Pass static string list to array prior to shuffle
string tmp1 = str; //Pass str output to string tmp
char tab3[128]; // Memory Allocation for array population
strncpy(tab3, tmp1.c_str(), sizeof(tab3)); //string copy tmp into tab2 array
tab3[sizeof(tab3) - 1] = 0;



srand(seed1); // Allows user custom seeded starting algorithm position for random

random_shuffle(str.begin(), str.end()); // Shuffle the string
cout << str << "\n\n\n"; // Output the shuffle sequence

//Pass String Output into an array to pair up pointer value with associated

character

//Pass String Output into an array to pair up pointer value with associated

character

string tmp = str; //Pass str output to string tmp
char tab2[128]; // Memory Allocation for array population
strncpy(tab2, tmp.c_str(), sizeof(tab2)); //string copy tmp into tab2 array
tab2[sizeof(tab2) - 1] = 0;

//cout<<"Enter array pointer value\n";
//cin>>point1;
//Correction for Array offset since starting position is 0 not 1
point1--; //This can be removed after changing IF logic -1 for all code1 values
cout<<tab2[point1]<<"\n";
//system("cls");

cout<<"Enter Info to Crypt in correct case\n";
cout<<"To Exit Program Close Window or enter ` \n\n\n";

while(run==1){

cin>>ch1;

if (ch1=='A'){
code1=1;
}
else if (ch1=='B'){
code1=2;
}
else if (ch1=='C'){
code1=3;
}
else if (ch1=='D'){
code1=4;
}
else if (ch1=='E'){
code1=5;
}
else if (ch1=='F'){
code1=6;
}
else if (ch1=='G'){
code1=7;
}
else if (ch1=='H'){
code1=8;
}
else if (ch1=='I'){
code1=9;
}
else if (ch1=='J'){
code1=10;
}
else if (ch1=='K'){
code1=11;
}
else if (ch1=='L'){
code1=12;
}
else if (ch1=='M'){
code1=13;
}
else if (ch1=='N'){
code1=14;
}
else if (ch1=='O'){
code1=15;
}
else if (ch1=='P'){
code1=16;
}
else if (ch1=='Q'){
code1=17;
}
else if (ch1=='R'){
code1=18;
}
else if (ch1=='S'){
code1=19;
}
else if (ch1=='T'){
code1=20;
}
else if (ch1=='U'){
code1=21;
}
else if (ch1=='V'){
code1=22;
}
else if (ch1=='W'){
code1=23;
}
else if (ch1=='X'){
code1=24;
}
else if (ch1=='Y'){
code1=25;
}
else if (ch1=='Z'){
code1=26;
}
else if (ch1=='a'){
code1=27;
}
else if (ch1=='b'){
code1=28;
}
else if (ch1=='c'){
code1=29;
}
else if (ch1=='d'){
code1=30;
}
else if (ch1=='e'){
code1=31;
}
else if (ch1=='f'){
code1=32;
}
else if (ch1=='g'){
code1=33;
}
else if (ch1=='h'){
code1=34;
}
else if (ch1=='i'){
code1=35;
}
else if (ch1=='j'){
code1=36;
}
else if (ch1=='k'){
code1=37;
}
else if (ch1=='l'){
code1=38;
}
else if (ch1=='m'){
code1=39;
}
else if (ch1=='n'){
code1=40;
}
else if (ch1=='o'){
code1=41;
}
else if (ch1=='p'){
code1=42;
}
else if (ch1=='q'){
code1=43;
}
else if (ch1=='r'){
code1=44;
}
else if (ch1=='s'){
code1=45;
}
else if (ch1=='t'){
code1=46;
}
else if (ch1=='u'){
code1=47;
}
else if (ch1=='v'){
code1=48;
}
else if (ch1=='w'){
code1=49;
}
else if (ch1=='x'){
code1=50;
}
else if (ch1=='y'){
code1=51;
}
else if (ch1=='z'){
code1=52;
}
else if (ch1=='1'){
code1=53;
}
else if (ch1=='2'){
code1=54;
}
else if (ch1=='3'){
code1=55;
}
else if (ch1=='4'){
code1=56;
}
else if (ch1=='5'){
code1=57;
}
else if (ch1=='6'){
code1=58;
}
else if (ch1=='7'){
code1=59;
}
else if (ch1=='8'){
code1=60;
}
else if (ch1=='9'){
code1=61;
}
else if (ch1=='0'){
code1=62;
}
else if (ch1=='!'){
code1=63;
}
else if (ch1=='@'){
code1=64;
}
else if (ch1=='#'){
code1=65;
}
else if (ch1=='$'){
code1=66;
}
else if (ch1=='%'){
code1=67;
}
else if (ch1=='^'){
code1=68;
}
else if (ch1=='&'){
code1=69;
}
else if (ch1=='*'){
code1=70;
}
else if (ch1=='('){
code1=71;
}
else if (ch1==')'){
code1=72;
}
else if (ch1=='_'){
code1=73;
}
else if (ch1=='-'){
code1=74;
}
else if (ch1=='+'){
code1=75;
}
else if (ch1=='='){
code1=76;
}
else if (ch1=='?'){
code1=77;
}
else if (ch1=='<'){
code1=78;
}
else if (ch1=='>'){
code1=79;
}
else if (ch1==':'){
code1=80;
}
else if (ch1=='\\'){ // Escape Character \ needed to allow \ check
code1=81;
}
else if (ch1=='/'){
code1=82;
}
else if (ch1=='~'){
code1=83;
}
else if (ch1=='.'){
code1=84;
}
else if (ch1==','){
code1=85;
}
else if (ch1==';'){
code1=86;
}
else if (ch1=='\`'){ //Escape Character \ before ` to exit
run=0; //Run = False at 0 and leaves while loop
}
else {
cout<<"Invalid Input = No Match\n\n";
}
processed++;

code2=code1-1; //Array code1 offset where 0 is starting position 1

cout<<tab2[code2];
}
//cout<<processed<<" = loops\n\n";

system("PAUSE");
return EXIT_SUCCESS;
}
unCrypt v1.01

Code: [Select]#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
// 12/30/2015 - Added string random shuffle
// 12/31/2015 - Added custom seed for random shuffle so seed acts a crypt key
// 1/4/2016 - Added ability to enter string and have while loop process
// 1/5/2016 - Added inverse unCrypt array pairing between Alpha and Seeded Key
// 1/6/2015 - Added characters , and ; to supported characters to crypt
using namespace std;

int main(int argc, char *argv[])
{


int seed1=0;
int code1=0;
int code2=0;
int point1=0;
int processed=0;
int run=1;
char ch1;
cout<<" unCrypt Version 1.01\n\n";
cout<<"XXXXXXXXXXXXXXXXXXXXX\n";
cout<<" Enter Integer Seed: \n"; // Asks user to input integer seed
cout<<"XXXXXXXXXXXXXXXXXXXXX\n\n";
cin >> seed1; // Input user seed
cout<<"\n\n"<<"unCrypt String Key =\n\n";


//Initialize Valid Characters for String Shuffle Output
//Note Bug corrected with blank space for \ by use of escape character proceeding
string str="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";
//String random comparison 1 for 1 match

//Pass static string list to array prior to shuffle
string tmp1 = str; //Pass str output to string tmp
char tab3[128]; // Memory Allocation for array population
strncpy(tab3, tmp1.c_str(), sizeof(tab3)); //string copy tmp into tab3 array
tab3[sizeof(tab3) - 1] = 0;


srand(seed1); // Allows user custom seeded starting algorithm position for random

random_shuffle(str.begin(), str.end()); // Shuffle the string
cout << str << "\n\n\n"; // Output the shuffle sequence

//Pass String Output into an array to pair up pointer value with associated character

string tmp = str; //Pass str output to string tmp
char tab2[128]; // Memory Allocation for array population
strncpy(tab2, tmp.c_str(), sizeof(tab2)); //string copy tmp into tab2 array
tab2[sizeof(tab2) - 1] = 0;

//Correction for Array offset since starting position is 0 not 1
point1--; //This can be removed after changing IF logic -1 for all code1 values
cout<<tab2[point1]<<"\n";
//system("cls");

cout<<"Enter Info to unCrypt in correct case\n";
cout<<"To Exit Program Close Window or enter ` \n\n\n";

while(run==1){

cin>>ch1;

if (ch1==tab2[0]){
code1=1;
}
else if (ch1==tab2[1]){
code1=2;
}
else if (ch1==tab2[2]){
code1=3;
}
else if (ch1==tab2[3]){
code1=4;
}
else if (ch1==tab2[4]){
code1=5;
}
else if (ch1==tab2[5]){
code1=6;
}
else if (ch1==tab2[6]){
code1=7;
}
else if (ch1==tab2[7]){
code1=8;
}
else if (ch1==tab2[8]){
code1=9;
}
else if (ch1==tab2[9]){
code1=10;
}
else if (ch1==tab2[10]){
code1=11;
}
else if (ch1==tab2[11]){
code1=12;
}
else if (ch1==tab2[12]){
code1=13;
}
else if (ch1==tab2[13]){
code1=14;
}
else if (ch1==tab2[14]){
code1=15;
}
else if (ch1==tab2[15]){
code1=16;
}
else if (ch1==tab2[16]){
code1=17;
}
else if (ch1==tab2[17]){
code1=18;
}
else if (ch1==tab2[18]){
code1=19;
}
else if (ch1==tab2[19]){
code1=20;
}
else if (ch1==tab2[20]){
code1=21;
}
else if (ch1==tab2[21]){
code1=22;
}
else if (ch1==tab2[22]){
code1=23;
}
else if (ch1==tab2[23]){
code1=24;
}
else if (ch1==tab2[24]){
code1=25;
}
else if (ch1==tab2[25]){
code1=26;
}
else if (ch1==tab2[26]){
code1=27;
}
else if (ch1==tab2[27]){
code1=28;
}
else if (ch1==tab2[28]){
code1=29;
}
else if (ch1==tab2[29]){
code1=30;
}
else if (ch1==tab2[30]){
code1=31;
}
else if (ch1==tab2[31]){
code1=32;
}
else if (ch1==tab2[32]){
code1=33;
}
else if (ch1==tab2[33]){
code1=34;
}
else if (ch1==tab2[34]){
code1=35;
}
else if (ch1==tab2[35]){
code1=36;
}
else if (ch1==tab2[36]){
code1=37;
}
else if (ch1==tab2[37]){
code1=38;
}
else if (ch1==tab2[38]){
code1=39;
}
else if (ch1==tab2[39]){
code1=40;
}
else if (ch1==tab2[40]){
code1=41;
}
else if (ch1==tab2[41]){
code1=42;
}
else if (ch1==tab2[42]){
code1=43;
}
else if (ch1==tab2[43]){
code1=44;
}
else if (ch1==tab2[44]){
code1=45;
}
else if (ch1==tab2[45]){
code1=46;
}
else if (ch1==tab2[46]){
code1=47;
}
else if (ch1==tab2[47]){
code1=48;
}
else if (ch1==tab2[48]){
code1=49;
}
else if (ch1==tab2[49]){
code1=50;
}
else if (ch1==tab2[50]){
code1=51;
}
else if (ch1==tab2[51]){
code1=52;
}
else if (ch1==tab2[52]){
code1=53;
}
else if (ch1==tab2[53]){
code1=54;
}
else if (ch1==tab2[54]){
code1=55;
}
else if (ch1==tab2[55]){
code1=56;
}
else if (ch1==tab2[56]){
code1=57;
}
else if (ch1==tab2[57]){
code1=58;
}
else if (ch1==tab2[58]){
code1=59;
}
else if (ch1==tab2[59]){
code1=60;
}
else if (ch1==tab2[60]){
code1=61;
}
else if (ch1==tab2[61]){
code1=62;
}
else if (ch1==tab2[62]){
code1=63;
}
else if (ch1==tab2[63]){
code1=64;
}
else if (ch1==tab2[64]){
code1=65;
}
else if (ch1==tab2[65]){
code1=66;
}
else if (ch1==tab2[66]){
code1=67;
}
else if (ch1==tab2[67]){
code1=68;
}
else if (ch1==tab2[68]){
code1=69;
}
else if (ch1==tab2[69]){
code1=70;
}
else if (ch1==tab2[70]){
code1=71;
}
else if (ch1==tab2[71]){
code1=72;
}
else if (ch1==tab2[72]){
code1=73;
}
else if (ch1==tab2[73]){
code1=74;
}
else if (ch1==tab2[74]){
code1=75;
}
else if (ch1==tab2[75]){
code1=76;
}
else if (ch1==tab2[76]){
code1=77;
}
else if (ch1==tab2[77]){
code1=78;
}
else if (ch1==tab2[78]){
code1=79;
}
else if (ch1==tab2[79]){
code1=80;
}
else if (ch1==tab2[80]){ // Escape Character \ needed to allow \ check
code1=81;
}
else if (ch1==tab2[81]){
code1=82;
}
else if (ch1==tab2[82]){
code1=83;
}
else if (ch1==tab2[83]){
code1=84;
}
else if (ch1==tab2[84]){
code1=85;
}
else if (ch1==tab2[85]){
code1=86;
}
else if (ch1=='\`'){ //Escape Character \ before ` to exit
run=0; //Run = False at 0 and leaves while loop
}
else {
cout<<"Invalid Input = No Match\n\n";
}
processed++;

code2=code1-1; //Array code1 offset where 0 is starting position 1



cout<<tab3[code2]; // output
}
//cout<<processed<<" = loops\n\n";

system("PAUSE");
return EXIT_SUCCESS;
}




[attachment deleted by admin to conserve space]Cleaned up code ... removed unnecessary junk from source and corrected for the +1 offset to IF logic pointed incorrectly with starting position at 1 vs 0 for array. Corrected to start at 0.

Below highlighted is input information from user and green is the output.

Quote

Crypt Version 1.02

XXXXXXXXXXXXXXXXXXXXX
Enter Integer Seed:
XXXXXXXXXXXXXXXXXXXXX

43


Crypt String Key =

/kTZ:ovA-)[emailprotected]&tq62WfVU;%i\>r^xaH,_$9CFy=JXpKQ8Id.O<1eDuc+GjmnblR?sS(
MP#*NE


Enter Info to Crypt in correct case
To Exit Program Close Window or enter `


Hello_World
AW\\^nY^H\2




Quote
unCrypt Version 1.02

XXXXXXXXXXXXXXXXXXXXX
Enter Integer Seed:
XXXXXXXXXXXXXXXXXXXXX

43


unCrypt String Key =

/kTZ:ovA-)[emailprotected]&tq62WfVU;%i\>r^xaH,_$9CFy=JXpKQ8Id.O<1eDuc+GjmnblR?sS(
MP#*NE


Enter Info to unCrypt in correct case
To Exit Program Close Window or enter `


AW\\^nY^H\2
Hello_World

Crypt Version 1.02 source code

Code: [Select]#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
// 12/30/2015 - Added string random shuffle
// 12/31/2015 - Added custom seed for random shuffle so seed acts a crypt key
// 1/4/2016 - Added ability to enter string and have while loop process
// 1/5/2016 - Added characters , and ; to supported characters which were missing from v1.00
// 1/8/2015 - Source code trash cleanup & offset band aid removed for IF statement logic +1 array offset
using namespace std;

int main(int argc, char *argv[])
{

int seed1=0;
int code1=0;
int run=1;
char ch1;
cout<<" Crypt Version 1.02\n\n";
cout<<"XXXXXXXXXXXXXXXXXXXXX\n";
cout<<" Enter Integer Seed: \n"; // Asks user to input integer seed
cout<<"XXXXXXXXXXXXXXXXXXXXX\n\n";
cin >> seed1; // Input user seed
cout<<"\n\n"<<"Crypt String Key =\n\n";

//Initialize Valid Characters for String Shuffle Output
//Note Bug corrected with blank space for \ by use of escape character proceeding
string str="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";



srand(seed1); // Allows user custom seeded starting algorithm position for random

random_shuffle(str.begin(), str.end()); // Shuffle the string
cout << str << "\n\n\n"; // Output the shuffle sequence


//Pass String Output into an array to pair up pointer value with associated character

string tmp = str; //Pass str output to string tmp
char tab2[128]; // Memory Allocation for array population
strncpy(tab2, tmp.c_str(), sizeof(tab2)); //string copy tmp into tab2 array
tab2[sizeof(tab2) - 1] = 0;


cout<<"Enter Info to Crypt in correct case\n";
cout<<"To Exit Program Close Window or enter ` \n\n\n";

while(run==1){

cin>>ch1;

if (ch1=='A'){
code1=0;
}
else if (ch1=='B'){
code1=1;
}
else if (ch1=='C'){
code1=2;
}
else if (ch1=='D'){
code1=3;
}
else if (ch1=='E'){
code1=4;
}
else if (ch1=='F'){
code1=5;
}
else if (ch1=='G'){
code1=6;
}
else if (ch1=='H'){
code1=7;
}
else if (ch1=='I'){
code1=8;
}
else if (ch1=='J'){
code1=9;
}
else if (ch1=='K'){
code1=10;
}
else if (ch1=='L'){
code1=11;
}
else if (ch1=='M'){
code1=12;
}
else if (ch1=='N'){
code1=13;
}
else if (ch1=='O'){
code1=14;
}
else if (ch1=='P'){
code1=15;
}
else if (ch1=='Q'){
code1=16;
}
else if (ch1=='R'){
code1=17;
}
else if (ch1=='S'){
code1=18;
}
else if (ch1=='T'){
code1=19;
}
else if (ch1=='U'){
code1=20;
}
else if (ch1=='V'){
code1=21;
}
else if (ch1=='W'){
code1=22;
}
else if (ch1=='X'){
code1=23;
}
else if (ch1=='Y'){
code1=24;
}
else if (ch1=='Z'){
code1=25;
}
else if (ch1=='a'){
code1=26;
}
else if (ch1=='b'){
code1=27;
}
else if (ch1=='c'){
code1=28;
}
else if (ch1=='d'){
code1=29;
}
else if (ch1=='e'){
code1=30;
}
else if (ch1=='f'){
code1=31;
}
else if (ch1=='g'){
code1=32;
}
else if (ch1=='h'){
code1=33;
}
else if (ch1=='i'){
code1=34;
}
else if (ch1=='j'){
code1=35;
}
else if (ch1=='k'){
code1=36;
}
else if (ch1=='l'){
code1=37;
}
else if (ch1=='m'){
code1=38;
}
else if (ch1=='n'){
code1=39;
}
else if (ch1=='o'){
code1=40;
}
else if (ch1=='p'){
code1=41;
}
else if (ch1=='q'){
code1=42;
}
else if (ch1=='r'){
code1=43;
}
else if (ch1=='s'){
code1=44;
}
else if (ch1=='t'){
code1=45;
}
else if (ch1=='u'){
code1=46;
}
else if (ch1=='v'){
code1=47;
}
else if (ch1=='w'){
code1=48;
}
else if (ch1=='x'){
code1=49;
}
else if (ch1=='y'){
code1=50;
}
else if (ch1=='z'){
code1=51;
}
else if (ch1=='1'){
code1=52;
}
else if (ch1=='2'){
code1=53;
}
else if (ch1=='3'){
code1=54;
}
else if (ch1=='4'){
code1=55;
}
else if (ch1=='5'){
code1=56;
}
else if (ch1=='6'){
code1=57;
}
else if (ch1=='7'){
code1=58;
}
else if (ch1=='8'){
code1=59;
}
else if (ch1=='9'){
code1=60;
}
else if (ch1=='0'){
code1=61;
}
else if (ch1=='!'){
code1=62;
}
else if (ch1=='@'){
code1=63;
}
else if (ch1=='#'){
code1=64;
}
else if (ch1=='$'){
code1=65;
}
else if (ch1=='%'){
code1=66;
}
else if (ch1=='^'){
code1=67;
}
else if (ch1=='&'){
code1=68;
}
else if (ch1=='*'){
code1=69;
}
else if (ch1=='('){
code1=70;
}
else if (ch1==')'){
code1=71;
}
else if (ch1=='_'){
code1=72;
}
else if (ch1=='-'){
code1=73;
}
else if (ch1=='+'){
code1=74;
}
else if (ch1=='='){
code1=75;
}
else if (ch1=='?'){
code1=76;
}
else if (ch1=='<'){
code1=77;
}
else if (ch1=='>'){
code1=78;
}
else if (ch1==':'){
code1=79;
}
else if (ch1=='\\'){ // Escape Character \ needed to allow \ check
code1=80;
}
else if (ch1=='/'){
code1=81;
}
else if (ch1=='~'){
code1=82;
}
else if (ch1=='.'){
code1=83;
}
else if (ch1==','){
code1=84;
}
else if (ch1==';'){
code1=85;
}
else if (ch1=='\`'){ //Escape Character \ before ` to exit
run=0; //Run = False at 0 and leaves while loop
}
else {
cout<<"Invalid Input = No Match\n\n";
}
cout<<tab2[code1];
}


system("PAUSE");
return EXIT_SUCCESS;
}


unCrypt Version 1.02 source code

Code: [Select]#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
// 12/30/2015 - Added string random shuffle
// 12/31/2015 - Added custom seed for random shuffle so seed acts a crypt key
// 1/4/2016 - Added ability to enter string and have while loop process
// 1/5/2016 - Added inverse unCrypt array pairing between Alpha and Seeded Key
// 1/6/2015 - Added characters , and ; to supported characters to crypt
// 1/8/2015 - Source code trash cleanup & IF logic Array offset correction to remove -1 band aid
using namespace std;

int main(int argc, char *argv[])
{


int seed1=0;
int code1=0;
int run=1;
char ch1;
cout<<" unCrypt Version 1.02\n\n";
cout<<"XXXXXXXXXXXXXXXXXXXXX\n";
cout<<" Enter Integer Seed: \n"; // Asks user to input integer seed
cout<<"XXXXXXXXXXXXXXXXXXXXX\n\n";
cin >> seed1; // Input user seed
cout<<"\n\n"<<"unCrypt String Key =\n\n";


//Initialize Valid Characters for String Shuffle Output
//Note Bug corrected with blank space for \ by use of escape character proceeding
string str="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";
//String random comparison 1 for 1 match

//Pass static string list to array prior to shuffle
string tmp1 = str; //Pass str output to string tmp
char tab3[128]; // Memory Allocation for array population
strncpy(tab3, tmp1.c_str(), sizeof(tab3)); //string copy tmp into tab3 array
tab3[sizeof(tab3) - 1] = 0;


srand(seed1); // Allows user custom seeded starting algorithm position for random

random_shuffle(str.begin(), str.end()); // Shuffle the string
cout << str << "\n\n\n"; // Output the shuffle sequence

//Pass String Output into an array to pair up pointer value with associated character

string tmp = str; //Pass str output to string tmp
char tab2[128]; // Memory Allocation for array population
strncpy(tab2, tmp.c_str(), sizeof(tab2)); //string copy tmp into tab2 array
tab2[sizeof(tab2) - 1] = 0;

cout<<"Enter Info to unCrypt in correct case\n";
cout<<"To Exit Program Close Window or enter ` \n\n\n";

while(run==1){

cin>>ch1;

if (ch1==tab2[0]){
code1=0;
}
else if (ch1==tab2[1]){
code1=1;
}
else if (ch1==tab2[2]){
code1=2;
}
else if (ch1==tab2[3]){
code1=3;
}
else if (ch1==tab2[4]){
code1=4;
}
else if (ch1==tab2[5]){
code1=5;
}
else if (ch1==tab2[6]){
code1=6;
}
else if (ch1==tab2[7]){
code1=7;
}
else if (ch1==tab2[8]){
code1=8;
}
else if (ch1==tab2[9]){
code1=9;
}
else if (ch1==tab2[10]){
code1=10;
}
else if (ch1==tab2[11]){
code1=11;
}
else if (ch1==tab2[12]){
code1=12;
}
else if (ch1==tab2[13]){
code1=13;
}
else if (ch1==tab2[14]){
code1=14;
}
else if (ch1==tab2[15]){
code1=15;
}
else if (ch1==tab2[16]){
code1=16;
}
else if (ch1==tab2[17]){
code1=17;
}
else if (ch1==tab2[18]){
code1=18;
}
else if (ch1==tab2[19]){
code1=19;
}
else if (ch1==tab2[20]){
code1=20;
}
else if (ch1==tab2[21]){
code1=21;
}
else if (ch1==tab2[22]){
code1=22;
}
else if (ch1==tab2[23]){
code1=23;
}
else if (ch1==tab2[24]){
code1=24;
}
else if (ch1==tab2[25]){
code1=25;
}
else if (ch1==tab2[26]){
code1=26;
}
else if (ch1==tab2[27]){
code1=27;
}
else if (ch1==tab2[28]){
code1=28;
}
else if (ch1==tab2[29]){
code1=29;
}
else if (ch1==tab2[30]){
code1=30;
}
else if (ch1==tab2[31]){
code1=31;
}
else if (ch1==tab2[32]){
code1=32;
}
else if (ch1==tab2[33]){
code1=33;
}
else if (ch1==tab2[34]){
code1=34;
}
else if (ch1==tab2[35]){
code1=35;
}
else if (ch1==tab2[36]){
code1=36;
}
else if (ch1==tab2[37]){
code1=37;
}
else if (ch1==tab2[38]){
code1=38;
}
else if (ch1==tab2[39]){
code1=39;
}
else if (ch1==tab2[40]){
code1=40;
}
else if (ch1==tab2[41]){
code1=41;
}
else if (ch1==tab2[42]){
code1=42;
}
else if (ch1==tab2[43]){
code1=43;
}
else if (ch1==tab2[44]){
code1=44;
}
else if (ch1==tab2[45]){
code1=45;
}
else if (ch1==tab2[46]){
code1=46;
}
else if (ch1==tab2[47]){
code1=47;
}
else if (ch1==tab2[48]){
code1=48;
}
else if (ch1==tab2[49]){
code1=49;
}
else if (ch1==tab2[50]){
code1=50;
}
else if (ch1==tab2[51]){
code1=51;
}
else if (ch1==tab2[52]){
code1=52;
}
else if (ch1==tab2[53]){
code1=53;
}
else if (ch1==tab2[54]){
code1=54;
}
else if (ch1==tab2[55]){
code1=55;
}
else if (ch1==tab2[56]){
code1=56;
}
else if (ch1==tab2[57]){
code1=57;
}
else if (ch1==tab2[58]){
code1=58;
}
else if (ch1==tab2[59]){
code1=59;
}
else if (ch1==tab2[60]){
code1=60;
}
else if (ch1==tab2[61]){
code1=61;
}
else if (ch1==tab2[62]){
code1=62;
}
else if (ch1==tab2[63]){
code1=63;
}
else if (ch1==tab2[64]){
code1=64;
}
else if (ch1==tab2[65]){
code1=65;
}
else if (ch1==tab2[66]){
code1=66;
}
else if (ch1==tab2[67]){
code1=67;
}
else if (ch1==tab2[68]){
code1=68;
}
else if (ch1==tab2[69]){
code1=69;
}
else if (ch1==tab2[70]){
code1=70;
}
else if (ch1==tab2[71]){
code1=71;
}
else if (ch1==tab2[72]){
code1=72;
}
else if (ch1==tab2[73]){
code1=73;
}
else if (ch1==tab2[74]){
code1=74;
}
else if (ch1==tab2[75]){
code1=75;
}
else if (ch1==tab2[76]){
code1=76;
}
else if (ch1==tab2[77]){
code1=77;
}
else if (ch1==tab2[78]){
code1=78;
}
else if (ch1==tab2[79]){
code1=79;
}
else if (ch1==tab2[80]){ // Escape Character \ needed to allow \ check
code1=80;
}
else if (ch1==tab2[81]){
code1=81;
}
else if (ch1==tab2[82]){
code1=82;
}
else if (ch1==tab2[83]){
code1=83;
}
else if (ch1==tab2[84]){
code1=84;
}
else if (ch1==tab2[85]){
code1=85;
}
else if (ch1=='\`'){ //Escape Character \ before ` to exit
run=0; //Run = False at 0 and leaves while loop
}
else {
cout<<"Invalid Input = No Match\n\n";
}
cout<<tab3[code1]; // output
}

system("PAUSE");
return EXIT_SUCCESS;
}Looks cool although you would be much better off using some sort of map data structure instead of that massive block of else ifs. Alternatively you may be able to get creative with the character's ASCII value. This would make the code a lot neater and more compact.Good suggestion ...

Prior to coming up with what I came up with I was toying around with all sorts of dynamic methods of scrambled character substitution to try to make it work with less code, but while its really easy to scramble information with not many lines of code needed, being able to inverse that scramble and bring it back to its original form was tricky. So using 2 arrays one static and the other dynamic was the way to decrypt it back to its original form.

I almost went with SWITCHES instead of IF THEN ELSE, but from years of IF THEN ELSE logic, that method flows easy from brain to keys.

Tonight I was playing around with it writing a single lined entry to 2 files appended... a Key File and a Data File. And I thought all was well, BUT when looking further for some reason I am getting an additional write to file for the scrambled output so instead of an output of say 7*hY I am getting 7*hYY. My solution to fix this might be to have a counter that counts how many characters were entered and only allows the while loop to run equal to the character count. Or have a routine that reads in the last line and TRIMS off 1 character place. But these both seem like sloppy band aids. Its really strange that the output to display is correct without the extra character at the tail end, but the file write instruction processes writing the last character TWICE. This one has me slightly stumped because programmatically I dont see a flaw, but there is one.

Code: [Select]#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
// 12/30/2015 - Added string random shuffle
// 12/31/2015 - Added custom seed for random shuffle so seed acts a crypt key
// 1/4/2016 - Added ability to enter string and have while loop process v1.00
// 1/5/2016 - Added characters , and ; to supported characters which were missing from v1.01
// 1/8/2015 - Source code trash cleanup & offset band aid removed for IF statement logic +1 array offset v1.02
// 1/8/2015 - Added write to file for coded data storage eliminating need to copy/paste output to a text file v1.03
using namespace std;

int main(int argc, char *argv[])
{

int seed1=0;
int code1=0;
int run=1;
int again=1;
int test=1;
char ch1;
char ch2;


while(again==1){



cout<<" Crypt Version 1.03\n\n";
cout<<"XXXXXXXXXXXXXXXXXXXXX\n";
cout<<" Enter Integer Seed: \n"; // Asks user to input integer seed
cout<<"XXXXXXXXXXXXXXXXXXXXX\n\n";
cin >> seed1; // Input user seed
cout<<"\n\n"<<"Crypt String Key =\n\n";

ofstream myfile;
myfile.open ("Crypt103Key.txt", ios::out | ios::app);
myfile <<seed1<<"\n";
myfile.close();






//Initialize Valid Characters for String Shuffle Output
//Note Bug corrected with blank space for \ by use of escape character proceeding
string str="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";



srand(seed1); // Allows user custom seeded starting algorithm position for random

random_shuffle(str.begin(), str.end()); // Shuffle the string
cout << str << "\n\n\n"; // Output the shuffle sequence


//Pass String Output into an array to pair up pointer value with associated character

string tmp = str; //Pass str output to string tmp
char tab2[128]; // Memory Allocation for array population
strncpy(tab2, tmp.c_str(), sizeof(tab2)); //string copy tmp into tab2 array
tab2[sizeof(tab2) - 1] = 0;


cout<<"Enter Info to Crypt in correct case\n";
cout<<"To Exit Inner Program enter ( ` ) \n\n\n";

while(run==1){

cin>>ch1;

if (ch1=='A'){
code1=0;
}
else if (ch1=='B'){
code1=1;
}
else if (ch1=='C'){
code1=2;
}
else if (ch1=='D'){
code1=3;
}
else if (ch1=='E'){
code1=4;
}
else if (ch1=='F'){
code1=5;
}
else if (ch1=='G'){
code1=6;
}
else if (ch1=='H'){
code1=7;
}
else if (ch1=='I'){
code1=8;
}
else if (ch1=='J'){
code1=9;
}
else if (ch1=='K'){
code1=10;
}
else if (ch1=='L'){
code1=11;
}
else if (ch1=='M'){
code1=12;
}
else if (ch1=='N'){
code1=13;
}
else if (ch1=='O'){
code1=14;
}
else if (ch1=='P'){
code1=15;
}
else if (ch1=='Q'){
code1=16;
}
else if (ch1=='R'){
code1=17;
}
else if (ch1=='S'){
code1=18;
}
else if (ch1=='T'){
code1=19;
}
else if (ch1=='U'){
code1=20;
}
else if (ch1=='V'){
code1=21;
}
else if (ch1=='W'){
code1=22;
}
else if (ch1=='X'){
code1=23;
}
else if (ch1=='Y'){
code1=24;
}
else if (ch1=='Z'){
code1=25;
}
else if (ch1=='a'){
code1=26;
}
else if (ch1=='b'){
code1=27;
}
else if (ch1=='c'){
code1=28;
}
else if (ch1=='d'){
code1=29;
}
else if (ch1=='e'){
code1=30;
}
else if (ch1=='f'){
code1=31;
}
else if (ch1=='g'){
code1=32;
}
else if (ch1=='h'){
code1=33;
}
else if (ch1=='i'){
code1=34;
}
else if (ch1=='j'){
code1=35;
}
else if (ch1=='k'){
code1=36;
}
else if (ch1=='l'){
code1=37;
}
else if (ch1=='m'){
code1=38;
}
else if (ch1=='n'){
code1=39;
}
else if (ch1=='o'){
code1=40;
}
else if (ch1=='p'){
code1=41;
}
else if (ch1=='q'){
code1=42;
}
else if (ch1=='r'){
code1=43;
}
else if (ch1=='s'){
code1=44;
}
else if (ch1=='t'){
code1=45;
}
else if (ch1=='u'){
code1=46;
}
else if (ch1=='v'){
code1=47;
}
else if (ch1=='w'){
code1=48;
}
else if (ch1=='x'){
code1=49;
}
else if (ch1=='y'){
code1=50;
}
else if (ch1=='z'){
code1=51;
}
else if (ch1=='1'){
code1=52;
}
else if (ch1=='2'){
code1=53;
}
else if (ch1=='3'){
code1=54;
}
else if (ch1=='4'){
code1=55;
}
else if (ch1=='5'){
code1=56;
}
else if (ch1=='6'){
code1=57;
}
else if (ch1=='7'){
code1=58;
}
else if (ch1=='8'){
code1=59;
}
else if (ch1=='9'){
code1=60;
}
else if (ch1=='0'){
code1=61;
}
else if (ch1=='!'){
code1=62;
}
else if (ch1=='@'){
code1=63;
}
else if (ch1=='#'){
code1=64;
}
else if (ch1=='$'){
code1=65;
}
else if (ch1=='%'){
code1=66;
}
else if (ch1=='^'){
code1=67;
}
else if (ch1=='&'){
code1=68;
}
else if (ch1=='*'){
code1=69;
}
else if (ch1=='('){
code1=70;
}
else if (ch1==')'){
code1=71;
}
else if (ch1=='_'){
code1=72;
}
else if (ch1=='-'){
code1=73;
}
else if (ch1=='+'){
code1=74;
}
else if (ch1=='='){
code1=75;
}
else if (ch1=='?'){
code1=76;
}
else if (ch1=='<'){
code1=77;
}
else if (ch1=='>'){
code1=78;
}
else if (ch1==':'){
code1=79;
}
else if (ch1=='\\'){ // Escape Character \ needed to allow \ check
code1=80;
}
else if (ch1=='/'){
code1=81;
}
else if (ch1=='~'){
code1=82;
}
else if (ch1=='.'){
code1=83;
}
else if (ch1==','){
code1=84;
}
else if (ch1==';'){
code1=85;
}
else if (ch1=='\`'){ //Escape Character \ before ` to exit
run=0; //Run = False at 0 and leaves while loop
}
else {
cout<<"Invalid Input = No Match\n\n";
}
cout<<tab2[code1];




myfile.open ("Crypt103Data.txt", ios::out | ios::app);
myfile <<tab2[code1];
myfile.close();

}// end inner while loop
//Add line return in file to seperate the data per line
myfile.open ("Crypt103Data.txt", ios::out | ios::app);
myfile <<" "<<"\n";
myfile.close();
test=1;
while(test==1){
system("CLS");
cout<<"Enter Y to continue or N to end \n\n\n";
cin>>ch2;
if (ch2=='N'||ch2=='n'){
again=0;
test=0;
}
else if (ch2=='Y'||ch2=='y'){
again=1;
test=0;
run=1;
system("CLS");
}
else {
cout<<"Invalid Input, please choose Y or N \n\n";
test=1;
}
}


} // end outter while loop

system("CLS");
system("PAUSE");
return EXIT_SUCCESS;
}
It would be possible to replace the else if portions dealing with alphabetic characters with some math.

Upper case characters are codes 65 to 90. Your codes start at 0, so all the blocks testing capital characters can be replaced:

Code: [Select]if(ch >= 65 && ch <= 90)
{
code1 = ch-65;
}
for lowercase characters, they span from 97 through 122, and your cipher maps them at 26:

Code: [Select]else if (ch1 >= 97 && ch1 <= 122)
{
code1 = ch1 - 71;
}
Thanks BC for your input on this... that got me thinking of back in the days many years ago with GW-Basic I used Chr$(ascii_value). http://www.antonis.de/qbebooks/gwbasman/chrs.html And I guess I am reinventing the wheel by assigning my own values to the characters, when I should just be using their already existing ascii identifier which I can get from casting char to an int.

Found this info here that is a big help too, and will correct for the fact that spaces are not accounted for on entry of what is to get scrambled and character substitution.

http://stackoverflow.com/questions/6405137/asc-and-chr-equivalent-in-c-c

output is:
Quote
string = "Hello, World!"
chars = 72 101 108 108 111 44 32 87 111 114 108 100 33

Also found more info here on the code example you gave me:
http://stackoverflow.com/questions/5029840/convert-char-to-int-in-c-and-cFound and fixed the additional character write problem I had. I thought of suppressing the write to file until the start of the first iteration of the loop in which write enable is enabled for the write function. This fixes the issue where upon exit by use of the ( ` ) key it does not write the last character twice appended to the text file.

Now that I have this fixed I can go back and clean up the IF logic mess. And make this program about 80% smaller in size.

The double write bug was really driving me up the wall when it made no sense as to why it was happening. So I decided to force the write to file prior to the ( ` ) exit instruction so that it will exit the loop without passing the write to file instruction before leaving the while loop in which its writing the last input from the input buffer and that idea worked. However I had to suppress writing to file until the characters processed went through the logic otherwise I had a leading array[0] value write to file and it added the first character within the array at the beginning of the file appended. So by this write to file only being enabled after the input was processed through the IF logic, but not after the exit instruction, by use of a write enable flag to start the write enable for the write to file instruction. That fixed it.

Prior to bug fix if you used a seed key value of 43 and entered Hello_World you would get AW\\^nY^H\22 and now with bug fix I get the correct information written to file of AW\\^nY^H\2 ( single last character appended vs double last character appended )


Quote
//supress write to file until 1 loop run ( bug fix for double character write )
if(writeenable==1){
myfile.open ("Crypt104Data.txt", ios::out | ios::app);
myfile <<tab2[code1];
myfile.close();
}
else{
//do nothing and continue
}
writeenable=1; //enable write to file



Code: [Select]#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
// 12/30/2015 - Added string random shuffle
// 12/31/2015 - Added custom seed for random shuffle so seed acts a crypt key
// 1/4/2016 - Added ability to enter string and have while loop process v1.00
// 1/5/2016 - Added characters , and ; to supported characters which were missing from v1.01
// 1/8/2016 - Source code trash cleanup & offset band aid removed for IF statement logic +1 array offset v1.02
// 1/8/2016 - Added write to file for coded data storage eliminating need to copy/paste output to a text file v1.03
// 1/15/2016 - Fixed Loop writing duplicate character on ( ` ) loop exit with write delay until loop processed prior to write
// - seed of 43 with Hello_World was producing AW\\^nY^H\22 prior when it should only be AW\\^nY^H\2 with a single 2
// - at tail end of write process.
using namespace std;

//int main(int argc, char *argv[])
int main ()
{

int seed1=0;
int code1=0;
int run=1;
int again=1;
int test=1;
int writeenable=0;
char ch1;
char ch2;

while(again==1){

cout<<" Crypt Version 1.04\n\n";
cout<<"XXXXXXXXXXXXXXXXXXXXX\n";
cout<<" Enter Integer Seed: \n"; // Asks user to input integer seed
cout<<"XXXXXXXXXXXXXXXXXXXXX\n\n";
cin >> seed1; // Input user seed
cout<<"\n\n"<<"Crypt String Key =\n\n";

ofstream myfile;
myfile.open ("Crypt104Key.txt", ios::out | ios::app);
myfile <<seed1<<"\n";
myfile.close();

//Initialize Valid Characters for String Shuffle Output
//Note Bug corrected with blank space for \ by use of escape character proceeding
string str="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";


srand(seed1); // Allows user custom seeded starting algorithm position for random

random_shuffle(str.begin(), str.end()); // Shuffle the string
cout << str << "\n\n\n"; // Output the shuffle sequence

//Pass String Output into an array to pair up pointer value with associated character

string tmp = str; //Pass str output to string tmp
char tab2[128]; // Memory Allocation for array population
strncpy(tab2, tmp.c_str(), sizeof(tab2)); //string copy tmp into tab2 array
tab2[sizeof(tab2) - 1] = 0;

cout<<"Enter Info to Crypt in correct case\n";
cout<<"To Exit Inner Program enter ( ` ) \n\n\n";

while(run==1){

cin>>ch1;
//supress write to file until 1 loop run ( bug fix for double character write )
if(writeenable==1){
myfile.open ("Crypt104Data.txt", ios::out | ios::app);
myfile <<tab2[code1];
myfile.close();
}
else{
//do nothing and continue
}
writeenable=1; //enable write to file

if (ch1=='A'){
code1=0;
}
else if (ch1=='B'){
code1=1;
}
else if (ch1=='C'){
code1=2;
}
else if (ch1=='D'){
code1=3;
}
else if (ch1=='E'){
code1=4;
}
else if (ch1=='F'){
code1=5;
}
else if (ch1=='G'){
code1=6;
}
else if (ch1=='H'){
code1=7;
}
else if (ch1=='I'){
code1=8;
}
else if (ch1=='J'){
code1=9;
}
else if (ch1=='K'){
code1=10;
}
else if (ch1=='L'){
code1=11;
}
else if (ch1=='M'){
code1=12;
}
else if (ch1=='N'){
code1=13;
}
else if (ch1=='O'){
code1=14;
}
else if (ch1=='P'){
code1=15;
}
else if (ch1=='Q'){
code1=16;
}
else if (ch1=='R'){
code1=17;
}
else if (ch1=='S'){
code1=18;
}
else if (ch1=='T'){
code1=19;
}
else if (ch1=='U'){
code1=20;
}
else if (ch1=='V'){
code1=21;
}
else if (ch1=='W'){
code1=22;
}
else if (ch1=='X'){
code1=23;
}
else if (ch1=='Y'){
code1=24;
}
else if (ch1=='Z'){
code1=25;
}
else if (ch1=='a'){
code1=26;
}
else if (ch1=='b'){
code1=27;
}
else if (ch1=='c'){
code1=28;
}
else if (ch1=='d'){
code1=29;
}
else if (ch1=='e'){
code1=30;
}
else if (ch1=='f'){
code1=31;
}
else if (ch1=='g'){
code1=32;
}
else if (ch1=='h'){
code1=33;
}
else if (ch1=='i'){
code1=34;
}
else if (ch1=='j'){
code1=35;
}
else if (ch1=='k'){
code1=36;
}
else if (ch1=='l'){
code1=37;
}
else if (ch1=='m'){
code1=38;
}
else if (ch1=='n'){
code1=39;
}
else if (ch1=='o'){
code1=40;
}
else if (ch1=='p'){
code1=41;
}
else if (ch1=='q'){
code1=42;
}
else if (ch1=='r'){
code1=43;
}
else if (ch1=='s'){
code1=44;
}
else if (ch1=='t'){
code1=45;
}
else if (ch1=='u'){
code1=46;
}
else if (ch1=='v'){
code1=47;
}
else if (ch1=='w'){
code1=48;
}
else if (ch1=='x'){
code1=49;
}
else if (ch1=='y'){
code1=50;
}
else if (ch1=='z'){
code1=51;
}
else if (ch1=='1'){
code1=52;
}
else if (ch1=='2'){
code1=53;
}
else if (ch1=='3'){
code1=54;
}
else if (ch1=='4'){
code1=55;
}
else if (ch1=='5'){
code1=56;
}
else if (ch1=='6'){
code1=57;
}
else if (ch1=='7'){
code1=58;
}
else if (ch1=='8'){
code1=59;
}
else if (ch1=='9'){
code1=60;
}
else if (ch1=='0'){
code1=61;
}
else if (ch1=='!'){
code1=62;
}
else if (ch1=='@'){
code1=63;
}
else if (ch1=='#'){
code1=64;
}
else if (ch1=='$'){
code1=65;
}
else if (ch1=='%'){
code1=66;
}
else if (ch1=='^'){
code1=67;
}
else if (ch1=='&'){
code1=68;
}
else if (ch1=='*'){
code1=69;
}
else if (ch1=='('){
code1=70;
}
else if (ch1==')'){
code1=71;
}
else if (ch1=='_'){
code1=72;
}
else if (ch1=='-'){
code1=73;
}
else if (ch1=='+'){
code1=74;
}
else if (ch1=='='){
code1=75;
}
else if (ch1=='?'){
code1=76;
}
else if (ch1=='<'){
code1=77;
}
else if (ch1=='>'){
code1=78;
}
else if (ch1==':'){
code1=79;
}
else if (ch1=='\\'){ // Escape Character \ needed to allow \ check
code1=80;
}
else if (ch1=='/'){
code1=81;
}
else if (ch1=='~'){
code1=82;
}
else if (ch1=='.'){
code1=83;
}
else if (ch1==','){
code1=84;
}
else if (ch1==';'){
code1=85;
}
else if (ch1=='\`'){ //Escape Character \ before ` to exit
run=0; //Run = False at 0 and leaves while loop
}
else {
cout<<"Invalid Input = No Match\n\n";
}

// Display output
cout<<tab2[code1];

}// end inner while loop

test=1;
while(test==1){
system("CLS");
cout<<"Enter Y to continue or N to end \n\n\n";
cin>>ch2;
if (ch2=='N'||ch2=='n'){
// line return to file ( formatting purposes )
myfile.open ("Crypt104Data.txt", ios::out | ios::app);
myfile <<"\n";
myfile.close();
again=0;
test=0;
}
else if (ch2=='Y'||ch2=='y'){
// line return to file ( formatting purposes )
myfile.open ("Crypt104Data.txt", ios::out | ios::app);
myfile <<"\n";
myfile.close();
again=1;
test=0;
run=1;
writeenable=0; //reset write enable to start of 0
system("CLS");
}
else {
cout<<"Invalid Input, please choose Y or N \n\n";
test=1;
}
}


} // end outter while loop

system("CLS");
system("PAUSE");
//return EXIT_SUCCESS;
return(0);
}
1862.

Solve : Powershell Regular expression to replace part of a file name?

Answer»

Rename FILES using regex in powershell I need a REGULAR EXPRESSION to identify the season and episode. I'm horrible with regular expressions

file name formats:
"something - 01x01a - something.ext" should be "something - S01E01 - something.ext"
"something - 01x01b - something.ext" should be "something - S01E02 - something.ext"
"something - 01x01c - something.ext" should be "something - S01E03 - something.ext"
"something - 01x02a - something.ext" should be "something - S01E04 - something.ext"
"something - 01x02b - something.ext" should be "something - S01E05 - something.ext"
...
"something - 02x01a - something.ext" should be "something - S02E01 - something.ext"
"something - 02x01b - something.ext" should be "something - S02E02 - something.ext"
"something - 02x01c - something.ext" should be "something - S02E03 - something.ext"
"something - 02x02a - something.ext" should be "something - S02E04 - something.ext"
"something - 02x02b - something.ext" should be "something - S02E05 - something.ext"
...
and so on

So I want to keep the part before the "x" (Season) and rename the part after the "x" (Episode), more so increment the value by 1 per season
Using RegEx in any language can be a challenge. I stored your posted data in a file (Media.txt). The output of the script is also a file (Media.final). Best to PUT script and data file in same folder but if not you can tweak the script as needed. Note the continuation character at the end of the first two lines.

Code: [Select]Set-Content -Path .\Media.new -value ((get-content .\Media.txt) `
-replace '^(.*?)( - )(.*)', '$1$2S$3' `
-replace '^(.*?)(x)([0-9]{2})([a-z])(.*)', '$1E$3$5')

$epi = 0
$ssn = 0

Get-Content .\Media.new |
Select-String -pattern '^(?<begin>.*?S)(?<ssn>[0-9]{2})(?<bigE>[a-z])(?<epi>[0-9]{2})(?<end>.*)' |
Select-Object -ExpandProperty Matches |
ForEach-Object {
if ( $_.groups["ssn"].value -NE $ssn ) {
$epi = 0
$ssn = $_.groups["ssn"].value
}
$print = "{0:D2}" -f ($epi += 1)
($_.groups["begin"], $_.groups["ssn"], $_.groups["bigE"], $print, $_.groups["end"]) -join "" |
Out-File -FilePath .\Media.final -Append -Encoding ascii
}

Remove-Item -Path .\Media.new

Good luck.

1863.

Solve : need help w/captcha?

Answer»

Quote

I need help with this Captcha code. when I try it, all I get is code,
starting with

"captcha_varname='$captcha_var_name';" through "?>"

It's like my Php wasn't working but I've confirmed it is. I'm hoping

someone will tell me why. Following is my code COPIED FROM ONLINE:

Code: [Select]<?PHP
// simple-captcha.php
class FGSimpleCaptcha extends FG_CaptchaHandler;
{
var $error_str;
var $captcha_varname;
var $uniquekey;

function FGSimpleCaptcha($captcha_var_name)
{
$this->captcha_varname='$captcha_var_name'; // ?

$this->uniquekey='abc12fghijkl34mno;
}
/*Add more simple QUESTIONS here.*/
function GetSimpleCaptcha()
{
$arrQuestions = array(
"Which of SOCK, library, cake or red is a color? "=>"red",
"Enter the number thirteen thousand THREE hundred and SIXTY eight in

digits: "=>"13,368");

$question = array_rand($arrQuestions);
$answer = $arrQuestions[$question];

$_SESSION['FGCF_Captcha_Answer'] = $this->Md5CaptchaAnswer

($answer);

return $question;
}
function SetFormKey($key)
{ $this->uniquekey = $key; }
function GetKey()
{ return $this->uniquekey; }
function Validate()
{
$ret=false;
if(empty($_POST[$this->captcha_varname]))
{
$this->error_str = "Please answer the anti-spam question";
$ret = false;
}
else
{

$scaptcha = trim($_POST[$this->captcha_varname]);

$scaptcha = strtolower($scaptcha);

$user_answer = $this->Md5CaptchaAnswer($scaptcha);

if($user_answer != $_SESSION['FGCF_Captcha_Answer'])
{
$this->error_str = "Failed the anti-spam check!";
$ret = false;
}
else
{ $ret = true; }
}
//else
return $ret;
}
function Md5CaptchaAnswer($answer)
{ return md5($this->GetKey().$answer); }
function GetError()
{ return $this->error_str; }
}
?>[/b]First:
captcha
https://en.wikipedia.org/wiki/CAPTCHA
Quote
"Completely Automated Public Turing test to tell Computers and Humans Apart") is a TYPE of challenge-response test used in computing to determine whether or not the user is human.
Also:
http://www.captcha.net/

Rather than do it yourself, you can get an code thing from Google or others that lets you put a GOTCHA in your web page.

Are you doing this inside of a specific application?
1864.

Solve : LIFE SIMULATION?

Answer»

I would like to be able to MAKE a simulation of the town I live in.
Using realistic economy to what it costs to live here.
Afterwards, I would like to make it with information from job sites and
housing real estate sites, as well as trans portion information to get around.
Athletics and school as well.

My first intention is for fun.
The second intention for the second sim, is to enable people to find everything
for living in my town all in one site.

I live in Dayton,OH . So I think i would like to CALL the site RUNDYT.com
as a play on RUNDMC

My question now is, where do I start to make this as a website at first and then possibly a PHONE application.
What and where do I find information to begin with this??First you will want to go to godaddy or some other domain name register to secure your domain. It might have already been taken.

Do you have any programming skills to program this yourself or is this something you will need others to program for you?

The census for your town as well as google has lots of info for most towns that show info. You will need to have approved RIGHTS to the data that your using unless its actually public domain classified information that anyone can get without permissions granted.

This sounds like a very large project and you will want to have some money to throw at this project as well as if you can program it yourself it would be the cheapest, but if you need someone else to program it up it could easily cost upwards of $50,000 DEPENDING on how in depth the programming gets. I have doubts that you would find anyone to program this up for free. However you might be able to locate a career programmer and work out a deal in which they get a royalty for any money generated from their code.

Personally its a neat project idea, but information you will have will probably be just a consolidation of information already available on Google, in which you have to worry about disclosure and permissions of others information that you use as your own to avoid getting sued. If you plan on making any money on this, I would say its high risk for failure to take a loss. If you plan on making money on this how are you going to generate revenue? ( Ad supported, or membership fee, or per use fee, or other? )

The easiest setup would be a online calculator that has fields to be populated and then formulas based off of census info for the town. Then in the end it shows a report of some sort with whatever info your trying to provide.

As far as an actual SIM goes, if your looking to run it with algorithms and such that have formulas that are dynamic and info provided dynamic within limits its going to get very complicated. The easiest to program up would be an online calculator, but to have a sim that shows how one thing would affect other things etc to project assumptions based on prior data available. That is when it gets complicated.

1865.

Solve : Long Long INT - maxes out at 999,999,999 ??

Answer»

Found an interesting problem with a program I wrote. If I use a value greater than 999,999,999 for a long long int it acts like an overflow to the int and the program freaks out. long long int has/(should have) a range of: –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 ..... 19 digit places, whereas the program is failing as if there is an overflow with more than 9 digits.

Was curious if this is a BUG with the IDE or some other issue that I am not aware of. I'm using Bloodshed Dev C++ 4.9.9.2. More info on the ranges for VARIABLES listed at the link.

https://msdn.microsoft.com/en-us/library/s3f49ktz.aspx

The program has all integers that are to interact with the long long int set to long long so that I dont overflow a standard int. So I know its not a mistake of passing a long long int value to a standard int with only a range of –2,147,483,648 to 2,147,483,647 by which even a standard int shouldn't be exceeded either as for I am 1,147,483,648 away from the standard signed int limit at 999,999,999

The CODE is in C++ and has a while loop and the value of the long long is passed to srand(seed). So maybe 999,999,999 is the limit for seeded random?

However looking here it shows that it should go beyond the 999,999,999 limit that I am hitting. If I pass 1,000,000,000 to it the program malfunctions as if its an overflow. http://en.cppreference.com/w/cpp/numeric/random/randIt is a compiler issue. The workaround is to make your own compiler.
Or do it in assembly.
Wait... did you conform to this?
https://gcc.gnu.org/onlinedocs/gcc/Long-Long.html
Quote


Next: Complex, Previous: __int128, Up: C Extensions
6.9 Double-Word Integers

ISO C99 supports data types for integers that are at least 64 bits wide, and as an extension GCC supports them in C90 mode and in C++. Simply write long long int for a signed integer, or unsigned long long int for an unsigned integer. To make an integer constant of type long long int, ADD the suffix ‘LL’ to the integer. To make an integer constant of type unsigned long long int, add the suffix ‘ULL’ to the integer.

You can use these types in arithmetic like any other integer types. Addition, subtraction, and bitwise boolean operations on these types are open-coded on all types of machines. Multiplication is open-coded if the machine supports a fullword-to-doubleword widening multiply instruction. Division and shifts are open-coded only on machines that provide special support. The operations that are not open-coded use special library routines that come with GCC.

There may be pitfalls when you use long long types for function arguments without function prototypes. If a function expects type int for its argument, and you pass a value of type long long int, confusion results because the caller and the subroutine disagree about the number of bytes for the argument. Likewise, if the function expects long long int and you pass int. The best way to avoid such problems is to use prototypes.

Geek thanks for sharing what you shared, it pointed me to LL suffix which helped point out the issue.

http://stackoverflow.com/questions/1458923/long-long-in-c-c

Now its going to be interesting with a counter++; as to if I need to concatenate the LL suffix before use. The counter starts at 0 and at 1,000,000,000 was when the program would fail going past the last value of 999,999,999 which was ok without the LL suffix. The while loop might be ok with it since its looking for a constant before exiting, but value passed to SRAND(seed) I wonder if I will need to concatenate and then cast it to seed to retain the LL suffix as for obviously the language itself doesnt do this automatically at 1,000,000,000, and I would need an IF statement that when the counter value reached 1,000,000,000 it is required that it add the LL suffix. WOW What a mess!

Quote
counter++; //This works until 1,000,000,000 is reached

Might need to add code to add the LL suffix for a dynamic value...

Quote
IF(counter>=1000000000LL){
// concatenate incremented value with LL suffix
}
else{
// do nothing until 1,000,000,000 is reached
}
Ok found my problem.... Typo in code. You dont need to add suffix to counters dynamic value. It works beyond 999,999,999 now with the LL used for while loop constant that its looking to reach

Code: [Select]long long int = 999999999;

while(counter<=1000000010LL){
counter++;
COUT<<"Counter = "<<counter;
}
And this warning below is seen if tying to set the while loop to 1,000,000,000 or larger without the LL suffix and compiling.

Quote
13:20 C:\cpp\run1.cpp [Warning] integer constant is too large for its type

Quote
counter = 999999999
counter = 1000000000
counter = 1000000001
counter = 1000000002
counter = 1000000003
counter = 1000000004
counter = 1000000005
counter = 1000000006
counter = 1000000007
counter = 1000000008
counter = 1000000009
counter = 1000000010
1866.

Solve : Batch - Match files and folders by filename?

Answer»

Hi experts,

Im in COMPLETE need of some urgent help.

Okay so I'm a complete noob at batch programming but I have not found a SOFTWARE tool that can do exactly what I need so I´m THINKING a small batch program might be what I need.

I have a folder containing 210 files named: 0_107, 1_107, 2_107 etc. up to 209_107.

I then have another folder which contain 210 subfolders named: 0, 1,2 etc. up to 209.

I want to move 0_107 into folder 0 and 1_107 into folder 1 and so forth.

I have tried using the software tool RoboBasket but this would require med to create 210 rules and I might need to do this multiple times so this is not desirable.

Can anyone help me to create this small batch file ? - keep in mind I have no knowledge of batch programming

Thanks in advance and best regards
Have you already seen this?
https://www.youtube.com/watch?v=X-AoDwMIZN4
The video shows how to move files with RoboBasket
Quote from: Geek-9pm on February 29, 2016, 03:24:17 PM

Have you already seen this?
https://www.youtube.com/watch?v=X-AoDwMIZN4
The video shows how to move files with RoboBasket

Oh yea - as far as I can see he moves the files based on the file extension. This is not possible for me as I need to move them by filename. Now this would require me to create 210 rules and im not so glad about that solution
1867.

Solve : powershell hash table editing?

Answer»

I'm WORKING on a powershell script that will walk through my network and get file version info on a few programs and want to add the computer name to the hash table for easier reviewing.
Here's what I'm using at the moment:

Code: [Select]$office = (get-childitem "\\$pc\C$\Program FILES (x86)\Microsoft Office\" -recurse -filter "excel.exe" ).VersionInfo
$office | select FileName, FileDescription, ProductMajorPart | ft -autosize
I want to add a column in the hash table to show the computer name, but am having trouble figuring out how to edit hashtables.
Any help would be appreciated. Thanks.I figured out something a little easier to work with. I CREATED a New-Object that I used to save the info I wanted from the Get-ChildName.
So, instead of the code above, it looks like this:

Code: [Select]$PCName = "test"
$a = (Get-ChildItem "\\$PCName\C$\Program Files (x86)\Microsoft Office\" -Recurse -Filter "excel.exe").VersionInfo
$pn = $office.ProductName
$PV = $office.ProductMajorPart
$pcinfo = New-Object psobject -Property @{""COMPUTERNAME"="$PCName"; "ProductName"="$pn";"ProductVersion"="$pv"}
$pcinfo +=$AllInfo


1868.

Solve : Batch file help - Start /w does not continue?

Answer»

I am not a programmer, however I am a technical writer and understand "some" code.

I am using Windows 7 and have a high end machine with 64 GB memory.

I am running a simple batch file that uses START /W to start a cmd file. It is important that the file finished before it continues executing the batch file. Start /w stops the batch file from continuing but it does not recognize when the cmd is finished. Consequently, The batch file is never continued.

I have tried START /w and START /wait. Neither works.
How do I make the batch file understand when the cmd file is done.

This batch file is intended to start a series of backup programs and record the time and date that each backup was completed by creating an empty folder at the top of each directory backed up. It is important the the empty directory is not created until the backup is finished.

Below is the test code for my batch file.

ECHO ON
CD /d C:\Temp
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"
CD /d D:\
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

REM 00-Backup-JFileSync is the directory where the backup PROGRAM is located
CD D:\00-Backup-JFileSync

Start /w 00-CTempTest
CD D:\000-BackupTest
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

CD D:\00-Backup-JFileSync
Start /w 00-BackupTestDtoZ

CD D:\
RD "$LAST BACKUP FINISHED"
MD "$LAST BACKUP FINISHED"

Thank you in advance for your help.

JimStart command will send the instruction to start and move on. If you want to wait for the 00-CTempTest to start and complete before moving on to CD D:\000-BackupTest then simply REMOVE the start instruction and it will not continue until that program has ended with the rest of the batch instruction. Assuming its an EXE your calling this is what might WORK. OR if you do want it to start /w you will need to specify the file extension in its name which could be the problem as well. So if its an EXE add the .exe because otherwise the OS doesnt know what 00-CTempTest and 00-BackupTestDtoZ is and it will fail. Also you want these programs to be in the same folder or directory of that of the batch file to run so it will find them. Although if you dont want the programs to reside in same folder or directory of the batch, then I would suggest full pathing used such as Start /w D:\00-Backup-JFileSync\00-CTempTest.exe to explicitly target the executable vs treeing down to it within batch.

Quote

ECHO ON
CD /d C:\Temp
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"
CD /d D:\
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

REM 00-Backup-JFileSync is the directory where the backup program is located
CD D:\00-Backup-JFileSync

Start /w 00-CTempTest.exe
CD D:\000-BackupTest
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

CD D:\00-Backup-JFileSync
Start /w 00-BackupTestDtoZ.exe

CD D:\
RD "$LAST BACKUP FINISHED"
MD "$LAST BACKUP FINISHED"



OR



Quote
ECHO ON
CD /d C:\Temp
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"
CD /d D:\
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

REM 00-Backup-JFileSync is the directory where the backup program is located
CD D:\00-Backup-JFileSync

00-CTempTest.exe
CD D:\000-BackupTest
RD "$LAST BACKED UP"
MD "$LAST BACKED UP"

CD D:\00-Backup-JFileSync
00-BackupTestDtoZ.exe

CD D:\
RD "$LAST BACKUP FINISHED"
MD "$LAST BACKUP FINISHED"
Answered on Dostips.
http://www.dostips.com/forum/viewtopic.php?f=3&t=6943
1869.

Solve : Just sharing a test project as part of my other project?

Answer»

Decided to share a test project which is part of the crypt project. I was curious if there was a SEED value that would spit out the same output as the input, since its possible but not very probable for a shuffle to be shuffled back to its original form. If the output matches the original input the program will stop at that value in which a match was found. So far no matches up to 100 Billion seed keys. I will probaby also have no matches as well to 1 Trillion. I am not going to GO beyond 1 Trillion seed values. After that its just a waste of electric.

Crunching the string compares after randomization of one of the strings using my AMD FX8350 4000Mhz system and I split the programs span into 8 groups so that the single threaded execution would each be assigned to 1 of the 8 cores.

Below is the info I got for how long it took to process the keys. The Keys are long long integer seed values.

Crunch Keys for 1 to 10 Billion Combinations
*Took about 2 hours 28 minutes to COMPLETE on AMD FX8350 4000Mhz
with each core solving 1.25 Billion Problems.

Started on Tue 01/26/2016 at 14:24:10.39
Ended on Tue 01/26/2016 at 16:52:05.71

Crunch Keys for 10 to 100 Billion Combinations
*Took about 17 hours 35 minutes to complete on AMD FX8350 4000Mhz
with each core solving 12.5 Billion Problems

Started on Tue 01/26/2016 at 15:12:55.56
Ended on Wed 01/27/2016 at 8:47:31.22

Crunch Keys for 100 Billion to 1 Trillion Combinations

*estimation ... will take 7.3 days to complete on AMD FX8350 4000Mhz
with each core solving 125 Billion Problems. Still running until next week this time at full bore 100% CPU use and nothing else running to waste CPU cycles offline.

Here is the code I have running.

Code: [Select]#include <iostream>
#include <string>


int delay;
long long int counter1=875000000000LL; // Add LL beyond 9 digits
long long int endcount=999999999999LL; // while loop end counter
long long int match=0;
long long int nomatch=0;
long long int seed1=0;

int main ()
{

std::string str="[emailprotected]#$%^&AMP;*()_-+=?<>:\\/~.,;";
std::string str2="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";
system("@echo. Started on %date% at %time%>>Log8R3.txt");
system("color f0");
std::cout<<"Running Please Wait...\n";
while(counter1<=endcount){

seed1=counter1;

srand(seed1);

random_shuffle(str.begin(), str.end()); // Shuffle the string


if (str.compare(str2) != 0){
//std::cout <<"counter= "<<counter1<<" "<< str << " is not " << str2 << '\n';
//std::cout<<"counter = "<<counter1<<" \n";
nomatch++;
//std::cin>>delay;
}
else{
std::cout<<"counter= "<<counter1<<" - Match Found\n";
match++;
std::cin>>delay;
}
counter1++;
}
std::cout<<"Match = "<<match<<"\n";
std::cout<<"No Match = "<<nomatch<<"\n";
system("@echo. Ended on %date% at %time%>>Log8R3.txt");
std::cin>>delay;
return 0;
}

1870.

Solve : Memory Leak??

Answer»

Well I ran a test against my code to throw 1 Trillion keys at it to make sure that I would not have a key that when used would output the same characters as the input for a crypto program I have been playing with and building upon. The AMD-FX-8350 at 4000Mhz took 7 days to complete 1 Trillion key tests with string compares with each core crunching 125 Billion Key tests, but what caught my eye is that the system memory showed that only 260MB was free of 8GB DDR3 1600mhz RAM. When I started the program last week only about 1.5GB of 8GB was in use, and the system was offline just used to crunch the project that I threw at it with 8 programs running 12.5% of 1 Trillion keys each to make use of all cores as 8 individual threads.

Looking in task manager it showed that svchost.exe using 6GB of the 8GB and other services using up the other 1.6GB of RAM. Ran a virus scan against system even though I know that its clean, and it came up clean. Rebooted system for first time in a week and it went back to normal with a little over 1GB in use at idle and almost 7GB free.

Curious if this is a memory leak in my program that I wrote, but if a memory leak I would expect it to free up the memory upon exiting the 8 instances of the program that I wrote. In my program all variables are initialized and I am not using anything improper, although I do use some system calls, but I've used them for years without any problems. Only thing I did different in this program than others in past that I have written is add a display trip to show status at every millionth counter tick of display to show the counter value. I wanted to know where the programs were at with a progress indicator, but showing a constant print to display cripples performance heavily so with a single print to display of the status every 1 millionth tick, I was able to know where the programs were at and how far away from completion without crippling performance.

Just out of curiosity I made a copy of this program without the while loop millionth print status to print status for every iteration and compiled that and ran both of them together side by side and the program that constantly prints to display status was so incredibly slow than the one that showed only every millionth tick. I then laughed at how many movies you watch where they show a hacker hitting a security of some sort with a counter LIKE program attack with scrolling digits or alpha of all the keys its trying super fast, and realized that the best one would be one that didnt print to display until a match was found. But that I guess would make for a boring few minutes of a movie whereas scrolling digits or alpha has the better visual effect.

Additionally although I wasted 7 days testing for an exact match between the starting string and the seeded random shuffle which didnt exist, but COULD have. It wasnt a waste because I made use of this test and implemented a test instruction into my main program to test for a match and reject use of a bad (WEAK) key. Additionally I also added a string compare instruction that instead of the user entering a key of their choice you can specify how strong of a shuffle you want, such as no characters would ever line up with their original character or allow a certain number of them to be the same with others far from their original form. This then spawned off the curiosity as to even if not a 85 for 85 character match, just how CLOSE of an exact match is there between the original string and the shuffled output string, and out of 85 possible characters, very few shuffles end up with more than 10 characters the same between the original string and the shuffled output. To compare for the original string and the output I am using a counter and comparing str[counter] against str2[counter] which performs a string compare from array to array for each element against each other of the same element location within array.


Code: [Select]#include <iostream>
#include <string>


int delay;
long long int counter=0;
long long int endcount=0;
long long int match=0;
long long int nomatch=0;
long long int seed1=0;
int display=0;

int main ()
{
std::cout<<"Enter Starting Value\n";
std::cin>>counter;
std::cout<<"\n"<<"Enter Ending Value\n";
std::cin>>endcount;
std::cout<<"\n\n";

std::string str="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";
std::string str2="[emailprotected]#$%^&*()_-+=?<>:\\/~.,;";
system("@echo. Started on %date% at %time%>>Log1.txt");
std::cout<<"Running Please Wait...\n";
while(counter<=endcount){

seed1=counter;

srand(seed1);

random_shuffle(str.begin(), str.end()); // Shuffle the string

display++;

if (str.compare(str2) != 0){

while(display==1000000){
std::cout<<"counter = "<<counter<<" \n";
display=0;
}
nomatch++;

}
else{
std::cout<<"counter= "<<counter<<" - Match Found\n";
match++;
std::cin>>delay;
}
counter++;
}
std::cout<<"Match = "<<match<<"\n";
std::cout<<"No Match = "<<nomatch<<"\n";
system("@echo. Ended on %date% at %time%>>Log1.txt");
std::cin>>delay;
return 0;
}
I think you have much too much time on your hands random_shuffle is undefined in the above sample; I had to add
Code: [Select]#include <algorithm>
using namespace std;

Do you run systems for that long very often? If the system is running Windows 7 it could have fallen victim to a number of diagnosed problems such as this one, and is a memory leak related to Windows Update. If you don't tend to run your systems as long as you did to run this program you might not have considered it out of the ordinary.

If it was a memory leak I would expect it to be instantly obvious when running but it sat at a little over 800K private bytes the entire time I ran it.Quote from: Allan on February 04, 2016, 09:00:45 AM

I think you have much too much time on your hands
Yes this time of year I generally have too much time on my hands. Every winter I generally dive into a project of some sort. I like programming, but there have been so many times that I have felt an urge to write a program of my own and its like, what can I make that isn't completely pointless and would be useful to me. Making a program that scrambles text became this winters project as for I have a small notebook that I use to keep in my trunk of my car so that in case of a fire or same notebook in home was lost, I'd still have passwords and private info readily available... BUT its very dangerous having it all in a small notebook where if it fell out of my trunk or someone got their hands on it they would have "EVERYTHING" in clear text to use.

My plans with the program I have is its a 2 part. A file is created with a key listing, and another file is created with the scrambled data. The key file and scrambled data file are kept separate so its like a key and a lockbox. But the lockbox is like a box of scrabble squares in it with the squares all different colors. It could be any message, but without the key and program to reassemble the message its almost pointless. Then a USB stick or a CD or DVD is burned with this data only without the program and keys needed to decrypt it. The program and key file is then kept in 2 locations, but never in the trunk of car, where odds of both locations having a fire for example at same time to destroy it are unlikely and the data and the tool and key to decrypt it are always kept appart with exception to when I need to look up a complex password that I dont use every day.

The program I have now is not perfect and it needs to be strengthened. For now with it in its weak form words that have duplicate characters such as Hello World I enter into it as HeLlo World so that a duplicate character output is not seen in the scrambled output which is what a crypto cracker would probably use as a means to brute force it back to its original form. But passwords that are case sensitive unfortunately if there is a Password of YellowDog5$ the scrambled output would be something like &577*xH*+qU and that 77 pairing in there is a weakness!

Hoping to implement later more complexity to it so that you could get pairing but pairing would not likely ever be substitution for the same character by use of multiple shuffled strings in use and based on the character placement within the full message to crypt its scrambled that much more complexly. Including an idea to salt the message with extra characters to add noise to it so Hello_World would not be always a scrambled output of 11 characters, but could be greater than 11 characters such as an output of G6*[emailprotected]?>0pZ&$Bvd3L# ( 20 characters ).

The good thing is that my wife of 20 years knows my Winter Cycle of diving into programming heavily winters when daylight is short and too cold outside TV is boring and I get burnt out on video games. She has learned not to ask what I have been up to. Although she asked the other day and then after I started spilling out what i was doing and this algorithm doing this and the probability of a string match and running 1 Trillion iterations to test for the slim possibility of an exact match absolute worst key to use scenario she told me to shut up. ha ha ha Then I had an idea and started writing it onto paper as a brain dump and she told me she doesnt want to see me even writing code or flow charts at the dinner table as my brain is still going. I told her as long as she doesnt see me wallpapering the room in source code and flow charts that I'm still sane.

She also SAID you should have married a computer nerd girl who gets turned on by code talk. I then reminded her of a girl that matched well with me at work 16 years ago and how if I wasnt married to my wife, I suppose that would have been the one since we were both heavily flirting with geek speak and very into each others conversations, as well as she was very nice on the eyes, but being true to my wife, I didnt leave her or cheat. She just looked at me and shook her head and I laughed. I said so they say opposites attract. And your telling me that likes attract then. She then said that you should have been a character on the tv show big bang theory and I laughed and said thank you for that compliment.

Thanks BC for that info on Windows 7 memory leak. I wasnt aware of that and this system hasnt been CONNECTED for Windows updates in a while. I will update it tonight. Also interesting that my IDE didnt complain about the #include missing, not even a warning in the compile log. Also I dont run systems for days on end anymore other than some laptops that are crunching for BOINC in my basement. I either shut down my systems or have them processing data that is CPU intensive such as online gaming events with others that i record with Fraps and then use virtual dub to take the raw 40GB video file and process it down to a more manageable 1GB video file when I am sleeping and they are completed with processing by the time I wake up in which I check e-mail, delete the massive 40GB file and then shut it down and head to work.
1871.

Solve : make [ Batch file to execute program ]?

Answer»

Admin can you please delete this message for me please, because i moved this subject to
Microsoft DOS, but i can not delete it???

THANK you for helping
Sorry for my EnglishUsng call with an exe file has no effect. Call is strictly for calling another batch program or an in-line subroutine.

Code: [Select]@echo off
cls
MOVE picture1.jpg recover
start /wait PAINT.exe picture1.jpg
move recover\picture1.jpg ..\automatic

MSPaint runs in it's own window. The start /wait will prevent the window running your batch file from continuing until paint has FINISHED processing.

Good LUCK.

1872.

Solve : distorted view?

Answer»

hi, my computer screen has been DISTORTED lately and i dont KNOW why. this happened once before but it went away.the colors have changed one the screen and it is hard to read worlds..help please!!
WOW!! Way too much information! If you give us any more then MAYBE, just maybe, SOMEONE may solve your problem. (SIGH) Worth a try.Have you tried to degause your screen at all?
Sometimes you get an option to degause in your screen menu.

1873.

Solve : How to access Windows AutoDetect.exe?

Answer»

Hi-
I have a little java application which (using JRE) will allow the user to open files with an application.
I have a dialog which asks the user to browse for the application that will open the file based upon the file extension and saves this information in a map
so the next time they wish to open a file with that extension they don't have to browse for the application.
My question is:
Does anyone know how to extract this information using Windows AutoDetect.exe?
So on start-up I can write the map and not have to ask the user to browse.
Maybe there is a utility or something that can be used?
I've posted this question on Sun Forums and I guess it was inappropriate since it is not really a Java question.
Any help would be welcome. windows autodetect.exe? What is that?http://www.file.net/process/autodetect.exe.html1. Autodetect.exe is not a Windows component, it is part of software from Ceedo Technologies Ltd.

2. In English, this is a "map"

Uh Thanks for the info re: my generic use of the TERM map.
I guess what I should have said was HashMap<String,String> where the key string is the file extension and the value string is the path to the APPROPRIATE program to use to open the file.
Anyway it LOOKS as though I am going to pursue another tack and have found that the information I need
can be OBTAINED using batch files which make use of the assoc and ftype commands.
This seems to be successful and so Thank You all for your patience.
I am relatively new at batch files and so hope to be ABLE to ask some advice from you.
Cheers n.

1874.

Solve : Small program won't compile... what is this error message??

Answer»

Compiler shows me this, but I can't seem to see what I'm MISSING.
main.cpp:45: error: expected `}' at end of input


There are two files this main.cpp and also a template at bottom:

#include//C++ standard library header file I/O definitions
#include "file.h" //The template file file.h is included here
using namespace std;//Contains classes, objects and functions in the C++ library - no std :: scope
using namespace duram;//Resolves conflicting functions or variable names between the two libraries.

void instruct (void);

int main(int ARGC, CHAR ** argv)

{
instruct();

int a[7] = { -4, -2, 0, 2, 4, 6, 7 };
double b[7] = { -7.5, -4.3, 0, 6, 4.4, 8.2, 9.6 };

int v;

cout << "The integers in array a are: ";
display(a,7);
cout << "The real numbers in array b are: ";
display(b,7);
cout << "The integers smaller than 4 in a are: ";
cout << count(a,7,v);
cout << "The real numbers smaller than 4 in b are: ";
cout << count(b,7,v);

return 0;
}

void instruct(void)
{
cout << endl << endl << "This program utilizes initialized arrays full of 7 digits" << endl;//instructions for user
cout << "and displays those array values using one template and" << endl;//instructions for user
cout << "finds and returns the quantity of values within less than 4." << endl << endl;//instructions for user
}




TEMPLATE file.h

#include
using namespace std;
namespace duram
{
template
void display(T*a, int N){
for (int i=0; icout << a << " ";
}


template<typename T>
T count(T*a, int N, T v) {
int counter = 0;
for(int i=0; i<N; i++)
{ if (a<v)
counter++;
}
return counter;
}




It would seem that you have a mismatch of the {

Wen showing US code, use the code thing.

Code: [Select]{
template<typename T>
void display(T*a, int N){
for (int i=0; i<N; i++)
cout << a << " ";
}
Otherwise you turn on the formulating tokens used on tis SMF board. The code above looks like you have an extra { at the end of a line.

Code: [Select]#include<iostream>
using namespace std;
namespace duram
{
template<typename T>
void display(T*a, int N){ <------------------------------------------
for (int i=0; i<N; i++)
cout << a << " ";
}

1875.

Solve : need a list of lua programming codes?

Answer»

I need a list of LUA programming codes for lua script. I can't seem to FIND any. I WOULD like a COMPLETE list of lua codes so I can learn it better.Googled and found this which led to this and there's lots more...

1876.

Solve : C# Help please...?

Answer»

I decided I WANT to make a FILE that can make other files...

My Code:

using System;
using System.Collections;
using System.TEXT;
using System.IO;

public class Writetextfile
{
public static void Main(string[] args)
{
FileInfo t = new FileInfo("Hello.txt");
StreamWriter Tex =t.CreateText();
Tex.WriteLine("HELLO!!!!");
Tex.Write(Tex.NewLine);
Tex.close();
Console.WriteLine(" The Text file named Hello is created ");
Console.ReadLine();
}
}

For some reason it gives me this error

Text Maker.cs(14,1): error CS0117: 'System.IO.StreamWriter' does not CONTAIN a definition for 'close'

I am using Version 1.1.4322 of microsoft.NET

Can someone HELP me? Please Ignore this forum I Figured out what I did wroung.

I forgot to captialize the C in Close xD

1877.

Solve : UPDATED with additional info. Need to rename file as previous Sunday date?

Answer»

I have a vbs SCRIPT to rename a file with the previous Sunday's date. This script works perfectly fine on my windows XP machine, however, I am getting a runtime error when trying to execute on a windows VISTA machine. I attached the error MESSAGE as well as the syntax of the script. Do I need to change a setting somewhere on my vista machine to get this work?

Dim dtDateBegWeek, fname1
dtDateBegWeek = date-datepart("w",date-1)
fname1 = "aROsaleslast.xls_" &AMP; left(dtDateBegWeek,2) & mid(dtDateBegWeek,4,2) & right(dtDateBegWeek,2)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "aROsaleslast.xls", fname1


[attachment deleted by admin]That says that your file isn't found. Is the file "aROsaleslast.xls" where it needs to be? How about using a full name? (such as "C:\myfolder\aROsaleslast.xls")The file is in the same folder with the script. I did try adding the full path, but still no luck. It works exactly as it is, on windows XP...just not on Vista!I've done a little more research...it seems that the syntax works on one computer, but not on another...both XP machines. The error is coming from the statement date-datepart("w",date-1).

So, my question is...how can I get this script to work? I need to rename my file with the previous Sunday date. I am not sure what day during the week it will run, as it is dependent on the user...but it should always have the previous Sunday date. Can anyone help me? Thanks much.Possibly the 2 different computers have different date format settings. ("Regional Settings")

See here

http://support.microsoft.com/kb/218964

Extract:

Quote

The VBScript functions Now, Date, and Time rely on the Regional Settings in the computer for their formats. Regional Settings change, depending on the user who is logged on (or not logged on) to the computer. As a result, there is no way to guarantee that date and time formats will always be the same.

To ensure that your date and time formats are consistent, do one of the following:

* Use JScript, which does not rely on the regional settings for its date and time formats.

* Use functions other than Now, Date, and Time to display dates and times. Because the other date and time functions (for example, Day, Month, and Year) do not rely on regional settings, the formats do not change when different users log on to the computer. For example, the MyDate function always RETURNS the date in mm/dd/yyyy format:

Function MyDate()
dteCurrent = Date()

dteDay = Day(dteCurrent)
dteMonth = Month(dteCurrent)
dteYear = Year(dteCurrent)

MyDate = dteMonth & "/" & dteDay & "/" & dteYear
End Function


1878.

Solve : c++ in highschool?

Answer»

i am going into 9th grade and I want to know if that class would be too hard? Is c++ very hard? I dont know wether c++1 and 2 would be too much for 9th grade? Thanksif their offering it for your grade they probably aren't going to do anything beyond your abilities.

For example, I doubt on the first day they'll give you a C manual, a linux manual, a linux distribution that doesn't match that manual with a version of GCC that doesn't match the one described in the manual, and a computer that barely runs it all, and ask:

"Alright, create a tree-based implementation of Evaluating String expressions. you have 20 MINUTES. GO!"

basically- it boils down to wether you meet all the prerequisites of the class- as an example, is there a plain C class available? if so go for that. Otherwise they are likely catering the class to allow for those that are unfamilar with the material.should i take c++ 1 and 2 in 9th grade? Or do 1in 9th and 2 in 10th? I want to do that but my parents wont let me and its making me mad because I want to do someting else becideds c++ 1 and 2why are they making you do both I don't know what is C++ 1 & 2 but C++ is not as hard as it seems. Once you understand the basic concept, its just as simple as English.

So to start you off:
Code: [Select]#include <iostream>

using namespace std;

int main(void)
{
cout << "Hello World" << endl;

return 0;
}
LOLCode: [Select]#include "stdafx.h"
#include "windows.h"
#include "iostream.h"
#import "G:\vbproj\vb\graph\dll\functionparser\release\baseparser.dll" raw_interfaces_only

int main(int argc, char* argv[])
{



CoInitialize(NULL);


BASeParser::_CparserPtr parseruse = NULL;
HRESULT hr =
CoCreateInstance( __uuidof(__CParser),
NULL,
CLSCTX_INPROC_SERVER,
__uuidof(__CParser),
(void**) &parseruse
);

parseruse->put_Expression((BSTR)"sqr(2)^3");
VARIANT* retval;
retval=new VARIANT;

parseruse->Execute(retval);
cout<<retval->dblVal;
CoUninitialize();




//__Cparser* useparse;
//useparse = new __CParser();

return 0;
}


That's much simpler, LOL. my C++ program accessing my VB6 ActiveX Dll.Ok I am only taking one c++ class nowWhen I was in Highschool they had Computer Programming Honors which I took sophmore year and junior year I took AP Computer Science. we mostly learned Java, but we did some case studies in C++.BC Programmer:
Is that an introduction program??

If so then we would have very less C++ programmers!Quote from: Ashutosh32 on February 12, 2009, 03:12:11 AM

BC Programmer:
Is that an introduction program??

If so then we would have very less C++ programmers!

goodness no! actually... it doesn't even really work, since I couldn't be bothered to learn how to use a VARIANT in C++. So if the expression ends up returning a string or object it causes a PAGE fault. Oh well.

As confusing as that may look, I have VB6 code that looks even worse...


Public Sub InvokeDynamic(ByVal onObj As Object, ByVal memberName As String, Arguments As Variant, retval As Variant)
Dim ArgsPass() As Variant
Dim AccessMode As InvokeKinds
Dim i As Long
Dim Current As Long
Dim TryEm(10) As InvokeKinds, TryCount As Long
Dim MemberInf As TLI.SearchItem
Dim FuncFlags As InvokeKinds
Dim IntInfo As TLI.InterfaceInfo, Getfirst As Boolean
On Error Resume Next
Set IntInfo = TLI.InterfaceInfoFromObject(onObj)
'Set MemberInf=IntInfo.Members.GetFilteredMembers(False).Item(
Set MemberInf = FindSearchItem(IntInfo.Members.GetFilteredMembers(False), memberName)
If MemberInf Is Nothing Then
' 'check for existence of Get and Set prefixed names of this one... for example, if we were passed "Name" look for getName and setName.
' If StrComp(left$(memberName, 3), "Set", vbTextCompare) = 0 And StrComp(left$(memberName, 3), "Get", vbTextCompare) = 0 Then
' 'check for set/Get permutations.
' If Not IsArray(Arguments) Then
' 'try Get first.
' Getfirst = True
' Else
' Getfirst = False
'
' End If
' If Getfirst Then
' On Error Resume Next
' InvokeDynamic onObj, "Get" & memberName, Arguments, retval
'
'
' End If
' If Not Getfirst Or Err <> 0 Then
' Err.Clear
' InvokeDynamic onObj, "Set" & memberName, Arguments, retval
'
'
'
'
'
' End If
'

'Execution Error: METHOD or Data member not found.

On Error GoTo 0
Err.Raise ExecuteErrors.Exec_UnsupportedOperation, "ModParser::InvokeDynamic", "Interface member name " & memberName & " Not present in class name " & TypeName(onObj)

Else
'The method DOES exist. good.
'if we have an array of arguments, put them in reverse order for the InvokeHook...
If IsArray(Arguments) Then
ReDim ArgsPass(UBound(Arguments))

For i = UBound(Arguments) To 0 Step -1

If IsObject(Arguments(i)) Then

Set ArgsPass(Current) = Arguments(i)

Else

ArgsPass(Current) = Arguments(i)

End If

Current = Current + 1
Next i
End If
'OK, if we have no parameters, it is POSITIVE that, if it is a property, it will be the retrieval of it.
'with parameters, however, is a different story. we'll need to try a Put first, then a get if an error occurs.

' If IsArray(Arguments) Then
'An Array/
'possibly Get/Put/PutRef/Function.
'INVOKE_PROPERTYPUT and INVOKE_PROPERTYPUTREF require arguments.
If MemberInf.InvokeKinds And INVOKE_PROPERTYPUT And IsArray(Arguments) Then

'try Good ol' put first...
TryEm(TryCount) = INVOKE_PROPERTYPUT
TryCount = TryCount + 1

End If
If MemberInf.InvokeKinds And INVOKE_PROPERTYPUTREF And IsArray(Arguments) Then
TryEm(TryCount) = INVOKE_PROPERTYPUTREF
TryCount = TryCount + 1
End If
If MemberInf.InvokeKinds And INVOKE_PROPERTYGET Then
TryEm(TryCount) = INVOKE_PROPERTYGET
TryCount = TryCount + 1
End If
If MemberInf.InvokeKinds And INVOKE_FUNC Then
TryEm(TryCount) = INVOKE_FUNC
TryCount = TryCount + 1
End If





End If
Dim CurrTry As Long

'Final Stage- Iterate through each item in TryEm from 0 to trycount and attempt an InvokeHook.
For CurrTry = 0 To TryCount
On Error Resume Next
If UBound(ArgsPass) < 0 Then
Err.Clear
Call Assign(retval, CallByName(onObj, memberName, TryEm(CurrTry)))

Else
Call Assign(retval, TLI.InvokeHookArray(onObj, memberName, TryEm(CurrTry), ArgsPass))

End If
If Err = 0 Then Exit For
Err.Clear
Next

End Sub


-reduced in size to keep from taking up the whole page. the PROJECT that this is in clocks in at 15,000 lines, but I'm pretty sure there's a bit of dead-code in there somewhere.


Ahem... anyway...


As long as you stay away from COM, C++ is really no trouble at all. It's when you start doing gross STUFF like my silly little sample that it get's tricky. In fact, I gave up on that one ages ago- I found it easier to find out how to make a console program in VB6...i just found my vb book. Take only one class, they'll teach you the basics starting from scratch. Because you're in grade nine they know there is no prerequisites to take before that, so you'll start with the basics. You're lucky you have C++ class in your high school, I only had Pascal and Java which became available a little bit to late for me.You're lucky to have any programming courses in your school. We don't have any - I have had to self-teach myself since i was seven. Useless northland schools...my school had "Information technology" for grades 10,11, and 12- (11 and twelve were mostly in Visual Basic, with some Flash thrown in for good measure), as well as AP CS 12, which I myself took in grade 11, and did nothing at all in and got 100%. Actually, come to think of it, I didn't do anything in any of those computer courses after the first day or so of IT11... technically I was silently upgraded to IT12 and even then I was far better at VB then anybody else in the school of 1400.

I credit all this to my 386 and VB2 during summer holidays one year...


Now the poor bastards there are using VS .NET... I actually visited there once, and I had to supress sarcastic laughter when they asked wether I used VB .NET.

"As my main language. I find the .NET framework clunky and an unnecessary distributable, and the CLR to be a cheap copy of the Java VM. I prefer VB Classic. yourself?"

That person spent the rest of that period trying to think of something that .NET could do that I not only couldn't do in VB6 but also hadn't done - didn't go over in his favour...
1879.

Solve : C# Help!?

Answer»

I'm Trying to make a Program that will start another program if you type in the correct password and user name...

So far I got everything to work except the part where it starts the other program...
I need some help this is the program so far...

Code:
using System;

public CLASS Password
{
public static void Main()
{
Console.WriteLine("Please put in your Username.");
string U = Console.ReadLine();
Console.WriteLine("Please put in your Password.");
string P = Console.ReadLine();
if (U == "Username")
{
if (P == "Password")
{
//I don't know what to type here to start another program...
}
}
Console.WriteLine("SUCCESS");
}
}Sourced from http://www.csharp-station.com/HowTo/ProcessStart.aspx

A C# program can launch another program using the Process class. The Process class is part of the System.Diagnostics namespace. You start another program by instantiating a Process object, SETTING members of it's StartInfo property, and invoking it's Start() method. Listing 1 shows how to start a process from C#.
Listing 1: Starting a Process: ProcessStart.cs

Code: [Select]using System;
using System.Diagnostics;

namespace csharp_station.howto
{
/// <summary>
/// Demonstrates how to start another program from C#
/// </summary>
class ProcessStart
{
static void Main(string[] args)
{
Process notePad = new Process();

notePad.StartInfo.FILENAME = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";

notePad.Start();
}
}
}
Reading further, and applying this to your situation, you don't need the arguments line for your application (unless you are indeed passing it arguments.)

In the filename, put the full name of your executable, e.g. C:\Myfolder\Program.exe

Thus, your lines would be
Code: [Select]Process myprogram = new Process();

myprogram.StartInfo.FileName = "C:\Myfolder\Program.exe";

myprogram.Start();

Good LuckThank you ! this helped out A lot!!!!

Uh Oh I got a Problem

NVM I Fixed it I for got the

using System.Diagnostics;


I put the info in and I got an error Making it.

Code:
using System;
using System.Diagnostics;

public class Password
{
public static void Main(string[] args)
{
Console.WriteLine("Please put in your Username.");
string U = Console.ReadLine();
Console.WriteLine("Please put in your Password.");
string P = Console.ReadLine();
if (U == "Username")
{
if (P == "Password")
{
Process mystuff = new Process();
mystuff.StartInfo.FileName = "MyStuff.exe";
mysutff.StartInfo.Arguments = "ProcessStart.cs";
mystuff.Start();
Console.WriteLine("SUCCESS");
}
}
}
}

This is the Error

Error:

Password.cs(15,5): error CS246: The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly REFERENCE?)

Password.cs(16,5): error CS246: The type or namespace name 'mystuff' could not be found (are you missing a using directive or an assembly reference?)

Password.cs(17,5): error CS246: The type or namespace name 'mystuff' could not be found (are you missing a using directive or an assembly reference?)

Password.cs(18,5): error CS246: The type or namespace name 'mystuff' could not be found (are you missing a using directive or an assembly reference?)

How do I fix this?You're very welcome

1880.

Solve : RE: programming ro detect a specific change on screen?

Answer»

Hi all,

I'm not sure if my problem is possible so my question is to ask if this is feasibly possible.

I have a trading software which has volume bars at the bottom of the charts. When there is increasing volume, the bars will CHANGE color showing that there is more activity.

For the trading software datafeed, I cannot access the primary source of the data (and I wouldn't want to ) so I can find an EASIER programming solution.

What I like to know if 'programming' can detect this increasing volume change 'from the screen' at a SPECIFIC point.

If there is more activity the volume bar will change to blue, and this is what I want the 'program' to detect, then send an email or play a sound.

Possible or am I barking up the wrong TREE?

It is a high possibility that there isn't a premade software to do this on the market now. I did think of a webcam TAKING and comparing screenshots but I think this is possible too slow

Thanks for your time.

1881.

Solve : Perfered Programming Language?

Answer»

Another bump?batch is good, but its even better when you add VBScriptWho said this:

TCL

Many professional C++ programmers us this as 'glue' to tie together things that they don't want to rewrite in C++ are any other language. They use TCL and Tk as a "wrapper" to get the job done quick and easy.

Becasue it is open source thee is not much visible commercial interest. But it is, in fact, a production tool in use in the commercial WORLD.

In the real world programmers often work in three languages on a project.
Quote from: Geek-9pm on February 06, 2009, 12:33:46 PM

Who said this:
TCL

I think I did.
Quote
they don't want to rewrite in C++ are any other language
c++ or java or computer apps for school. What do you guys thinkQuote
Quote
they don't want to rewrite in C++ are any other language
Huh
What I meant was that a project may have built several apps in C ++ and each APP has its own main thing and the apps are not integrated together. So the project leader says the apps have to be integrated. Oops. They have conflictual thing sin them and they do not really work together. What the boss wants is a package that makes it loot like one big application. So the programmers do not want to re-write the apps so that can all be in one big EXE. So they use a script language like TCL to do a GUI that gives a look and feel of a kind of integrated app. The TCL is just a user interface that lets the user pick an app from a list.
Do you understand what I mean? The advantage of TCL is it can do a simple GUI that looks nice in windows.
I may have exposed a inside secret.
Sorry. I can't keep my beak shut.
OK -- cool -- I'll have to keep that in mind.Snit looks fun...

Quote from: Wikipedia
Snit is intended to HELP build applications out of the code at hand.
I've voted C++. I think that C is the de-facto standard in UNIX but the ORIGINAL C language lacked many features (reference, template, STL, string, overloading, class, etc.). I currently use lots of these features in C++ now.C, not C++, is the de-facto standard of UNIX and is what UNIX is written in, as well as most of it's user-based derivatives, such as Ubuntu, GNU,Fedora, and so forth.

in my opinion C++ is a somewhat rushed implementation of OOP into the existing C language. The fact that one needs to define the class interface and the concrete class itself in separate HEADER and cpp files makes file management a unnecessary pain in the but.

Additionally, although simply using classes in C++ is workable, a completely different set of difficulties arises when trying to implement COM classes via C++. with requirements to implement IUnknown, IDispatch, IPersistFile, IObjectSafety, and goodness knows how many other COM interfaces, many of which contain basic boilerplate code (which can be easily wrapped into templates as shown by ATL).

of course this isn't really a design flaw on the part of C++ but rather the lack of anything higher-level to the C++ programmer for COM components. As an example, Visual Basic and Delphi can both implement COM classes without requiring the programmer to manually implement the various required classes (IClassFactory and so forth)
1882.

Solve : More C# Help...?

Answer»

Hello I need some more help... xD

I Figured out how to make a .dll from a C# program but I want it to edit another file when I turn it on.

The PROBLEM is I don't know what to type in the code to do that...

This is the code...

USING System;

public class EditMe
{
public static VOID MAIN()
{
string editthisstring = "Hello";
Console.WriteLine(editthisstring);
// Part when you use the dll...
Console.ReadLine();
// I want it to say "Good Bye!" when the DLL edits it.
Console.WriteLine(editthisstring);
Console.ReadLine();
}
}Quote from: hibyy on February 09, 2009, 05:21:25 PM

when I turn it on.

what does this mean? When you turn what on?when I activate the dll in another application so I can use it in that application.
1883.

Solve : menu tree and grid control?

Answer»

I'm LOOKING for a good portable control for menus and navigation. also a good grid. Any one have any experiences with some of those on the MARKET, old or new, i'd APPRECIATE it. Coding for desktop, and web, SEPARATE apps.

1884.

Solve : Good c++ complier?

Answer»

Looking for a GOOD C++ complier. I GOT a dummies book on C++ but it only goes up too WInd ME an I am USING xp not sure were to find this stuff since I'm starting out an all ready having issues.Googlefigures, there a thousands of ones that may do SOMETHINGS an not OTHERS I just want one that is fairly well.http://en.wikipedia.org/wiki/List_of_C%2B%2B_compilers#C.2FC.2B.2B_compilersshould have thought of that I dont really wiki but any way I got vsual c++ 05 version but dont know if its limited an if it will work an all that.

1885.

Solve : Formula in Microsoft Excel?

Answer»

Hello,
I want to calculate Annual Compounded Growth Rate in an Excel Spreadsheet.
Can you please HELP me how to WRITE this formula for ACGR?

Thanks

Munira Click below

http://www.google.com/search?source=ig&hl=en&rlz=&=&q=Annual+Compounded+Growth+Rate+excel&btnG=Google+Search&meta=lr%3Duse the XIRR function. if you get an error, its not installed. from your menu, tools, ADDINS, select, install and load the analysis toolpak addin

1886.

Solve : batch file on cd to autorund a sellection of programe exe files?

Answer»

Hi can anyone help me. I have not written a batch file in a very long time @18 years and never had to do what I now need to do. I am trying to prepare a batch file for burning onto a cd/dvd that will allow me to offer the cd/dvd user a selection of programs to install. I have a code that will make the batch file executable. I suppose I am trying to product a file much like you will see on the free cd/dvd's given out with many mags these days. I use xp as my os but the file would have to be capable of executing on almost any windows based system from say 2000 to vista. Is there any one who can help. My request is genuine and I have just had a web site built at www.cadireland.com I am trying to put together a cd/dvd with all of the demo files on it. I am new to this field as you have probably guessed. If anyone knows of an business who could write this program for me that would also be an acceptable solution depending on cost and time taken to produce. I really appreciate your help thanks.This could be as elaborate or a simple as you want.

For simple, the batch file could run the proper installation program based on the user selection.

For elaborate, you could use Internet Explorer, write an HTML splash screen, complete with the company logo and some majestic art work , and run the proper installation program based on the user selection.

Either method would require an autorun.inf file which will kick start the process by pointing to and executing the batch file when the CD is inserted.

This might be a fun project. Hi Sidewinder, Thanks for responding. I had thought of the Autorun.inf file and was going to use

[Autorun]
open=master.exe
Icon=cadirelandlogo.jpg

I have a small free program that turns batch files into exe files so i would make the batch file an exe.called master and drop in my logo.

While I need the choices your suggestion of a web page is very appealing as it sounds much more flexible. Problem is what little knowledge I have about batch files I have none with html.

@echo off
cls
echo.
echo.
echo 1. ProgeCad
echo.
echo 2. ArchSoft
echo.
echo 3. Land Development Suite
echo.
echo 4. Design & Parking
echo.
echo.
choice /C:1234 /N " Enter your choice..... "
cls

if errorlevel 1 set errorlev=1
if errorlevel 2 set errorlev=2
if errorlevel 3 set errorlev=3
if errorlevel 3 set errorlev=4

echo.
echo.
echo Return Code = %errorlev%

echo.
@echo off
cls
:start
echo This is a loop
set choice=
set /p choice="Do you wish install another program? Press 'y' and enter for Yes: Or "N" for no "
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='y' goto start

Not sure if I have got this right been a very long time and never did anything with with the integration and complexity of this.

Having finished their installation the computer will need to restart. I would use the code.

echo.
shutdown-r-c"Computer needs to shutdown & restart to complete installation"-t,30

Again my problem is how to tie all of these together still show a welcome message and disclaimer and if POSSIBLE a little bit of artwork. Any suggestions and again thank you for your time.Simple is good.

You pretty much have everything in place. I streamlined a bit of your code.

Code: [Select]@echo off
:top
cls
echo.
echo.
echo. 0. Exit
echo.
echo 1. ProgeCad
echo.
echo 2. ArchSoft
echo.
echo 3. Land Development Suite
echo.
echo 4. Design and Parking
echo.
echo.
choice /C:01234 /N " Enter your choice..... "
cls

if errorlevel 5 goto park
if errorlevel 4 goto land
if errorlevel 3 goto arch
if errorlevel 2 goto cad
if errorlevel 1 exit /b

:cad
cad.exe
goto top

:arch
arch.exe
goto top

:land
land.exe
goto top

:park
park.exe
goto top

I made up the executable names, which you will need to change along with the relative paths. Errorlevels should be tested in descending sequence as the compare is equal or greater than.

Quote

I use xp as my os but the file would have to be capable of executing on almost any windows based system from say 2000 to vista

Choice is not installed on WinNT machines only Win9x (yes, they are still out there) although I hear they brought it back from the dead for Vista. You may have to query what OS the user is running and write another segment of code for WinNT, Win2000, and WinXP USERS that will use set /p

Quote
Again my problem is how to tie all of these together

Provided the compiled version of the batch file is NAMED master.exe, everything is tied together. Be sure to put the exe and the jpg icon in the root directory of the CD. Each of the support files for each selection can be in their own directory, but use relative paths as the CD drive letter will be different on different machines.

Quote
still show a welcome message and disclaimer and if possible a little bit of artwork

Forget the artwork. Batch files are text only and do not support graphics. You could create a splash screen with multiple echo commands and use ping to leave visible for say 5 seconds.

If you decide to go with a HTML solution let us know.

Note: During testing I used a USB thumb drive which is not supported for autoplay without some smoke and MIRRORS so my autorun.inf was a bit different than yours. The autorun.inf file you posted should work fine for a CD. Hi Sidewinder
Sorry for long delay in thanking you for your help with code. It was a neater solution.

I decided having looked at the limited nature of the result to write a html code. It has been very difficult and I am only now nearing completion. I did not ask for help as the pages of code were in some cases large and complex although I have through trial and error started to slim all of this down. It turned out to be quite a project linking all the pages of code in a similar manner to a web site. When finished I may publish on these forums the code pages should anyone else like to give it a try or offer some improvements. Once again thank you
1887.

Solve : in need of debugging help?

Answer»

i'm using Microsoft Visual .Net Studio 2003
when i debug my program this comes up:




Compiling...
cylindermain.cpp
Linking...

cylindermain.obj : error LNK2005: "PUBLIC: void __thiscall circleType::setBase(double,double,double)" ([emailprotected][emailprotected]) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: double __thiscall circleType::getBaseCenterX(void)const " ([emailprotected]QBENXZ) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: double __thiscall circleType::getBaseCenterY(void)const " ([emailprotected]QBENXZ) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: double __thiscall circleType::getBaseRadius(void)const " ([emailprotected]QBENXZ) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: double __thiscall circleType::baseArea(void)const " ([emailprotected]QBENXZ) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: double __thiscall circleType::baseCircumference(void)const " ([emailprotected]QBENXZ) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: void __thiscall circleType::printBase(void)const " ([emailprotected]QBEXXZ) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: __thiscall circleType::circleType(double,double,double)" ([emailprotected]@[emailprotected]@Z) already defined in circleType.obj

cylindermain.obj : error LNK2005: "public: __thiscall circleType::~circleType(void)" ([emailprotected]@[emailprotected]) already defined in circleType.obj

cylinderType.obj : error LNK2005: "public: void __thiscall cylinderType::setCylinder(double,double,double,double)" ([emailprotected][emailprotected]) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: double __thiscall cylinderType::getCylinderBaseCenterX(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: double __thiscall cylinderType::getCylinderBaseCenterY(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: double __thiscall cylinderType::getCylinderBaseRadius(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: double __thiscall cylinderType::getCylinderHeight(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: double __thiscall cylinderType::CYLINDERVOLUME(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: double __thiscall cylinderType::cylinderSurface(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: void __thiscall cylinderType::printCylinder(void)const " ([emailprotected]QBEXXZ) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: __thiscall cylinderType::cylinderType(double,double,double,double)" ([emailprotected]@[emailprotected]@Z) already defined in cylindermain.obj

cylinderType.obj : error LNK2005: "public: __thiscall cylinderType::~cylinderType(void)" ([emailprotected]@[emailprotected]) already defined in cylindermain.obj

pointType.obj : error LNK2005: "public: void __thiscall pointType::setXY(double,double)" ([emailprotected][emailprotected]) already defined in cylindermain.obj

pointType.obj : error LNK2005: "public: double __thiscall pointType::getX(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

pointType.obj : error LNK2005: "public: double __thiscall pointType::getY(void)const " ([emailprotected]QBENXZ) already defined in cylindermain.obj

pointType.obj : error LNK2005: "public: void __thiscall pointType::printPoint(void)const " ([emailprotected]QBEXXZ) already defined in cylindermain.obj

pointType.obj : error LNK2005: "public: __thiscall pointType::pointType(double,double)" ([emailprotected]@[emailprotected]@Z) already defined in cylindermain.obj

pointType.obj : error LNK2005: "public: __thiscall pointType::~pointType(void)" ([emailprotected]@[emailprotected]) already defined in cylindermain.obj

Debug/cyl.exe : fatal error LNK1169: one or more multiply defined symbols found


how can i FIX these? pleasemight help if you give us your source code too...here they are.

Main
#include
#include
using namespace std;

#include "pointType.h"
#include "circleType.h"
#include "cylinderType.h"
#include "pointType.cpp"
#include "circleType.cpp"
#include "cylinderType.cpp"

int main()
{

pointType myPoint1; //(0,0);
pointType myPoint2(8,6);

circleType myCircle1; //(0,0,0);
circleType myCircle2(10, 7, 3);

cylinderType myCylinder1; //(0, 0, 0, 0);
cylinderType myCylinder2(1, 2, 3, 4);

// cout<< fixed << showpoint << setprecision(3);

cout << "myPoint1: ";
myPoint1.printPoint();
cout << endl;

cout << "myPoint2: ";
myPoint2.printPoint();
cout << endl;

cout << "myCircle1: ";
myCircle1.printBase();
cout << endl;
cout << "Circumference of myCircle1: " << myCircle1.baseCircumference() << endl;
cout << "Area of myCircle1: " << myCircle1.baseArea() << endl;

cout << "myCircle2: ";
myCircle2.printBase();
cout << endl;
cout << "Circumference of myCircle2: " << myCircle2.baseCircumference() << endl;
cout << "Area of myCircle2: " << myCircle2.baseArea() << endl;

cout << "myCylinder1: ";
myCylinder1.printCylinder();
cout << endl;
myCylinder1.printPoint();
cout << endl;
cout << "Surface of myCylinder1: " << myCylinder1.cylinderSurface() << endl;
cout << "VOLUME of myCylinder1: " << myCylinder1.cylinderVolume() << endl;

cout << "myCylinder2: ";
myCylinder2.printCylinder();
cout << endl;
myCylinder2.printPoint();
cout << endl;
cout << "Surface of myCylinder2: " << myCylinder2.cylinderSurface() << endl;
cout << "Volume of myCylinder2: " << myCylinder2.cylinderVolume() << endl;


cout<<"Press any key to continue...";
getch ();

}



cylinder

#include
#include "cylinderType.h"
using namespace std;

void cylinderType::setCylinder( double l, double w, double r, double h)
{
circleType::setBase(l, w, r);
if ( h &GT;= 0 ) height=h;
else height=0;
}

double cylinderType::getCylinderBaseCenterX() const
{
return pointType::getX();
}

double cylinderType::getCylinderBaseCenterY() const
{
return pointType::getY();
}

double cylinderType::getCylinderBaseRadius() const
{
return circleType::getBaseRadius();
}
double cylinderType::getCylinderHeight() const
{
return height;
}
double cylinderType::cylinderVolume() const
{
return circleType::baseArea() * height;
}

double cylinderType::cylinderSurface() const
{
return (circleType::baseCircumference() * height + 2* circleType::baseArea());
}

void cylinderType::printCylinder() const
{
printBase();
cout << "Height = " << height << endl ;
}

cylinderType::cylinderType(double l, double w, double r, double h):
circleType(l,w, r)
{
height=h;
}

cylinderType::~cylinderType()
{

}



circle

#include
#include "circleType.h"
using namespace std;

void circleType::setBase( double l, double w, double s)
{
pointType::setXY(l,w);
if ( s >= 0 ) radius=s;
else radius=0;
}

double circleType::getBaseCenterX() const
{
return pointType::getX();
}

double circleType::getBaseCenterY() const
{
return pointType::getY();
}

double circleType::getBaseRadius() const
{
return radius;
}

double circleType::baseArea() const
{
return (3.1415926535*radius*radius);
}

double circleType::baseCircumference() const
{
return 2* 3.1415926535 * radius;
}

void circleType::printBase() const
{
pointType::printPoint();
cout << "radius = " << radius << endl;
}

circleType::circleType(double l, double w, double r): pointType(l,w)
{
radius=r;
}

circleType::~circleType()
{
}


point


#include
#include "pointType.h"
using namespace std;

void pointType::setXY( double l, double w)
{
x=l;
y=w;
}

double pointType::getX() const
{
return x;
}

double pointType::getY() const
{
return y;
}

void pointType::printPoint() const
{
cout << "X = " << x << "; Y= " << y << endl;
}

pointType::pointType(double l, double w)
{
x=l;
y=w;
}

pointType::~pointType()
{
}

1888.

Solve : Please help with batch file problem?

Answer»

Hi,
I wonder if anybody can help?
I am making a batch file but I cannot get the comparison to work.
Where am I going wrong?
Any help or advice appreciated.

Quote

FOR /F "tokens=*" %%R IN ('md5sums -u c:\windows\system32\drivers\tcpip.sys') DO SET curver=%%R

set ver18000=48a5b7570b9a866208ae217acdb72b26 *tcpip.sys

IF "%curver%" == "%ver18000%" (GOTO gotmatch) ELSE GOTO nomatch


:gotmatch
echo got match
GOTO END
:nomatch
echo no match
GOTO end
:end
echo exit

I think it must be something to do with the IF PART. Welcome to the CH forums.

Try this (UNTESTED):

IF "%curver%" equ "%ver18000%" (GOTO gotmatch) ELSE GOTO nomatchYou don't really need an ELSE

IF [test] goto true

echo test failed!
goto end

:true
echo test passed!

:end
WHat are you trying to do and y r u putting quotationmarks around VARIABLES? Why are you resurrecting the dead? Check the post dates...
1889.

Solve : How can i make a batch file start once it is copied??

Answer»

I need to know how to make a batch FILE START itself once it is copied. I am fairly knew to this and really need to know(its on a test, but no one needs to know) We're not supposed to help with tests or homework, because it leads to your teacher thinking you understand something you don't, and then they move to something mroe complicated which MAY be based on the thing you don't understand, which just means you end up coming back here again and again and we end up doing your qualification for you. Approach your teacher for help. Sorry.dirt1996 how is it you know enough to get into the forum and you do not know how to start a batch file? At the top of this page there is a search box.Just type in BAT or BATCH and see the TUTORIALS on this site.

Just try it! All you have to know is how to read and it is a quick read.I know how to start batch.

1890.

Solve : Help creating my first vbscript?

Answer»

I found a way to manually stop the wuauserv from running in our testing lab and I have been ASKED to create a script to put on the DC so when they LOG students in for a a test the pop up to restart does not bother the student. I have no EXPERIENCE with PROGRAMMING and need a little help. I need to create the script so it runs this command:

cs stop wuauserv

Any help in this would be APPRECIATED.

1891.

Solve : VB Constant Height/Width?

Answer»

Hi am I making a program in VB.

I wander if there is any code/option that allow your form size to remain constant? So that when you start the program your form height and width always remain the same and users are not ALLOWED to change it, and also to disable to the maximize button.

Thanks To disable the maximize button, try setting the form property .maximizebox to False

To keep users from resizing the form, try setting the form property .locked to True



Both properties can be set either at design time or run time.

I guessed you using VB.NET for lack of any definite information.I don't REALLY know the difference between VB and VB.net (if there is any) but I'm using
VB 6.0 as part of the visual studios package.

I tried adding the code but it appears VB does not recognize .maximizebox or .locked, And I could find nothing in the properties panel.


SAMPLE CODE
==========
form1.maximizebox = False
form1.locked = true
(or simply) form1.locked
==========


Either way they don't work




The only reason I made the leap to VB.NET was Microsoft gave away free copies of VS2005 when I ATTENDED their launch party. VB6 is a good product, in many ways easier to use, creates smaller exe footprints, but sometimes just not all that intuitive.

To disable the maximize button, try setting the maxbutton form property to False

To prevent users from resizing the form, try setting the form border property to 1 or 3 or 4. Any value that uses a fixed border should work.

Good luck. Yes that was the right stuff thanks. Do not know how I didn't see it before.

1892.

Solve : problem with simple chat program programmed with visual basic?

Answer»

:(Hi, I have an error that keeps coming up when I try to run a simple chat program from the Mastering Visual Basic series. this is the error I get: Run-time error 10054, the connection is reset by remote side. Here is the code that the debugger sends me to:
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim s As String
If bytesTotal > 0 Then
' Data has arrived. Add it to the label control. Maintain
' only the last 2KB of text in the label control.
Winsock1.GetData s, vbString
lblReceivedData = s & vbCrLf & Left$(lblReceivedData, 2048)
End If
End Sub
The complete program:
Option Explicit

Private Sub cmdBind_Click()
' Set the communication properties
Winsock1.RemoteHost = txtPeerMachine
Winsock1.RemotePort = txtPeerPort
Winsock1.BIND txtLocalPort
End Sub

Private Sub cmdSend_Click()
' Send the data to the peer machine
Winsock1.SendData txtSendData
txtSendData = ""
End Sub

Private Sub txtLocalPort_Change()
EnableBinding
End Sub

Private Sub txtPeerMachine_Change()
EnableBinding
End Sub

Private Sub txtPeerPort_Change()
EnableBinding
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim s As String
If bytesTotal > 0 Then
' Data has arrived. Add it to the label control. Maintain
' only the last 2KB of text in the label control.
Winsock1.GetData s, vbString
lblReceivedData = s & vbCrLf & Left$(lblReceivedData, 2048)
End If
End Sub

Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "A Winsock Error has occurred. " & vbCrLf & _
"Error No. " & Number & " " & Description
End Sub

Private Sub EnableBinding()
' Enable the Bind button only if the peer machine,
' peer port, and local port have been SPECIFIED.
cmdBind.Enabled = Len(txtPeerMachine) > 0 And _
Len(txtPeerPort) > 0 And Len(txtLocalPort) > 0
End Sub

The interface is a single from with text boxes for remote host, remote port, local port and send data. Data is received in label. It has a bind and send buttons.
Thanks for any suggestions,
StuartThis may help

http://support.microsoft.com/kb/260018

Quote

SYMPTOMS
A run-time error occurs when you use network communications on a Windows 2000-based computer with a Winsock Control that uses User Datagram Protocol (UDP), and the Protocol PROPERTY of the control is set as sckUDPProtocol.

If a SendData request is sent to a RemoteHost that is not listening on the RemotePort, the DataArrival event fires and indicates that 1 byte of data is available. When you call the GetData method to retrieve that data, the following Microsoft Visual Basic run-time error occurs:
'10054' - "The connection is reset by remote side".
Normally, you can capture the error by using the Error event of the Winsock Control. However, even when the Error event is present for the control, the Error event never fires and a run-time error message box displays.

Code: [Select]RESOLUTION
To work around this problem, use the Microsoft Visual Basic Standard Error Handling MECHANISM to catch the error. This workaround is illustrated in the following code snippet:

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim szData As String

On Error Resume Next
Winsock1.GetData szData
If ERR Then
' handle the error here
End if
End Sub



:)Thanks for your help. I'll try that.
1893.

Solve : using arccos(x) function - Visual Basic?

Answer»

hey everybody,
I have a question involving visual basic -
im creating a program that allows you to draw a TRIANGLE, and will then compute the side lengths and
angle measurements. However, i need to use inverse cosine to figure the angles out.

I know the formula for inverse cosine is
Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

I GET the error "Invalid Call Procedure, or Argument"
and arccos(x)=empty

If any one knows how to use the function, please give me some example CODE.
Thanks alotIn order to make the ArcCos function call, you need to define the function:

Code: [Select]myVar = ArcCos(arg)

Public Function ArcCos(X As DOUBLE) As Double
ArcCos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function

Hope this helps.

1894.

Solve : Using Visual Basic?

Answer»

How I can create a program using visual Basic. My Idea is to count the number of pages from a "PDF" file .which code i can use to create this type of program?This sub procedure LETS you get the page count for a given PDF file. The page count usually appears somewhere in the last 50 lines of the file. Simply open the file in binary mode and parse through the content searching for "/count". To test this, simply add a command button and label control to your Winform. Be SURE to update the path to your PDF file in the command button control's event handler.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Code: [Select]' open the PDF in binary mode & count the pages
' search for "/N xx"
' or "/Count xx"
Dim pages As Long

Public Sub pagecount(sfilename As String)
On Error GoTo a
Dim nFileNum As Integer
Dim s As String
Dim c As Integer
Dim pos, pos1 As Integer
pos = 0
pos1 = 0
c = 0
' Get an available file number from the system
nFileNum = FreeFile
'OPEN the PDF file in Binary mode
Open sfilename For Binary Lock Read Write As #nFileNum
' Get the data from the file
Do Until EOF(nFileNum)
Input #1, s
c = c + 1
If c <= 10 Then
pos = InStr(s, "/N")
End If
pos1 = InStr(s, "/count")
If pos > 0 Or pos1 > 0 Then
CLOSE #nFileNum
s = Trim(Mid(s, pos, 10))
s = Replace(s, "/N", "")
s = Replace(s, "/count", "")
s = Replace(s, " ", "")
s = Replace(s, "/", "")
For i = 65 To 125
s = Replace(s, Chr(i), "")
Next
pages = Val(Trim(s))
If pages < 0 Then
pages = 1
End If
Close #nFileNum
Exit Sub
End If
'imp only 1000 lines searches
If c >= 1000 Then
GoTo a
End If
Loop
Close #nFileNum
Exit Sub
a:
Close #nFileNum
pages = 1
Exit Sub
End Sub

Private Sub Command1_Click()
pagecount ("c:\path\to\your.pdf")
Label1.Caption = pages
End Sub


1895.

Solve : Is there away to do this...?

Answer»

I was wondering if there is a program that can do certain steps that I program it to do, lets say something like hitmanpro (hitmanpro.nl), which updates, scans and cleans your pc using other antispyware programs WITHOUT you doing anything, so what I NEED is something like that so I can save myself alot of steps that I do over and over again on my pc.
I'm not a programmer but I thought someone knows something like this for a noob like me.
Help is appreciatedif you are using windows, you MAY find that vbasic is just the TICKET. Vbasic is easy to learn, code and it handles windows programs very smoothly.
Here is a link to Sesame Script- an ONLINE database of Vbasic hosted by microsoft.

http://www.microsoft.com/technet/scriptcenter/learnit.mspx

1896.

Solve : Name that instruction set!?

Answer»

Name that Instruction set.

This is from an era when SPS , AutoCoder and CardSytems were fashionable!

(Author unknown - SALVO HONORES ET TITULIS)

InstructionMeaning
---------------------------

BAHBranch and Hang
IIBIgnore interrupt and branch
TDBTransfer and drop bits
DODivide and overflow
DCDivide and conquer
SRZSubtract and reset to zero
PICPunch invalid character
SSJSelect STACKER and jam
RASTRead and shred tape
CMIClobber MONITOR immediately
SRSDSeek record and scar DISK
BSTBackspace and stretch tape
RIRGRead inter record gap
UDRUpdate and delete record
RSRandom slew
SSBScramble status byte
EDRExecute destructive read
EIOCExecute invalid OP code
EPExecute programmer
ERMErase reserved memory
PBDPrint and break drum
MLRMove and lose record
CRNConvert to Roman numerals
IDPSIgnore disk protection switch
HCFHalt and catch fire
FOPC(Set) false out-of-paper condition
WUPOWad up printer output
IEOFIgnore end of file
DWITDo what I'm thinking
PPLPerform perpertual loop
ZDZap directory
DSHDestroy sector heading
DAPDeselect active peripheral
SMDSpontaneous memory DUMP
(use only when payroll checks are loaded)
SFTTStrip form tractor teeth
HRPRHang up ruin printer ribbon
ACQTAdvance clock to quitting time
RCFBRead cardfile backwards
IDIInvoke devine intervention
Assembler 'I wish' instructions - more here...

And lots more on the WWW

1897.

Solve : Searching a book?

Answer»

I'm searching the book of David Kruglinski - Visual C++ 5.0/6.0. Can anyone help me - I've been searching in all bookstores and many sites for e-books but I can't find it. PLEASE GIVE a LINK...Maybe these will help?

http://www.hal9k.com/cug/bookstor/

http://www.amazon.com/gp/product/1572318570

http://www.amazon.co.uk/Programming-Microsoft-Visual-David-Kruglinski/dp/1572318570

http://www.alibris.com/search/books/author/Kruglinski,%20David





1898.

Solve : Looking for ideas for network troubleshooting with a VBS?

Answer»

I am working on a VBS script to help troubleshoot an intermittent network / internet PROBLEM, and I was hoping to get some ideas from PROGRAMMERS who may have done something similar.

I don't even have any specific details on the intermittent problem that I am writing this for, but I decided that I would just make it generic as I will probably be able to use it in the future. All I know about the current issue is that she keeps having intermittent problems connecting to the internet, and that she is using a wireless network card. My code so far is basically: check for ICMP echo reply from known IP addresses from close to far, check DNS by pinging hostname, check wireless signal strength. It basically goes like this so far:
Ping local machine
Ping other computer on LAN
Ping gateway / router
Ping DNS server
Ping REMOTE IP
Ping remote hostname
Check wireless signal strength (via WMI)
Log anything that fails, and loop every 30 seconds

I'm sure that there are a lot more things that could be checked, but I'm not sure what or where to look. If anybody has any ideas and / or code samples of what to check or how to check it, please let me know.Gary,

This snippet may help with the pings. Modify it as you will; you can add additional if statements and log the results accordingly.

Code: [Select]Const ForWriting = 2
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile ("c:\Logfile.txt", ForWriting, True)

Do While True
If PingOK("127.0.0.1") = False Then LogError("Cannot reach local machine")
'
' add other ping tests here along with log message
'
WScript.Sleep 30000
Loop

f.Close

Function PingOK(Machine)
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& machine & "'")
PingOK = 1
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode <> 0 Then
PingOK = 0
End If
Next
End Function

Sub LogError(msg)
f.WriteLine msg
End Sub

Signal strength was another story. You can ACCESS it thru the root\wmi namespace using the MSNdis_80211_ReceivedSignalStrength class. The result is a db value that I don't know how to convert to Mbps.

Hope this helps. Thanks, Sidewinder. I actually already have code for the pings and signal strength and logging failures. That all works, but it just seems kind of lame for a network test program because it doesn't seem to test very much to me.

I didn't know if there are more things that could be easily tested. One thing that I did look for but couldn't get to work was if there was a way to detect / log the LAN connection speed - like when you look at your network properties, and it says "Speed: 100.0 Mbps". I found a WMI query for Win32_NetworkAdapter and there was a "speed" property, but I can't get any info from it.

I just thought somebody might have additional ideas like "you can check for dropped network packets and retries with this code" or "a good network test is to use netsh.exe to look for this".

Thanks for the code and help, and please let me know if you have any additional ideas.Not really any new ideas. WMI seems to be trial and error at best. I still like the MSNdis_80211_ReceivedSignalStrength class, if only because it is volatile enough that it may give some hint of impending problems.

A suggestion would be to write it as some sort of a monitor script, so only when the value does change would the log be updated. You could also attempt the pings at this time.

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\WMI")
Set colEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceModificationEvent WITHIN 3 WHERE " _
& "Targetinstance ISA 'MSNdis_80211_ReceivedSignalStrength' And " _
& "Targetinstance.Ndis80211ReceivedSignalStrength > -54")
Do
Set objEvent = colEvents.NextEvent()
WScript.Echo "Signal Strength Modified:", _
objEvent.TargetInstance.Ndis80211ReceivedSignalStrength
'
' Put your pings here
'
Loop

The value on my 802.11g wireless connection varies from -53 to -57, so you may have to play around with the hardcoded value. From what I can tell, the closer to zero the value, the worse the connection.

Let us know how you make out.

Yes, thanks. I played around with it for a while last weekend. The best I could tell from my testing, the values seemed to range from -10 dBm (perfect) to -102 dBm (too weak to do anything). I also NOTICED the -10 would also sometimes show up when there was no signal strength. My testing concluded that:
-11 to -29 is great
-30 to -47 is good
-48 to -65 is OK
-66 to -82 is poor
-83 to -102 is worthless

Here is my code if anybody is interested:
Code: [Select]Function CheckWireless()
Signal = GetSignalStrength()
SSID = GetSSID()
APMac = GetAPMac()
SigPct = round((Signal+102)/.92)
if Signal > -11 Then
QualityStr = "Suspicious"
elseif Signal > -29 Then
QualityStr = "Excellent"
elseif Signal > -47 Then
QualityStr = "Good"
elseif Signal > -65 Then
QualityStr = "Acceptable"
elseif Signal > -82 Then
QualityStr = "Poor"
elseif Signal >= -102 Then
QualityStr = "Worthless"
else
QualityStr = "Suspicious"
end if
LogString = now & ": WiFi signal is " & Signal & " dBm (" & QualityStr & " at " _
& SigPct & "%) from AP " & chr(34) & SSID & chr(34) & " MAC=" & APMac
call LogToFile(Pass, LogString)
if Signal > -11 Then
call LogToFile(Fail, LogString)
elseif Signal < -75 Then
call LogToFile(Fail, LogString)
end if
End Function
I am testing with more wireless cards now, and the Ndis80211ReceivedSignalStrength range appears to depend on the driver. I tried a different card, and the values range from -45 to -90.

1899.

Solve : delphi help?

Answer»

I NEED somme help to a program. I am working in Delphi to a project and there i need to insert somme text, but i don't know how .I need an exemple for the picture that i had atached .


[CLEANING up - attachment DELETED by ADMIN]

1900.

Solve : Hide File in picture?

Answer»

How is it done.
I have heard that you can hide a file in a image and when the image is open the file opens.

I would like to try hide a text document or another picture within a picture so that when it is opened the other file opens.

Can this be done or is it just a rumor spread around online. what does googling for "hide file in image" SAY?http://howto.helpero.com/howto/Hide-Files-in-JPEG-Images_70.html


Try thisi know how to hide image but then the hidden file wont open when the image is open you always need another app like winrar to open it.

what i want to do is open the image then the hidden file opens with itI really don't think we should be discussing this here. Although your intentions may not be malicious, this sort of information could be used to do a lot of damage.ooo sorry chris i didnt know , i will say no-more.




GOOGLE KNOWS ALLQuote from: CBMatt on June 22, 2007, 12:59:27 PM

I really don't think we should be discussing this here. Although your intentions may not be malicious, this sort of information could be used to do a lot of damage.

Every bit of information and code given on here could do damage in the wrong hands even the delete command so why not give advice on this subject?.

I have figured out how to do this through hard searching all i can say is that i am disappointed in this site.

I came here to learn and that i cannot because of people like you who wont help others because you fear that the information will get in to the wrong hands.

Just delete my account and forget it.
I will find another forum where i can learn from real programmers. Quote
I came here to learn and that i cannot because of people like you who wont help others because you fear that the information will get in to the wrong hands.
You could hide a keylogger in a picture and send it to someone. When they open the file, the keylogger would be active and it could send keystrokes via email.

Or you could hide a batch file that would delete c:\ and when they open the picture, their computer is useless.

This is why we don't discuss these topics here. Most of us aren't real programmers, we are just good troubleshooters and we help people with problems, not give other people new problems.

If you want to become a programmer that makes viruses and spyware, go ahead. I couldn't care less. Even though it could throw you in court.

Quote
Every bit of information and code given on here could do damage in the wrong hands
Yeah, and I don't think this post can be used to destroy a computer. Quote from: kentguy07 on June 22, 2007, 05:34:26 PM
I have figured out how to do this through hard searching all i can say is that i am disappointed in this site.

Obviously, you're fully capable of finding the information on your own, so I suppose you didn't need us in the first place. Keep in mind that this is a free help site and we have certain guidelines that we abide by. It won't break my heart to see you leave, but if you change your mind, you're still more than welcome to stop by for advice. Just keep in mind that certain subjects may be a bit on the touchy side.I personally don't see that discussion of steganography is any more DANGEROUS than discussing sticking down an envelope before mailing a letter, or password protecting rar or zip files.

Carbon DudeOxide, if an executable file were "hidden" steganographically in an image file, simply opening that image file in a viewer would most definitely ***NOT*** cause the executable file to be run. You would have to choose to run the image file through a program that would retrieve the buried file and write it out to disk.

There are no image viewers that are capable of dong this.

What kentguy seems to want is, ie, open the image and extract & execute the hidden file is, I agree, potentially capable of malicious mischief and I very much doubt his motives in asking about it.

If steganography is so dangerous, why do so many people concerned with their privacy use Steganos to communicate securely via email, protect passwords, and do quite a few other perfectly legitimate things?


man, this is interesting ......... what did you say ?If an image file uses 24 bits per pixel, 8 each for red, green, and blue, you can throw away the lowest-order bit of each pixel R,G,B value and the picture won't look much different to the naked eye. Those bits could be replaced by the bits of a message. A one million pixel image could therefore hide 3 million bits or nearly 400 Kbytes of information, quite a big text file. If you only needed to hide a short text file, say 1 Kbyte, you could get quite imaginative with where you put the bits. The only trouble is, you can't do this with jpeg images which are compressed. You'd need a bmp type image. Other possibilities are the wav files that make up audio CDs. (but not mp3s for the same reason)

This is called "steganography". The word "Steganography" is of Greek origin and means "covered, or hidden writing". Its ancient origins can be traced back to 440 BC. Herodotus mentions two examples of Steganography in The Histories of Herodotus . Demeratus sent a warning about a forthcoming attack to Greece by writing it on a wooden panel and covering it in wax. Wax tablets were in common use then as re-usable writing surface, sometimes used for shorthand. Another ancient example is that of Histiaeus, who shaved the head of his most trusted slave and tattooed a message on it. After his HAIR had grown the message was hidden. The purpose was to instigate a revolt against the Persians. Later, Johannes Trithemius's book Steganographia is a treatise on cryptography and steganography disguised as a book on black magic.

The CIA has computers capable of finding hidden MESSAGES in image and audio files, I read somewhere.

"I'm glad your around" * nice reads !!!!!!!!!!!!