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.

1701.

Solve : Being Computer Scientist !!!?

Answer»

I love computers very MUCH and want to become a computer scientist.I know JAVA PROGRAMMING and want to know the prerequisites of being a computer scientist.A degree in Computer Science. And you're one more NONSENSE post away from being BANNED.

1702.

Solve : Undeletable file with READ ONLY rights!?

Answer»

I needed to have a "if found pls contact owner ..." file on my desktop
which should be un- editable and undeletable but with READ ONLY rights to it
so here's how I did it...

create the .txt file or perhaps a .bat ( haven't test a .bat THOUGH)

then attrib + r <"file name">

NB:..... in between " "



then
cacls < file name > /e /c /d %username%

NB: "" if file name is more than one word e.g ."IF Found.tx" or just owner.txt without the inverted commas.

and finally

cacls /g /P %username%:r

hope this helps


PS: to reverse the above:
negate the attrib using -r ... and restore the cacls

and then

/e /c /g %username%:f
this will free the file of its read only attribute and restore its ACCESSIBILITY to 'Full'

1703.

Solve : Batch Saving?

Answer»

I have started creating a batch GAME but I do not know how to save, I am relatively new so can you show me the code then how it works? Thanks a lot!You can append an output to a file such as...

@echo. Hello World >>SaveFile.txt

This with the >> will append to the save file if you want a game that has MANY saved states in a single game save file.

If you want a single save state you could use...

@echo. Hello World >SaveFile.txt

And this would overwrite the contents of the PRIOR save game state whenever used to echo information out to file such as echoing to file the last game state values.

Reading in the values you would simply be parsing the text file and importing the values back into variables such as parsing and setting READ in values to variables..

Do you have any batch content to share with us, so we can best assist you with this request? Knowing the EXACT content that you want to save we can show examples of how to save and read in the info.

For a game that you need to save 5 values you could simply echo out the values at the last played state and have a text file that has this inside of it

Quote

2500,1000,50,100,3

Which equals

2500 hp
1000 armor
50 weapon damage min
100 weapon damage max
3 health bottles

Or just

Set>save.txt

And then load:
For %%A in (save.txt) set %%A
Quote from: shiverbob on November 05, 2014, 09:24:49 AM
Or just

Set>save.txt

And then load:
For %%A in (save.txt) set %%A
But then you would probably want to have a specific prefix for the variables used in the game. You wouldn't want to take the risk of accidentally changing a system variable that had already been changed after you played the game last and before you play it again.
1704.

Solve : Bat File Back Up?????

Answer»

I would like to make a .bat file in notepad to COPY a file in a drive to another drive for example...

C:\Users\admgeorgew94\Documents\Matrix
copy to
G:\Backup\shared\Matrix

Thanks

Code: [Select]copy "C:\Users\admgeorgew94\Documents\Matrix\file1.txt" "G:\Backup\shared\Matrix\"Thank you how would I include sub folders?Quote from: georgew94 on November 08, 2014, 09:50:03 AM

Thank you how would I include sub folders?
You would need to use the XCOPY command then. But without further specifics I would not suggest you attempt that YET. BASED on the information you have given so far it sounds like you want to copy the file named file1.txt in all sub folders to one specific destination directory. That would cause the command to prompt you to overwrite the file every time unless you suppressed prompting for an overwrite. But logically it would not make sense to do what I am INTERPRETING at all.
1705.

Solve : Positioning JS with CSS??

Answer»

Hello

Not sure if anyone can help me with this. I know nothing about JavaScript but I have the permission of the author of it to USE on a Web site. It is this:

Code: [Select] <script>
(FUNCTION () {
var n, id, progress;


progress = new CircularProgress({

radius: 20

});


n = 0;
document.getElementById('myPosition').appendChild(progress.el);

id = setInterval(function () {

if (n == 100) CLEARINTERVAL(id);

progress.update(n++);
}, 100);
})();

(function () {
var n, id, progress;

progress = new CircularProgress({

radius: 40,
lineWidth: 2,
strokeStyle: '#FFAED7',
initial: {
lineWidth: 4,
strokeStyle: '#ffffff'
}

});

document.getElementById('myPosition').appendChild(progress.el);

n = 0;

id = setInterval(function () {

if (n == 100) clearInterval(id);

progress.update(n++);
}, 70);

})();

(function () {
var n, id, progress;

progress = new CircularProgress({

radius: 70,
strokeStyle: '#FFAED7',
lineCap: 'square',
lineJoin: 'round',
lineWidth: 5,
shadowBlur: 0,
shadowColor: '#ffffff',
text: {
font: 'bold 15px arial',
shadowBlur: 0
},

initial: {
strokeStyle: '#ffffff',
lineCap: 'square',
lineJoin: 'round',
lineWidth: 5,
shadowBlur: 10,
shadowColor: '#FFB3D8k'
}

});

document.getElementById('myPosition').appendChild(progress.el);

n = 0;

id = setInterval(function () {

if (n == 100) clearInterval(id);

progress.update(n++);
}, 30);

})();

</script>
I have changed the original

document.body.appendChild(progress.el);

to what I have it so that I can position it (a diagram of 3 circles with text in them) in CSS to:

document.getElementById('myPosition').appendChild(progress.el);

but now it's not loading at all!

Thanks for any ideas.




1706.

Solve : JS not passing to php?

Answer»

Hi, I'm baffled here; the two following statements from my JS <BR>file displays the correct values but the code to enter them
into a table enters zeroes. I tried document.write(s) and the
correct values were displayed.what am I missing? Thanks in advance.

Code: [Select]var expression = value1 + op +value2 +'='+ total;
alert(expression);
------------------------------------
Code: [Select]<?php
include('calcbegin.html');
$servername="localhost";
$username="root";table
$password="cookie";
$dbname="homedb";
show
//Createconnection
$conn=newmysqli($servername,$username,$password,$dbname);
//Checkconnection
if($conn->connect_error)
{die("Connectionfailed:".$conn->connect_error);}

$sql="INSERTINTOcalculator(purpose,value1,op,value2,total)
VALUES('$purpose','$value1','$op','$value2','$total')";
if($conn->query($sql)===TRUE)
{echo"Newrecordcreatedsuccessfully";}
else
{echo"Error:".$sql."<br>".$conn->error;}
$conn->close();
?>
Looks like your getting 0's because no values are being passed to VALUES ('$purpose', '$value1', '$op', '$value2', '$total') and so because nothing is passed to them they are 0 and so $total = 0.

From looking at your shared code it establishes a connection to your database, and just passes whatever value the variables are without any data being passed into those variables ( which is usually 0, however because not initialized to 0 it could be different than 0 with bogus info ) to the database as SEEN here:

$sql = "INSERT INTO calculator (purpose, value1, op, value2, total)
VALUES ('$purpose', '$value1', '$op', '$value2', '$total')";

Do you have more code to this to show other than what is shown that shows where the variables are being assigned values? I feel that is where your problem is with this in the variable value assignments.Below is my code in it"s entirety. thanks for any help.
Code: [Select]<?php
include('calcbegin.html');
?>
<html><HEAD>
<script type="text/javascript">
function make_blank()
{ document.form.type.value =""; }
</script>
</head><body><center>
<!-- use ajax - OnCalc function to send data to your database. ???-->
<FORM name="Keypad" action="" method="post">
<input type="text" name="purpose" size="48" value="what's this for?" onFocus="this.value=''">
<TABLE border=2 width=50 height=60 cellpadding=1 cellspacing=5>
<tr> <TD colspan=3 align=middle>
<input name="ReadOut" type="Text" size=24 value="0" width=100%></TD>
<TD></TD>
<TD>
<input name="btnClear" type="Button" value=" C " onclick="Clear()"></TD>
<TD>
<input name="btnClearEntry" type="Button" value=" CE " onclick="ClearEntry()"></TD>
</TR><TR>
<TD>
<input name="btnSeven" type="Button" value=" 7 " onclick="NumPressed(7)"></TD>
<TD>
<input name="btnEight" type="Button" value=" 8 " onclick="NumPressed(8)"></TD>
<TD>
<input name="btnNine" type="Button" value=" 9 " onclick="NumPressed(9)"></TD>
<TD></TD>
<TD>
<input name="btnNeg" type="Button" value=" +/- " onclick="Neg()"></TD>
<TD>
<input name="btnPercent" type="Button" value=" % " onclick="Percent()"></TD>
</TR><TR>
<TD>
<input name="btnFour" type="Button" value=" 4 " onclick="NumPressed(4)"></TD>
<TD>
<input name="btnFive" type="Button" value=" 5 " onclick="NumPressed(5)"></TD>
<TD>
<input name="btnSix" type="Button" value=" 6 " onclick="NumPressed(6)"></TD>
<TD></TD>
<TD align=middle>
<input name="btnPlus" type="Button" value=" + " onclick="Operation('+')"></TD>
<TD align=middle>
<input name="btnMinus" type="Button" value=" - " onclick="Operation('-')"></TD>
</TR><TR>
<TD>
<input name="btnOne" type="Button" value=" 1 " onclick="NumPressed(1)"></TD>
<TD>
<input name="btnTwo" type="Button" value=" 2 " onclick="NumPressed(2)"></TD>
<TD>
<input name="btnThree" type="Button" value=" 3 " onclick="NumPressed(3)"></TD>
<TD></TD>
<TD align=middle>
<input name="btnMultiply" type="Button" value=" x " onclick="Operation('*')"></TD>
<TD align=middle>
<input name="btnDivide" type="Button" value=" / " onclick="Operation('/')"></TD>
</TR><TR>
<TD>
<input name="btnZero" type="Button" value=" 0 " onclick="NumPressed(0)"></TD>
<TD>
<input name="btnDecimal" type="Button" value=" . " onclick="Decimal()"></TD>
<TD colspan=3>
</TD><TD>
<input name="btnEquals" type="Button" value=" = " onclick="Operation('=')"></TD>
</TR></TABLE>
<INPUT type="image" src="programmer.gif" alt="submit button"><p>
</FORM>
<font face="Verdana, Arial, Helvetica" size=2>
<SCRIPT LANGUAGE="JavaScript">
var FKeyPad = document.Keypad;
var Accumulate = 0;
var FlagNewNum = false;
var PendingOp = "";
function NumPressed (Num)
{
if (FlagNewNum)
{ FKeyPad.ReadOut.value = Num;
FlagNewNum = false;
}
else
{
if (FKeyPad.ReadOut.value == "0")
FKeyPad.ReadOut.value = Num;

else
FKeyPad.ReadOut.value += Num;
}
}
function Operation (Op)
{
var Readout = FKeyPad.ReadOut.value;
if (FlagNewNum &AMP;& PendingOp != "=");
else
{
FlagNewNum = true;
if ( '+' == PendingOp )
{
var temp = Accumulate;
Accumulate += parseFloat(Readout);
OnCalc(temp,PendingOp,Readout,Accumulate);
}
else if ( '-' == PendingOp )
{
var temp = Accumulate;
Accumulate -= parseFloat(Readout);
OnCalc(temp,PendingOp,Readout,Accumulate);
}
else if ( '/' == PendingOp )
{
var temp = Accumulate;
Accumulate /= parseFloat(Readout);
OnCalc(temp,PendingOp,Readout,Accumulate);
}
else if ( '*' == PendingOp )
{
var temp = Accumulate;
Accumulate *= parseFloat(Readout);
OnCalc(temp,PendingOp,Readout,Accumulate);
}
else
{
Accumulate = parseFloat(Readout);
}
FKeyPad.ReadOut.value = Accumulate;

PendingOp = Op;
}
}
function Decimal ()
{
var curReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum)
{
curReadOut = "0.";
FlagNewNum = false;
}
else
{
if
(curReadOut.indexOf(".") == -1)
curReadOut += ".";
}
FKeyPad.ReadOut.value = curReadOut;
}
function ClearEntry ()
{
FKeyPad.ReadOut.value = "0";
FlagNewNum = true;
}
function Clear ()
{
Accumulate = 0;
PendingOp = "";
ClearEntry();
}
function Neg ()
{
FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1;
}
function Percent ()
{
FKeyPad.ReadOut.value = (parseFloat(FKeyPad.ReadOut.value) / 100) * parseFloat(Accumulate);
}
function OnCalc(value1,op,value2,total)
{
var expression = value1 + op +value2 +'='+ total;
alert(expression);
}
</SCRIPT>
Code: [Select]<?php
include('gethomedb.php');
//nowconnectedtodatabase
if(!empty($_POST["submit"]))
{
$id=$_POST['id'];
$value1=$_POST['value1'];
$op=$_POST['op'];
$value2=$_POST['value2'];
$total=$_POST['total'];
$name=$_POST['total'];
if(isset($_POST['total']))
{
$fetch="SELECTpurpose,value1,op,value2,totalFROMcalculatorWHEREtotal='".$name."'";
$result=mysqli_query($con,$fetch);
if(!$result)
{echo"Error:".(mysqli_error($con));}
//===========================================================
$query="
INSERTINTOcalculator(purpose,value1,op,value2,total)
VALUES('$purpose','$value1','$op','$value2','$total')";
mysqli_query($con,$query);
mysqli_close($con);
}
}
?>Code: [Select]<a href="http://localhost/home/calcprint.php">PRINT</a>
</body></html>

1707.

Solve : function to validate input??

Answer»

I have the below code:


ABCD 1234:




function validateForm() {
var x = document.forms["myForm"]["FNAME"].value;
if (x == null || x == "") {
alert("You haven't completed this task yet!");
return false;
}
}


In the input, the user needs to type ABCD 1234 as per the name of the form field, If the user inputs no information they get a pop up saying they haven't completed the task yet, however I need it so if the user inputs the ABCD 1234 they'll be granted ACCESS to the next page, and if they PUT in anything different it will return that pop up.

Can anyone help me please?

1708.

Solve : Data Analysis?

Answer»

Hi, we are doing a PROJECT USING R. We were given two spreadsheets containing horse RACING results and we were asked to predict the FUTURE outcomes using the spreadsheets. Any ideas or help would be greatly appreciated.
Thanks!

1709.

Solve : goto issues?

Answer»

You need to define enter at the top of your code.
Don't blame the IF structure.
In batch and in Ch and C you must define or set variables at the start. With a few exceptions.
As for distribution, Ch is so close to C or C++ that you should be able to compile it and distribute it asa an EXE file after you have the code perfected. But If you want others to help you with it, you can give them the link to the free CH IDE.
Here are three resins I would recommend Ch rather that batch as a general tool.
• It has structure closer to C/C++ and can be ported to other platforms.
• It is a better learning tool that batch.
• It comes with a nice IDE. (Integrated Development ENVIRONMENT)

But if you want to use batch. bot ahead. Every time you have a IF statement there must be a GOPTO after it. UNLESS you are very clever.

BTW, there is also Tiny C,which has a very long history. It can be compiled.
http://bellard.org/tcc/
It does very compact x86 code.i defined enter at the top but it is displaying everything like i had said before in the previous reply
Quote from: omnominous on December 02, 2014, 03:25:37 PM

i defined enter at the top but it is displaying everything like i had said before in the previous reply
I didn't see it. Overall, your CH looks good. I still think you will do better in Ch rater than batch. Butch is weird.
Give me some time to run over your Ch code.
If you are going to program this in another language then please report this post and ask the moderators to move this thread to that forum category.Quote from: Squashman on December 02, 2014, 07:48:58 PM
If you are going to program this in another language then please report this post and ask the moderators to move this thread to that forum category.
My apology for diverting this thread.

I look at the C code the OP had and I see not reason to convert it to batch, other than the fact that distributing it is more work.
But Ch and Tiny C are freeware programs and can be made available to anyone.

Perhaps the OP will express his preference again. Quote from: Geek-9pm on December 02, 2014, 09:21:36 PM
My apology for diverting this thread.

I look at the C code the OP had and I see not reason to convert it to batch, other than the fact that distributing it is more work.
But Ch and Tiny C are freeware programs and can be made available to anyone.

Perhaps the OP will express his preference again.
i would like to go back to using Ch because it is an ok program to use.. and i can work on it at school because it is installed on the computers.. well one class.. i wish the library would have it so i can work on it there. i could pull out a 32bit pc and download Ch to my flash drive and use it off of it because i have the 64bit that i use on my flash drive already.The 32 bit version works on any Windows computer. After finding the error with enter it runs NORMALLY. Ch can be installed on a flash drive and run on any Windows PC. For all piratical purposes it is a portable program and does not need to alter the system environment. Provided you put your source code in the same directory.

Glad to hear you school is using an interpreter to teach programming. After about twenty years the schools are now HELPING students learn TOOLS that are relevant to the current state of the art in the commercial world.

MODERATOR. Can the thread be moved into programming?

Quote from: Geek-9pm on December 03, 2014, 12:58:39 PM
MODERATOR. Can the thread be moved into programming?
That is what the Report to Moderator link is for.Quote from: Squashman on December 03, 2014, 01:59:38 PM
That is what the Report to Moderator link is for.
OK. Did it.
Quote from: Geek-9pm on December 03, 2014, 12:58:39 PM
The 32 bit version works on any Windows computer. After finding the error with enter it runs normally. Ch can be installed on a flash drive and run on any Windows PC. For all piratical purposes it is a portable program and does not need to alter the system environment. Provided you put your source code in the same directory.

Glad to hear you school is using an interpreter to teach programming. After about twenty years the schools are now helping students learn tools that are relevant to the current state of the art in the commercial world.

MODERATOR. Can the thread be moved into programming?
the 32 bit version wouldn't work on my 64 bit pc... and there is obviously a problem with the code because it is outputting everything at once after I do 1 and then 1 again...(The OP is now doing his game in Ch, a fast interpreter that conforms to C99 rules. His code now is free of syntax error, but has logical errors.)

I will check the the 32 bit version of Ch on my other machine. I think it should work.
Here is the revised code from the OP. ( sent it via PM)
Code: [Select]/*File: interactive story*/
#include <stdio.h>
int main ()
{
int house;
int forest;
int poster;
int knock;
int thinking;
int enter;
printf("you are in an open forest west of a big abandoned house.\n");
printf("you can see that the front door is boarded up one window is open\n");
printf("there is a poster\n");
printf("if you want to look at poster type 1 if you want to pass press 2\n");
scanf("%d", &poster);
if (poster == 1);
{
printf("Welcome to the interactive story of idk!\n");
printf("\n");
printf("you can explore a haunted house or a forest in this chapter\n");
printf("\n");
printf("you are in an open forest west of a big abandoned house.\n");
printf("you can see that the front door is boarded up one window is open\n");
printf("if you want to go into the spooky house press 1\n");
printf("if you want to go to the forest press 2\n");
scanf("%d", &house);
scanf("%d", &forest);
if (house == 1);
{
printf("you are walking up to the white house.\n");
printf("you hear a noise inside. do you want to knock or enter? 1 for knock or 2 for enter.\n");
scanf("%d", &knock);
if(knock == 1);
{
printf("a big unknown thing breaks down the door and eats you whole. you are dead!\n");
}
if(enter == 2);
{
printf("you open the door and see this tall boney grey thing sitting\n");
printf("on the floor eating something fleshy.\n");
printf("you see a shotgun leaning up against a rocking chair. you are thinking about\n");
printf("picking up the shotgun and shooting it or try to reason with it. 1 for reason or 2 for shoot\n");
scanf("%d", &thinking);
if(thinking == 1);
{
printf("you say hello and asks what he is doing and it says not a word and rips you in two.\n");
printf("bad ending\n");
}

if(thinking == 2);
{
printf("you run and grab the shotgun. the big grey thing turns and looks at you as you blow its head off.");
}
}
}
}
}

Looks like he has too many left brackets.
Anybody?
1710.

Solve : im new to c++?

Answer»

trying to figure out how i would start this problem

Given the equations shown below, the values of x and y can be found using Cramer's Rule.

ax + by = c
dx + ey = f

Cramer's Rule says that determinants can be used to calculate the values of x and y as follows:

Cramer x formula Cramer y formula

To calculate the determinant of a 2 x 2 matrix, cross multiply and subtract the products. For example, the determinant of
sample matrix
is (5 * 6 - 3 * 4) = 18

Write an interactive C++ program that uses Cramer's Rule to solve a pair of linear equations. The program should prompt for 6 integer values that represent the 6 unknowns, a-f.

As output,

* display your name, SECTION #, and the assignment # AFTER the prompts for input
* display the 2 equations and the values of x and y with appropriate labels (see sample terminal session below)

Requirements

* program must read a, b, c, d, E, and f in that order (separate prompts are not necessary)
* a, b, c, d, e, and f must be declared as integers and displayed as integers
* x and y should be declared as double type values (may include decimals)
* your name, section #, and assignment # must be displayed after the input values have been read and before the equations are output
* when displaying the equations, make sure there is exactly 1 blank space between the terms and operators (see sample terminal session)
* the equations and x and y values should be displayed on separate lines
* let the computer use its default settings for displaying x and y (do not set PRECISION)

NOTE: You may assume that the determinant of the denominator will NOT be equal to zero.

Sample terminal session and output:
[[emailprotected]]$ g++ hw03.cpp
[[emailprotected]]$ ./a.out
Please enter integer value for a
4
Please enter integer value for b
6
Please enter integer value for c
4
Please enter integer value for d
2
Please enter integer value for e
-9
Please enter integer value for f
-2

Lee Misch Section #100_ Assignment #3
4x + 6y = 4
2x + -9y = -2
x = 0.5
y = 0.333333
this is really easy, and looks to be homework, try do it on your own and if you get stuck ask for help, if you want us to do it for you then why are you even studying programmign?Hello,
C++ is a programming language.It is combined of console and oops concept.Object oriented programming (OOP) have taken the best ideas of STRUCTURED programming and combined them with several powerful new concept that ENCOURAGE you the approach the task of programming in a new way.
...welcome back after 3 years missing ....

Maybe the aliens are sending people back finally after abductions here. Quote from: DaveLembke on October 12, 2014, 10:06:56 AM

welcome back after 3 years missing ....

Maybe the aliens are sending people back finally after abductions here.
DaveLembke,
Alien abduction?
Did you mean the OP?
OR
Are you refereeing yourself?
1711.

Solve : Microsoft.NET Framework for non-programmers?

Answer»

Microsoft.NET Framework is a huge program and the Updates are even worse. Is it really necessary for casual Internet users (browsing, downloading, email, Office, etc.)? I have three old XP loaded machines and one Windows 8 downgraded to 7. The old machines really need the space. Is it safe, and how, to remove it? I generally use Revo Uninstaller but that may be too much if there are parts of .NET to leave..Net is required for specific software applications to function properly. I'd leave the .Net alone and look for other methods to reduce data that is taking up space such as purging the browser cache, dumping cookies, temporary internet files, and uninstalling any unnecessary software from the systems. * Before dumping cached browser data be sure you know your passwords to sites etc, as for I have seen people do this before and then realize they forgot their password that they havent used in AGES because the computer browser had it stored and now its gone from system as well as the users memory.

You probably should also store any important data such as music, personal data, etc onto an external hard drive as for systems of the age running XP are likely high risk for data loss. Moving this data off these systems onto a large external would free up hdd space.

Other option is to install larger hard drivesQuote from: kenaudivw2 on December 15, 2014, 11:58:31 AM

Microsoft.NET Framework is a huge program and the Updates are even worse.
All the framework versions are <100 MB each. The largest is 68MB or so. Typically you might only need two for most applications to function properly. I find it unlikely that you are in such a case of needing space that you would have to look to deleting system components to get more- particularly since uninstalling the .NET Framework isn't going to recover very much space. It is usually more reasonable to move or delete user files from C:\Users\. The vast majority of data is going to be found there and in larger installed applications.
One useful tool I use to track disk space usage is WinDirStat (website). Very useful.
If it is okay with y'all, may we go a little deeper with this discussion?

What I mean is, what do some of you very experienced Windows OS folks think about upgrading the .Net Framework on our Windows OS units?

One example would be on a Vista machine I have there is in the options for updates an option to install .Net Framework 4.5.1 and I am wondering what some of y'all might think about installing it or not?

Or, even better, as the OP put it here:

Quote
Is it really necessary for casual Internet users (browsing, downloading, email, Office, etc.)?

Is 4.5.1 necessary for the casual Internet user?For Windows Updates, the "updates" as I understand, apply to installed Framework versions. Sort of like how you will be shown Office updates if you have Office installed. So if it is showing you "UPDATE for .NET Framework 3.5" than you already have that software installed- and an update is available for it. You should install most such updates as they appear in Windows Update. Sometimes later versions will appear as optional updates. For example, on my Windows Vista Virtual Machine I see updates for 2.0, 3.5, and 4.0 in the "important updates" section. I have these installed. However, 4.5.1 is in the "optional" update section, because I don't have it installed.

Regarding "Upgrading"- in terms of the actual Framework versions, they aren't 100% upgrading- that is, 4.5.1 is a new version but cannot run every single thing written against earlier versions.

It get's complicated, particularly since some applications written for one framework version may work on another version but another program written against the same version might fail to run on that same version (Different applications can require different parts of the framework). The best approach from a user perspective is to install the framework versions as applications need them. Most programs include installers which will install them. If you are seeing updates in Windows Update for 4.5, for example, and you didn't install it yourself, it is likely that you installed a program which uses it. A common example of this is the Radeon/AMD Front-end Driver software, which will install .NET Framework 4.0. Wow, PC_programmer, You list yourself as a "beginner"? Now I (listed as "familiar") have to go back and relist myself. Is there such a level as "pre-beginner"?
In defense of my concern; Microsoft.NET Framework 2.0 shows as occupying 301MB and 3.0 at 244MB in my XP system. If there is not a good reason to keep NET, that's equivalent to a program the size of MS Office.As has been mentioned, the .NET stuff does not take a lot of space. But some third-party applications can take over 500 MB. When those applications n are ported to .NET, the overall use of disk space is more efficient. When a numberr of applications allude the same run-time library, there is less duplication of the same material in other libraries.

For example, a good floating point library does not have to be very large. But if users what more features and greater precision, the library grows to be larger. Having one large floating point library is more efficient that have five libraries of many sizes and precision.

The above idea could be extended to include other kinds of things that go into libraries. Like SQL resources. Sort routines. Matrix multiplication.
http://en.wikipedia.org/wiki/Runtime_library

At one time it MADE sense to use compilers with program size options. But nowadays users are buying 64 bit systems with 8 GB of RAM and a terabyte of storage. So you can make an argument either way. It HARDLY even matters.

If you don't like updates, don't take them. Quote from: kenaudivw2 on December 16, 2014, 10:02:02 AM
Wow, PC_programmer, You list yourself as a "beginner"? Now I (listed as "familiar") have to go back and relist myself. Is there such a level as "pre-beginner"?
In defense of my concern; Microsoft.NET Framework 2.0 shows as occupying 301MB and 3.0 at 244MB in my XP system. If there is not a good reason to keep NET, that's equivalent to a program the size of MS Office.

One possibility is that the algorithm that is used to try to estimate the disk space usage is incorrect, this could be the case for the .NET Framework- particular 2.0, which only uses typically 20 or so MB.

On XP, I think that algorithm- as detailed in this blog post for the curious, could be to blame.

Quote
It goes through all the programs on your Start menu and compares their names with the display name of the uninstallable item. It looks for Start menu items which share at least two words with the words in the DisplayName.

For example, if there were a Start menu item called "Pretty Decent Windows Program", this would count as a two-word match ("Windows" and "Program").

It then takes the one with the most matches and decides, "Okay, I guess this is it." Suppose for the sake of illustration that the best match is indeed "Pretty Decent Windows Program.lnk", which is a shortcut to "C:\Program Files\LitWare\Decent Program\Decent.exe". Add/Remove Programs would decide that "Awesome Program for Windows" should get the icon for "Pretty Decent Windows Program.lnk", that the frequency of use and most-recently-used information for "C:\Program Files\LitWare\Decent Program\Decent.exe" will be displayed for "Awesome Program for Windows".

But wait, there's more. There's also the program size. Add/Remove Programs looks in your "Program Files" directory for directories whose names share at least two words in common with the DisplayName. The best match is assumed to be the directory that the program files are installed into. The sizes are added together and reported as the size of "Awesome Program for Windows".

So based on that explanation, if for some reason the registration information listing the size is missing (This could be due to things like tune up tools, registry cleaners, etc), Windows will guess the size information by looking for the closest match in Program Files. And given that .NET installs to several folders, and "Microsoft.NET" (The one folder in Program Files that seems directly related) isn't always going to be the best match for ".NET Framework 3.5 Client Profile" it could be getting that size information from the wrong folder- and even if it is the best match, matching that folder will instead list the size of every single framework installed. The differing sizes could be each version matching a different folder.

Of course, that is just a theory. I note something curious, though- on my XP VM I see .NET 4.0 Client Profile listed at 117MB. This size is registered as the size in the listed location in that post. However, when I look at the size of the proper install location, I find that the actual size on disk is actually around 300MB.

Removing a version of .NET you are using won't break anything terribly- you can just reinstall it again if you find that to be the case.

Quote
Wow, PC_programmer, You list yourself as a "beginner"? Now I (listed as "familiar") have to go back and relist myself. Is there such a level as "pre-beginner"?
At some point the forum software was upgraded and that field was not brought forward. I left it at the default because I no longer felt self evaluations were very trustworthy beyond a certain point and there is no way to not enter something. Arguably the more one learns about, the more one learns how much they haven't learned, because of all the PERIPHERY unlearned concepts you find out about along the way. Also when it comes to things like say Graphics Cards I am far more ignorant of specifics and typically defer to the experience of others about whether one Graphics card is going to run better than another.
1712.

Solve : [Help] C# WPF Dispatcher.Invoke (threading)?

Answer»

Im trying to use dispatcher.invoke on an if statement to check if a website can work. I keep getting the thread usage warning. Is there any way to FIX this ? I am Currently not good with background workers or threading with wpf.

I am going to use a loop with this code and have it be used in a thread so when someone pastes a new website to check it wont lag out the program while entering text
Code: [Select] public void CheckOnline()
{
try
{
if (wc.DownloadString(website_1.Text) == "")
{
Dispatcher.Invoke(new Action(() => status_1.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_1.Content = "Not Working"));
}
else
{
Dispatcher.Invoke(new Action(() => status_1.Foreground = Elysium.AccentBrushes.Green));
Dispatcher.Invoke(new Action(() => status_1.Content = "Working"));
}
}
catch
{
Dispatcher.Invoke(new Action(() => status_3.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_3.Content = "Error"));
}
try
{
if (wc.DownloadString(website_2.Text) == "")
{
Dispatcher.Invoke(new Action(() => status_2.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_2.Content = "Not Working"));
}
else
{
Dispatcher.Invoke(new Action(() => status_2.Foreground = Elysium.AccentBrushes.Green));
Dispatcher.Invoke(new Action(() => status_2.Content = "Working"));
}
}
catch
{
Dispatcher.Invoke(new Action(() => status_3.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_3.Content = "Error"));
}
try
{
if (wc.DownloadString(website_3.Text) == "")
{
Dispatcher.Invoke(new Action(() => status_3.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_3.Content = "Not Working"));
}
else
{
Dispatcher.Invoke(new Action(() => status_3.Foreground = Elysium.AccentBrushes.Green));
Dispatcher.Invoke(new Action(() => status_3.Content = "Working"));
}
}
catch
{
Dispatcher.Invoke(new Action(() => status_3.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_3.Content = "Error"));
}
try
{
if (wc.DownloadString(website_4.Text) == "")
{
Dispatcher.Invoke(new Action(() => status_4.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_4.Content = "Not Working"));
}
else
{
Dispatcher.Invoke(new Action(() => status_4.Foreground = Elysium.AccentBrushes.Green));
Dispatcher.Invoke(new Action(() => status_4.Content = "Working"));
}
}
catch
{
Dispatcher.Invoke(new Action(() => status_4.Foreground = Elysium.AccentBrushes.Red));
Dispatcher.Invoke(new Action(() => status_4.Content = "Error"));
}
}
well you could remove ALL the invokes and surround the body in a single Invoke call.

Quote from: BC_Programmer on October 11, 2013, 06:02:41 AM

well you could remove ALL the invokes and surround the body in a single Invoke call.
How would i do that ? I really suck at using wpf, i only use it for making nice looking apps.WPF has nothing to do with the threading solution, FWIW. I've used WPF once, but I've used the WebClient extensively.

I was going to stick exactly what I mentioned (just coalesce it into one invoke). But then I noticed the repetition, as well as the use of DownloadString(), and separated them out.

This version is not tested but should work EXCEPTING minor OVERSIGHTS:

Code: [Select]public void CheckOnline()
{
String[] Websites = new String[]{website_1.Text,website_2.Text,website_3.Text,website_4.Text};
StatusBar[] StatBars = new StatusBar[]{status_1,status_2,status_3,status_4}

for(int i=0;i<Websites.Length;i++){
String site = Websites[i];
StatusBar statbar = StatBars[i];
String TempFileUse = Path.GetTempFileName();
WebClient useClient = new WebClient();
useClient.DownloadFileCompleted+=(s,e)=>{
Dispatcher.Invoke(()=>{
if(e.Error!=null){
statbar.Foreground = Elysium.AccentBrushes.Red;
statbar.Content = "Not Working";
}
else {
statbar.Foreground = Elysium.AccendBrushes.Green;
statbar.Content = "Working";

}
File.Delete(TempFileUse);
})};
useClient.DownloadFileAsync(site,TempFileUse);

}

}

Basically it just combines each test, since each one simply uses a different status bar and a different website, those are gathered into corresponding arrays. Then the array is iterated over and with each one a new WebClient is created. the DownloadCompleted event is set to the appropriate code to set the color and text, using the EventArgs passed in to determine if an Error occurred, and then delete the temporary file; the WebClient's DownloadFileAsync is then called.

Note that each event handler uses Invoke() with multiple-line arguments (in fact, I use multi-line lambda's more than once).

If CheckOnline itself is running in another thread (why?) then the initialization logic for the arrays will need to be within a similar Invoke lambda.need help in creating a batch with below conditions.
i have abc.txt file. i want to read this file and load header and TRAILER information in xyz.txt file. and i want to accoplish this using batch file.
can you please help me in this
1713.

Solve : trying to pass JS to PHP?

Answer»

I need for someone to advise how I'm going wrong with passing my
JS "FUNCTION(OnCalc()" in the FORM named "calculator.html" to my database:
My form presents as desired but submitting enters 0.00 values.
I just need to know if the following syntax and procedures are correct.
Thanks.
--------------------------------------------------------
this is from "calculator,html"

Code: [Select]&LT;FORM name="Keypad" action="http://localhost/home/calc_redirect.php" method="post"&GT; // ??????

if (value1 == parseInt(num))
{value1.value = parseInt(value1.value)}
else
{value1.value = parsefloat(value1.value)}

if (value2 == parseInt(num))
{value2.value = parseInt(value2.value)}
else
{value2.value = parsefloat(value2.value)}

if (total == parseInt(num))
{total.value = parseInt(total.value)}
else
{total.value = parsefloat(total.value)}

/* var expression = value1 + op +value2 +'='+ total;
alert(expression); */
}
function OnCalc(value1,op,value2,total)
{
</SCRIPT>-------------------------------------------------------
Code: [Select]<?php
//nameofthisis"calc_redirect"
/*Theheader()sendsarawHTTP/1.1specificationspecificheader.header()mustbecalledbeforeanyactualoutputissent*/
/*Redirectbrowser*/
header("Location:http://localhost/home/calculator.php");//?????
exit;
?>--------------------------------------------------------
this is from "calculator.php":
Code: [Select]$query = "
INSERT INTO calculator (purpose, value1, op, value2, total)
VALUES ('$purpose','$value1','$op','$value2','$total')";
mysqli_query($con, $query);
mysqli_close($con);
?>Code: [Select]<a href="http://localhost/home/calc_print.php">Print</a>
</center></BODY></html>--------------------------------------------------------






1714.

Solve : Try an Hour of Code?

Answer»

If you already enjoy code, you may FIND this amusing. But the real value of this article is the value it has to introduce computer coding to people who NEVER program.
Here is a long introduction.
Hour of Code initiative introduces Mon-Yough AREA students to computer programming
Here is the short introduction.
http://www.tynker.com/
Show it to friends who avoid computers coding. Or their kids.

Google: Hour of Code

Disclaimer: The ARTICLES may relate to a product being sold for children. This is not an endorsement either from CH or myself. (The product is , IMO, overpriced.)Did the school also introduce a Plumbing course for people who never plumb?I did the Hour of Code in my school when it was in beta(i guess) It had alot of problems. I did it again and due to the amount of people it crashed alot.

1715.

Solve : Replace Spaces with Multiple Characters Batch Script?

Answer»

I am writing a Windows .BAT file which takes user input and creates a VARIABLE from their response. I need any SPACES within their response to be replaced with the characters %20 and then create a variable from the new string. How can I do this?

For example:
User is PROMPTED: What is your company name?
User answers: This is my company name
variable= This%20is%20my%20company%20name@echo off
setlocal enabledelayedexpansion
set string1=This Is My Company Name
set STRING2=!string1: =%%20!
echo string1 %string1%
echo string2 %string2%

output:

string1 This Is My Company Name
string2 This%20Is%20My%20Company%20Name

Works like a charm!
Thanks Salmon Trout!

1716.

Solve : programming help need??

Answer»

i want to BECOME a programmer.what shoud i do.i m stranger.and DONT know anything>START reading......

http://www.google.com/#hl=en&source=hp&q=becoming+a+programer&aq=f&aqi=g1&aql=&oq=&gs_rfai=&fp=6fb550a2476ba2a

1717.

Solve : File Metadata and java?

Answer»

In windows xp when you right clicked a file and then clicked properties you could view a file's metadata. It had date created, modified ect. In another tab there was title, author, comment, etc.

In Linux I use thunar and there are different file properties, who has what access rights to the file and emblems, etc.

My questions are:
1: Are all the properties attached to the file, or are some in a database stuck to the operating system?
2. With java how do I access these properties?
3. Can I create my own properties and attach it inside of the file? Might be able to with an API:

https://msdn.microsoft.com/en-us/library/ms404384%28v=vs.110%29.aspxQuote from: TheWaffle on January 23, 2015, 11:22:57 AM

In windows xp when you right clicked a file and then clicked properties you could view a file's metadata. It had date created, modified ect. In another tab there was title, author, comment, etc.

In Linux I use thunar and there are different file properties, who has what access rights to the file and emblems, etc.

My questions are:
1: Are all the properties attached to the file, or are some in a database stuck to the operating system?
2. With java how do I access these properties?
3. Can I create my own properties and attach it inside of the file?

The properties you MENTION are stored in an alternate data stream on the file itself. Alternate Data streams are effectively files attached to the same filename, but as a sort of "subfile".



As luck would have it I fiddled about with this a few years ago. I didn't work on actually parsing the data in the properties, I was mostly interested in Alternate Data Streams (and less on specifically what they contained). So Even once you read the SummaryInformation data stream you would need

Programmatically, there are three ways to get the Alternate Data Stream information from the file. From a Java perspective it is important to note that ALL of these methods will involve the Win32 API. I can't remember how that is accessed from Java but I remember it being unpleasant.

You can either use ntQueryInformationFile to directly QUERY data from the file itself. This is a low level function. If you cannot do that for whatever reason, you can use BackupRead, and read the file as a Backup program would. Files opened with "Backup Semantics" Basically read in all the data for the file, including any alternate Data streams. The fun PART at that point is actually parsing the data and separating the various alternate data stream headers. Loads of fun because it is naturally not documented.

I wrote an implementation using ntQueryInformation File in VB6 here, but I doubt it will be very easy to port to Java. and Here is an implementation in the same language which uses the Backup functions.

Thankfully, this magic is only truly needed to see what data streams are present in a file. You can OPEN them without special logic... but, unfortunately, only when directly using the Win32API. Java (And .NET, and most languages) complain that the filename is invalid because it contains a colon. (you can specify alternate streams with a colon, such as "readme.txt:Zone.Identifier" but few programs support this.)




1718.

Solve : VB .NET Code Stops Executing?

Answer»

I'm having an issue with my Visual Basic .NET code. I've never seen this before. I don't have any sort of threading, so it's just blowing me away. I'm using .NET Framework 4.5 and this is a WinForms app. My code is below, with comments indicating where I'm having issues with. I'm compiling for x86 architecture. I've tried using a WebBrowser HtmlDocument, a WebKit.DOM.Document object, and now using the HTML Agility pack. The objective of this application is to REPLACE the IMVU Silent Room Observer at http://www.imvu-e.com/products/sro/. I'm using Visual Studio 2012 Express. Please ask if you have a question. Thank you in advance!

Code: [Select] Friend Sub FetchRoomMeta(ByVal roomtag As String, Optional ByVal silent As Boolean = False)
If Not silent Then : Me.lblGettingRoomData.Visible = True : End If
roomtag = roomtag.Replace("http://", "").Replace("https://", "").Replace("www.", "").Replace("imvu.com/rooms/", "")
Dim r As New IMVURoom()
r.TagName = roomtag
r.URL = "http://www.imvu.com/rooms/" & r.TagName
Dim req As Net.HttpWebRequest = Net.HttpWebRequest.Create(r.URL)
req.UserAgent = "IMVU-SROR/" & My.Application.Info.Version.ToString()
Dim res As Net.HttpWebResponse = req.GetResponse()
If r.Occupants IsNot Nothing Then
r.Occupants = New List(Of String)
End If
Application.DoEvents()
Dim enc As System.Text.Encoding = (IIf(res.ContentEncoding = "UTF-8", New System.Text.UTF8Encoding, New System.Text.ASCIIEncoding))
' -----> Line below is the last line to execute
Dim htbytes As Byte() = {} : res.GetResponseStream().Read(htbytes, 0, res.ContentLength) : Dim httext As String = enc.GetString(htbytes)
' -----> This line is never reached and never executes
Dim resp As New HtmlAgilityPack.HtmlDocument : resp.LoadHtml(httext) : r.Occupants.Clear()
r.FriendlyName = resp.GetElementbyId("rm_name_name").InnerHtml
r.LaunchURL = resp.GetElementbyId("join_link").Attributes("href").Value
r.MaxOccupants = Byte.Parse(resp.GetElementbyId("rm_participants").InnerHtml.Split("/")(1).Trim())
For Each n As HtmlAgilityPack.HtmlNode In resp.GetElementbyId("participant_table").FirstChild.NextSibling.FirstChild.ChildNodes
If n.Name = "tr" Then
r.Occupants.Add(n.FirstChild.InnerHtml)
End If
Next n
For i As Byte = 0 To Rooms.Count - 1 Step 1
If r.URL = Rooms(i).URL Then
Rooms.RemoveAt(i)
Rooms.Insert(i, r)
End If
Next i
If Not silent Then : Me.lblGettingRoomData.Visible = False : End If
End Sub
Code: [Select]Dim htbytes As Byte() = {} : res.GetResponseStream().Read(htbytes, 0, res.ContentLength) : Dim httext As String = enc.GetString(htbytes)
This will throw an ArgumentOutOfRangeException every time. Stream.Read() requires a buffer that is already the required size for the data you want to read, but htbytes is always empty.

I expect the exception is getting swallowed further up the stack, meaning the stack unwinds and it never get's further through the method. though copy-pasting a single method out of an obviously larger project leaves a lot to my imagination.Made changes, unable to UPDATE the first post to reflect the new code. Still have the issue, though initializing the array to (res.ContentLength - 1) because of 0-based arrays. Also attached full code file, though I fail to see the point. This may just be my foggy brain and stubbornness at work causing me so much trouble, that's why I ask for some slightly fresher eyes to look at it. Big fan by the way, BC_Programmer. Been surfing CH for a long time, seen you everywhere.

Code: [Select]Friend Sub FetchRoomMeta(ByVal roomtag As String, Optional ByVal silent As Boolean = False)
If Not silent Then : Me.lblGettingRoomData.Visible = True : End If
roomtag = roomtag.Replace("http://", "").Replace("https://", "").Replace("www.", "").Replace("imvu.com/rooms/", "")
Dim r As New IMVURoom()
r.TagName = roomtag
r.URL = "http://www.imvu.com/rooms/" & r.TagName
Dim req As Net.HttpWebRequest = Net.HttpWebRequest.Create(r.URL)
req.UserAgent = "IMVU-SROR/" & My.Application.Info.Version.ToString()
Dim res As Net.HttpWebResponse = req.GetResponse()
If r.Occupants IsNot Nothing Then
r.Occupants = New List(Of String)
End If
Application.DoEvents()
Dim enc As System.Text.Encoding = (IIf(res.ContentEncoding = "UTF-8", New System.Text.UTF8Encoding, New System.Text.ASCIIEncoding))
Dim htbytes(res.ContentLength - 1) As Byte
res.GetResponseStream().Read(htbytes, 0, res.ContentLength)
Dim httext As String = enc.GetString(htbytes)
' -----> Previously never executed, executes now
Dim resp As New HtmlAgilityPack.HtmlDocument()
' -----> Now never executes
resp.LoadHtml(httext)
r.Occupants.Clear()
r.FriendlyName = resp.GetElementbyId("rm_name_name").InnerHtml
r.LaunchURL = resp.GetElementbyId("join_link").Attributes("href").Value
r.MaxOccupants = Byte.Parse(resp.GetElementbyId("rm_participants").InnerHtml.Split("/")(1).Trim())
For Each n As HtmlAgilityPack.HtmlNode In resp.GetElementbyId("participant_table").FirstChild.NextSibling.FirstChild.ChildNodes
If n.Name = "tr" Then
r.Occupants.Add(n.FirstChild.InnerHtml)
End If
Next n
For i As Byte = 0 To Rooms.Count - 1 Step 1
If r.URL = Rooms(i).URL Then
Rooms.RemoveAt(i)
Rooms.Insert(i, r)
End If
Next i
If Not silent Then : Me.lblGettingRoomData.Visible = False : End If
End Sub

[attachment DELETED by admin to conserve space]Question:
What does this mean?
Quote

..objective of this application is to replace the IMVU Silent Room Observer at http://www.imvu-e.com/products/sro/
Do you mean you want to compile a windows program to run on a web server?Regarding the code thing, In order to get anything I could actually test I had to basically guess about things like IMVURoom and Rooms. Looks like I guessed IMVURoom incorrectly (I created a class, when it is a structure in your original) but guessed Rooms right (List of IMVURoom). Luckily I was able to find the Agility pack right in NuGet so I then just had to staple a few controls onto the form and guess what their actual type was, but there were only 2 that I saw at the time.

After making the change and replacing my Class version of IMVURoom with the struct and initializing the byte array, it now seems to load the data up fine but crashes at the attempt to clear the Room occupants, since the list is nothing.

Fixing that, it crashes at the attempt to get the Element by the ID. looking at the Data result, it's cut off. Was it too short? So I used Response.length and doubled it in both places. Still cut off in the same location.

I was able to fix that by replacing that segment with a StreamReader and using it to Read to the End of the Stream. I'm uncertain as to why, specifically, that fixes it, though.

The bigger PROBLEM is that all the Elements you retrieve are going to be empty because they are intended to be populated by client-side javascript, which an HTML parser isn't going to run.

Here is the changed version of that function anyway. I don't know how you might fix the issue where the links and other information are filled out by Javascript code, though.

Code: [Select]Friend Sub FetchRoomMeta(ByVal roomtag As String, Optional ByVal silent As Boolean = False)
If Not silent Then : Me.lblGettingRoomData.Visible = True : End If
roomtag = roomtag.Replace("http://", "").Replace("https://", "").Replace("www.", "").Replace("imvu.com/rooms/", "")
Dim r As New IMVURoom()
r.TagName = roomtag
r.URL = "http://www.imvu.com/rooms/" & r.TagName
Dim req As Net.HttpWebRequest = Net.HttpWebRequest.Create(r.URL)
req.UserAgent = "IMVU-SROR/" & My.Application.Info.Version.ToString()
Dim res As Net.HttpWebResponse = req.GetResponse()
If r.Occupants IsNot Nothing Then
r.Occupants = New List(Of String)
End If
Application.DoEvents()
Using sr As New StreamReader(res.GetResponseStream())
Dim httext As String = sr.ReadToEnd()
Dim resp As New HtmlAgilityPack.HtmlDocument
resp.LoadHtml(httext)
r.Occupants.Clear()
r.FriendlyName = resp.GetElementbyId("rm_name").InnerHtml
r.LaunchURL = resp.GetElementbyId("join_link").Attributes("href").Value
r.MaxOccupants = Byte.Parse(resp.GetElementbyId("rm_participants").InnerHtml.Split("/")(1).Trim())
For Each n As HtmlAgilityPack.HtmlNode In resp.GetElementbyId("participant_table").FirstChild.NextSibling.FirstChild.ChildNodes
If n.Name = "tr" Then
r.Occupants.Add(n.FirstChild.InnerHtml)
End If
Next n
For i As Byte = 0 To Rooms.Count - 1 Step 1
If r.URL = Rooms(i).URL Then
Rooms.RemoveAt(i)
Rooms.Insert(i, r)
End If
Next i
End Using
If Not silent Then : Me.lblGettingRoomData.Visible = False : End If
End Sub


Upon doing a little more digging, I've discovered the Javascript variable on Line 668 (may vary) called roomInfo. If I can DIRECT the parser to the correct script element, extracting it should be a piece of cake. Thank you for your help! I'm going to mark the issue as solved.
1719.

Solve : Batch file to check the folder size?

Answer»

@sun_os:

Where did this come from?

Quote

c:\document and setting\administrator: 10,182,572,281 MB

The output is C:\Documents and Settings\Administrator 9710.8577

Are you sure the 10,182,572,281 represents MB (which is an awful lot) or just bytes (more reasonable)

It turns out that 10,182,572,281 bytes is 9710.8577 MB. Imagine that!

The file size for both the onscreen display and the csv line are computed the same way. I cannot reproduce the error. Need more info.

@nuckinfutz :

Please start your own thread. This marathon thread has gone on for 29 posts with no end in sight. Your post is only complicating things.



Hi Sidewinder,

How can I start the New Thread here?

Could you tell me, is that mean send you the personal messages ?

I copy your code and run cscript //d check.vbs , check with csv format which is not match the console information



Quote from: sun_os on July 20, 2010, 07:37:35 AM
How can I start the New Thread here?

That was for nuckinfutz who tried to hijack your thread.

Quote from: sun_os on July 20, 2010, 07:37:35 AM
Could you tell me, is that mean send you the personal messages ?

No. I very rarely even check if I have messages much less answer them. I prefer to post solutions that everyone can read.

Quote from: sun_os on July 20, 2010, 07:37:35 AM
I copy your code and run cscript //d check.vbs , check with csv format which is not match the console information

I cannot reproduce your results:

Quote
C:\Temp>cscript untitled.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Please enter directory name: d:\wfc\testlib
D:\WFC\Testlib: 1.6922 MB

C:\Temp>type dirsize.csv
D:\WFC\Testlib,1.6922

Unless I'm missing something, the console and the csv file matches. The only difference is the format of the output, but the data is the same. You wanted a csv file (comma separated values).

CSV files are useful when you need to input the data into a spreadsheet or database program. They are also easy to parse.


Hi
I capture the screen shot for your reference

C:\temp>cscript check.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.


Please enter directory name: c:\downloads
C:\Downloads: 5,203,235,307 MB

C:\temp>type disk*
系統找不到指定的檔案。

C:\temp>type dir*

DirSize.csv

C:\Documents and Settings\Administrator,9710.8577
C:\Downloads,4962.1919
C:\Downloads,4962.1919

C:\temp>

That is output

ThanksPlease check your code. I'm not understanding any of this. It appears the line that produces the console output has a problem.

The line produces the console output:
Quote
WScript.Echo f.Path & ": " & FormatNumber((f.Size / 1048576),4,,TriStateTrue) & " MB"

This line produces the CSV file output:
Quote
fs.WriteLine f.Path & "," & Replace(FormatNumber((f.Size / 1048576),4), ",", "")

Also check this line:
Quote
Set fs = fso.OpenTextFile("c:\temp\DirSize.csv", ForAppending, True)
The above line shows the path to the CSV file. If you changed it that's fine as long as you know where the CSV file is.

If this doesn't turn up anything, please post the script you are using. If you made any changes leave them in. Need to see the actual code that runs.

Hi Sidewinder

I run the same script on the another workstation, it is no problem on the size checking. I think something wrong on my workstation.

Last time, I request to check the directory size, the code is FOCUS on that. If the script can let me check the size of drive or directory folder option. I need to use compond condition if....if.... then....elsif condition

Thanks
Quote from: sun_os on July 20, 2010, 08:59:56 PM
Hi Sidewinder

I run the same script on the another workstation, it is no problem on the size checking. I think it may be something wrong with my workstation.

Last time I have the problem on the script to do the check the size, but I get message from my boss, he needs to check the CASE is run the script can show all the size of directory at once.

I check the all KB / MSI folder size under the directory e:\Patches$\KBXXXX\xxxxx and output to csv with the size, but it is different folder in the KBxxxx folder directory. The script is complex and need to to in effort to do that?

Thanks




Glad to see you got the script working. Not sure what could have caused the error on you other machine. VBScript is very forgiving where objects and variables are destroyed when the script ends. An exception is application objects (Word, Excel, etc) where they must be Quit, otherwise you'll find them in your task list long after the script ends.

Quote
Last time I have the problem on the script to do the check the size, but I get message from my boss, he needs to check the case is run the script can show all the size of directory at once.

Not sure what you're asking. I tweaked the script to display the subfolders. I also added a unit of measure to the CSV file so the numbers make more sense.

Be aware that the FileSystemObject recurses the directory tree when computing the size property. Each folder size includes all of it's subfolders. The numbers you see are correct but may appear inflated.

It's possible to retrieve the files from a recursive folder search, but the total size of the files will probably not add up to the size of the folder unless the folder has no subfolders. This would be easier in BATCH, however batch arithmetic only deals with integers. This can lead to some wildly inaccurate results. Hey! 700k bytes here, 700k bytes there, and pretty soon you're talking about some serious real estate.

Code: [Select]Const ForAppending = 8

Set fso = CreateObject("Scripting.FileSystemObject")
Set fs = fso.OpenTextFile("c:\temp\DirSize.csv", ForAppending, True)

Do
WScript.StdOut.Write "Please enter directory name: "
strFolder = WScript.StdIn.ReadLine
If fso.FolderExists(strFolder) Then
Exit Do
Else
WScript.StdOut.Write "Invalid Directory ... Try Again" & vbCrLf
End If
Loop

Set f = fso.GetFolder(strFolder)
WScript.Echo f.Path & ": " & GetEditSize(f.Size)
fs.WriteLine f.Path & "," & Replace(GetEditSize(f.Size), " ", ",")
GetThePaths(f)

fs.Close


Sub GetThePaths(Folder)
For Each Subfolder in Folder.SubFolders
WScript.Echo SubFolder.Path & ": " & GetEditSize(SubFolder.Size)
fs.WriteLine SubFolder.Path & "," & Replace(GetEditSize(SubFolder.Size), " ", ",")
GetThePaths Subfolder
Next
End Sub

Function GetEditSize(intSize)
If intSize => (1024*1024*1024*1024) Then
GetEditSize = Round(FormatNumber((intSize/(1024*1024*1024)), 4,, TriStateTrue), 2) & " TB"
ElseIf intSize => (1024*1024*1024) Then
GetEditSize = Round(FormatNumber((intSize/(1024*1024*1024)), 4,, TriStateTrue), 2) & " GB"
ElseIf intSize => (1024*1024) Then
GetEditSize = Round(FormatNumber((intSize/(1024*1024)), 4,, TriStateTrue), 2) & " MB"
ElseIf intsize => 1024 Then
GetEditSize = Round(FormatNumber((intSize/1024), 4,, TriStateTrue), 2) & " KB"
Else
GetEditSize = intSize & " Bytes"
End If
End Function

I'm sure we'' here from you again. Quote from: Sidewinder on July 21, 2010, 08:21:39 AM
batch arithmetic only deals with integers.

... and runs out of steam at 2 G (32-bit signed integer)
Hi Sidewinder,

Great !

I 'm appreciate your helpful and support the code. I can get the result what I want.

Are you programme ? You are specialist for vb script. Except for Microsoft link, what is other link for script which is useful for beiginner. VBscript. Batch , Shell script


Thank you very much ! Quote from: sun_os on July 24, 2010, 04:06:43 AM
Are you programme ? You are specialist for vb script.

I'm retired now after being in IT my entire career from EAM operator to systems administrator. Currently I run a small business in the local village helping some of the small business owners with their software needs and day to day PC operations.

For batch CODING I always recommend this site

For VBScript check out this tutorial

Also do a search on your hard drive for a file named script56.chm. This is a VBScript reference with lots of examples. Never leave home without it. If you can't find it on your hard drive, you can download it from here

Good luck.


I come from H.K. and work for system engineer. My employment is only for the three months CONTRACT. The IT in H.K. is no long term career, company prefer to recruit the outsource to support the inhouse I.T operation.

I have a dream to start the own business but it is a lot of competitor in Hong Kong. The profit margin is not very good in Hong Kong.

May I know where are you living ?


Enjoy your life and retirement !

1720.

Solve : Batch move files that are consecutive to the same folder USING NOTEPAD?

Answer»

I am trying to batch move consecutive named files with the same extension to a particular folder.
EXAMPLE: "G:\PHILHARMONIA DOWNLOAD\violin\violin_A3_1_forte_arco-normal.mp3" (this folder has all of the files currently), but I have created a destination folder also.

In the above, I would like to add:_B3_1_, _C3_1_, and ETC. to move into the same directory. I would also like to add that there is also (_A4_1_, _B4_1_) files, but I want to repeat the code and have them go to a different folder once I figure this out. So basically, all 3's are in the same folder and etc. Can someone please help me out here?

I am looking to do what I asked and not the following, because it moves everything with the same extension.The only way that I have seen is using this for example, which again is not what I asked:
"@echo off

REM Documents
move *.docx C:\Users\username\Documents move *.pdf C:\Users\username\Documents
move *.xls C:\Users\username\Documents
move *.txt C:\Users\username\Documents

REM Music
move *.mp3 C:\Users\username\Music

Thamks in advance!Hello, let me say something. (Sorry, I can't do the batch for you.)
Have you considered using other tools to organize your STUFF?
Look around and you can find free advanced file management software.
http://www.techsupportalert.com/best-free-file-manager.htm
Quote

The various special features that I'm looking forward to in a file manager are Dual panes, Tabbed interface, Bookmarks, History, Archive handling, Advanced File Search, MultiRename, Folder Size Enumeration, Folder COMPARE and Synchronize, FTP support, File VIEWER, File sorting, File splitter, Filtered view, Keyboard shortcuts, Easy access to system folders and more.
So here are top 5 products that I've found after months of testing. Their interface, features and customization are among the best and curated accordingly in each of the products.
He goes on to mention
FreeCommander XE
Unreal Commander
Nomad.NET
Multi Commander
Master Commander

Just saying that it might save you time and bring you a new tool.

Now somebody else will show you how in batch. You can use wildcards other than the simple star, dot, extension, (like *.mp3). For example, ASSUMING that your music file names just have these character groups A3_1, B4_1 in one place only you can build a wildcard like this

move *A3_1*.mp3 [some folder]
move *A4_1*.mp3 [some folder]
move *B5_2*.mp3 [some folder]
move *C6_41*.mp3 [some folder]
etc

Or if the only place you have a number followed by an underscore is here:

violin_A3_1_forte_arco-normal.mp3

then *3_*.mp3 would find all the 3s in that place.


Hi
Here is a starting batch file to test, just for searching : Search_MP3_Pattern.bat
Code: [Select]@echo off
Title Searching mp3 files with special pattern . . .
Color 9E & Mode con cols=75 lines=3
set "Master_Folder=C:\users"
set "Pattern=*_??_?_*.mp3"
set "LogSearch=%~dpn0.txt"
echo(
echo Please wait ... Searching "%Pattern%" files is in progress ...
Where /R "%Master_Folder%" "%Pattern%" /F >"%LogSearch%" 2>&1
start "" "%LogSearch%"
1721.

Solve : Tryting to clone accidentally ruined my computer!?

Answer»

I am having a panic attack as I just lost 1 tb of my files.

I purchased a 250GB ssd as an upgrade for my 80gb one. I backed up my 1TB HARDDRIVE 2 days ago, and was going to back up the 80gb SSD ONTO the harddrive, but I accidentally cloned it. When my computer REBOOTED the 1TB HDD was renamed to the E: drive, the H: drive is GONE (NOTHING brings it back up) Everything that was on my hard drive is gone, and I can't find out how to remove or restore old options. The drive now thinks it's only an 80 gb drive also. I had many important files on the hard drive. ANYTHING information you can help me with would be great!Triple Post...

Topic Closed.

1722.

Solve : NOTEPAD PROBLEM, PLEASE HELP!!!?

Answer»

I want to create a BAT file in Notepad that would automatically create a VBS file ( with command msgbox"blabla" , voice command, etc ) in a folder that i choose, by COPY CON command...
I tried this code&GT;>>
cd c:\
cd users
cd %userprofile%
cd desktop
copy con hello.vbs
msgbox"Bla!"

but it doesn't make file, it only opens CMD and goes to >>> copy con hello.vbs <<< then pauses and waits for me to type in what I want to be in VBS file...
Please help...quickly if not a problem...Quote

copy con hello.vbs
Does just what you asked it to do.

Are you using voice recognition software inside of notepad?
Please explain.I'm not using ANYTHING...I want to make a bat file that will create vbs file automatically,but the problem is that it runs cmd and stops at COPY CON,WITHOUT making a file...Quote from: AMS on June 28, 2010, 03:30:39 PM
it runs cmd and stops at COPY CON,without making a file...

That is normal. CON is the keyboard INPUT stream. When the batch "stops" it is WAITING for you to TYPE msgbox.vbs (with your fingers) and then do CTRL-Z then ENTER.

You are doing this the wrong way. This is how a batch file would do it:

Code: [Select]echo msgbox "Bla!">hello.vbs


Tnx, a lot!Just one more question, how can I enter a new line for that vbs? For example,if I want to enter command

StrText="thank you"
set ObjVoice=CreateObject("SAPI.SpVoice")




ObjVoice.Speak StrText


> creates/overwrites
>> appends

echo StrText="thank you">my.vbs
set ObjVoice=CreateObject("SAPI.SpVoice")>>my.vbs

1723.

Solve : Using Solver to make combination in excel?

Answer» Hi I'am using solver tool in order to MAKE combination from various payments to reach a GIVEN total of payments by using some of those payments, solver automatically identify which payments should be CONSIDERED to make the combination, However when I take large NUMBER of payment the solver tool is keep running until I kill the task from task manager. Is there any way to solve this issue.?

Thanks
1724.

Solve : question on some programs I have loading on start?

Answer»

Thank you for your HELP. I have been without my own computer since it crashed Right now on a loaner

Should I delete this program that show up in Running Processes?

PID 0
Image Name [System Process]
Version
Name
TYPE [unknown]
Parent 0
Threads 1
Priority 0
Window Title
Creation Time
Running Time
Kernel Time
User Time
Size 16,384
File Name and Path
Command LINE with Parameters



What is the name of the process (though I'm guessing it's the System IDLE Process)?

1725.

Solve : Java - having my classes send an ActionEvent?

Answer»

So I've been working on something. Anyways I was wondering how I can make my class throw its own action event to the class its implemented in: When either the slider or the text FIELD is updated.

Here is the class.
Code: [Select]import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class PhotoControls extends JPanel
{
private JSlider slider;
private JTextField slideVal;
public ActionEvent ae;
public PhotoControls()
{
super();

slider = new JSlider(1,200,100);
slider.addChangeListener(new SliderListener());
slideVal = new JTextField(6);
slideVal.addActionListener(new SlideValListener());
add(slider);
slideVal.setText(slider.getValue() + " %");
add(slideVal);
}
public int getSlide()
{
return slider.getValue();
}
public void setSlideVal(int VAL)
{
slider.setValue(val);
}
public void setText(int val)
{
slideVal.setText(val + " %");
}
public String getText()
{
return slideVal.getText();
}
public void stateChanged(ChangeEvent evt)
{
Object source = evt.getSource();
if(source == slider)
{
slideVal.setText(slider.getValue() + " %");
}
}
private class SliderListener implements ChangeListener
{
public void stateChanged(ChangeEvent E){
JSlider source = (JSlider)e.getSource();
if(!source.getValueIsAdjusting()){
//do crap here
setText(getSlide());
}
}
}
private class SlideValListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String RES = "";
String source = getText();
boolean reset = false;
for(int i = 0; i < 3; i++)
{
if((int)source.charAt(i) >= (int)'0' && (int)source.charAt(i) <= (int)'9')
res += source.charAt(i);
}
if(res.length() > 0)
{
setText(Integer.parseInt(res));
setSlideVal(Integer.parseInt(res));
}
else
{
setText(100);
setSlideVal(100);
}
}
}
}

1726.

Solve : How do I automatically kill a process that is dead but listening??

Answer»

How to automatically kill a PROCESS who is no longer active in ''ResourceMonitor/Network'' ?but which still exists,when i type TASKLIST i can see the process there,but my ''tool.exe'' is not active anymore.The process can still be SEEN in TASKLIST,does anyone have an idea how to automatically SHUT it down but only when he has no activity anymore!anyone knows a tool or a .BAT who can do something like that? thank you.

1727.

Solve : Word VBA to find x,y cordinates of selected range of text (Start and End)?

Answer»

I am LOOKING for help with a MS WORD VBA code that will run in a macro to find the x and y COORDINATES of selected range of TEXT.

xposition = Selection.Information(wdHorizontalPositionRelativeToPage)
yposition = Selection.Information(wdVerticalPositionRelativeToPage)

The above code provides the X and Y of the START of the selection (or where the curser is).

How do I find the x and y of the END of the Range of Selection?
(If it matters, I need it to run in standard text and also when the text is in a word Table)Code: [Select]Dim Left, Right, Top, Bottom

Set Starting = Selection.Range
Starting.SetRange Starting.Start, Starting.Start
Left = Starting.Information(wdHorizontalPositionRelativeToPage)
Top = Starting.Information(wdVerticalPositionRelativeToPage)

Set Ending = Selection.Range
Ending.SetRange Ending.End, Ending.End

Right = Ending.Information(wdHorizontalPositionRelativeToPage)
Bottom = Ending.Information(wdVerticalPositionRelativeToPage)

'MessageBox.Show "Left:" + Left + " Top:" + Top + " Right:" + Right + " Bottom:" + Bottom

Of course the "End" of the selection could be anywhere, so this wouldn't give you a rectangle in most cases. I couldn't figure out how to get the actual width/height of the selection itself.Thank you!! Thank you!!

1728.

Solve : Micro Controller?

Answer»

Hello again. My friend would like to know if there is any programming languages that can be use with the MICRO controller. Like c, c#, c++, java, java script, ruby, python, assembly, html 5?

Thanks,
ShiverbobIf there is some sort of problem please LET us know. Otherwise, if you want to continue to receive assistance on this forum you need to stop spamming the board. Well, we're going to need more information about what exactly you are trying to do...

A Micro Controller is extremely limited, therefore you will end up programming it in some sort of language that can be compiled directly to the hardware, e.g. C, C++ or Assembly. You aren't going to be able to run Java or Python on a Micro Controller since they require a virtual machine or interpreter respectively and I have no idea where HTML COMES into any of it since it's a markup language, not a programming language.Quote from: shiverbob on January 26, 2015, 09:42:46 AM

My friend

Why can't your friend create an account and ask their question themselves?General reference:
http://www.popularmechanics.com/technology/how-to/software/arduino-alternatives-5-microcontrollers-you-should-know#slide-1
Quote
Arduino Alternatives: 5 Microcontrollers You Should Know
If you're growing bored with your Raspberry Pi or Arduino, try working with one of these.
By Kiona Smith-Strickland

Even if you're a casual microcontroller dabbler you've probably heard of the biggest names in the business: Arduino, BeagleBone, and Raspberry Pi. However, there are less renowned but still high-quality microcontrollers that you may have missed but should get to know.
For almost all of these, a SIMPLE for of the C language is used. But you have to have the specific library for the target machine.
I don't know why he can't but i think he won't. Any way i am sorry for the spamming I was not paying attention. Html was thrown out there because it was just some random language I could think of. Thanks for the replies though.You can program MCU even in C# (.NET Micro Framework) if you want.
1729.

Solve : how i can be a programmer?

Answer»

In real world programming C++ is used as part of a project. It is never a full solution to an application.
That can also be said for Java, SQL, VBA and XML. And some other things that are not well know outside of the IT industry. The academic community ignores some of the day to day tools used in the real world. Forgot to mention Python. It is deep inside of some application programs. You don't see it, but it was used to develop part of that application. Even TCL/TKis still used in some development, but not a full solution.
A real programmer has to take a document written in plain English and turn it into a solution for some challenge in BUSINESS, Science, Technology or GOVERNMENT.
The ability to pass n academic test and score big on classroom work does not make a real programmer. But it might help.Quote from: rthompson80819 on July 04, 2010, 08:14:24 PM

I'm SURE BC will correct me if I wrong, but if i remember right almost of DOS and a good part of the first several windows versions was written in C.


DOS was ASM (IIRC), but Windows was and still is mostly C.

BUT, that's off-topic. recall, once again- he said development tool. Windows is an Operating SYSTEM, not an Application. the choices for writing Windows were pretty much either C or ASM, simply because of the low-level nature of an Operating system. DRIVERS, kernel mode, etc.

Quote from: Geek-9pm on July 04, 2010, 08:35:19 PM
The academic community ignores some of the day to day tools used in the real world.

Yeah, I've always found that sort of humourous. academic circles play around in Scheme and Smalltalk, and those almost never find their way into use outside of academia.Quote from: rthompson80819 on July 04, 2010, 08:14:24 PM
I'm sure BC will correct me if I wrong, but if i remember right almost of DOS and a good part of the first several windows versions was written in C.

No. They both were written split-octal cuneiform on clay tablets. Later translated to paper tape.
1730.

Solve : Computer is crashing?

Answer»

My computer has been CRASHING since I bought it early this year. I have kept the drivers up to date and have recently been doing whocrashed REPORTS. The crashes occur mainly when I am gaming or have the game tabbed out. This even occurs with games my computer can easily run such as LOL.

Computer name: DESKTOP-B1PCCPQ
Windows VERSION: Windows 10 , 10.0, build: 14393
Windows dir: C:\windows
Hardware: ASUSTeK Computer INC., M5A78L-M PLUS/USB3
CPU: AuthenticAMD AMD FX(TM)-8300 Eight-Core Processor AMD586, level: 21
8 logical processors, active mask: 255
RAM: 8571179008 bytes total


[attachment deleted by admin to CONSERVE space]http://speccy.piriform.com/results/kBKBvn72YMxn8edy1uiwH2U

1731.

Solve : PERL on Windows with Metacharacter in PathName?

Answer»

I have a Windows share of the format \\sharename\directory$\subdir. In PERL, when I try to read the directory, it STOPS right before the $ sign, and truncate the rest of the pathname. I also tried putting a backslash before the $ sign, and still the same issue. Any ideas how to handle this?

Thanks in advance....Which version or Perl for Windows?
Which version of Windows? Ia it a 64 bit version?
Can your try running your Perl job with no other programs using the same path names? If so, that would offer a WORKAROUND.
Are all the relevant files in one folder? If so,the full path name is not needed.
Or would you consider CRATING as small partition on your drive and moving the target folder and its contents into the new partition?

A quick 'hack' would be to use BATCH to rename some folders in the path to not have the meta-char. Then after the job reverse the naming thing back to what it was.

Sorry, I am not up to date on escapes in Perl script. You will have to SPEND some time with the manual for the version you are using.
This might help:

http://stackoverflow.com/questions/2001176/how-can-i-escape-meta-characters-when-i-interpolate-a-variable-in-perls-match-o
It seems to be like your problem. Does it?
http://www.perlmonks.org/bare/?node_id=738314

1732.

Solve : Bitmap editing vb.net?

Answer»

I have a bitmap in runtime. I WANT to ADD about 40 pixels of white on the left. how can i do that without a pictureboxCouldn't you just OPEN it in MSPAINT and do that; then re-import?

Or, make a blank bitmap 40pix wide and stick it next to the other picture.have to do it in runtime. it's a game

1733.

Solve : batch win7 problem copy/rename?

Answer»

hello everyone!

I've read about 30pages in there and i still havent found a solution to a problem i have, so i THOUGHT i'll ask!
anyway...here is what it's all about :

I have a bat file for backing up outlook files!
When i launch it, it close outlook.exe, then copy the .pst to another drive and if outlook.pst already exist it renames it to outlook(1).pst and so on
Everything WORKS perfectly fine on XP but I have to make it works with Win7 Pro 64 and it doesn't!
When i launch it on 7, it copy the file just fine but if it already exists, it renames it to outlook(1).pst and keep on overwriting it instead of going on with the (2) (3) (4)
I also tried the "run as win xp" and "run as ADMIN" but no luck.

Here is my batch, i really hope someone can help me figure it out!

*********batch********
taskkill /im Outlook.exe

@ping 127.0.0.1 -n 2 -w 1000 > nul
@ping 127.0.0.1 -n 2 -w 1000 > nul

setlocal EnableDelayedExpansion

set DestFolder=D:\test\Finished

md "%DestFolder%" 2> nul
for /r "C:\Users\steffy\AppData\Local\Microsoft\Outlook" %%f in (Outlook.pst) do (
set CanCopy=false
set folder=%%~pf
for %%x in ("!folder:~0,-1!") do set folder=%%~nx
if /i "!folder!" neq "%DestFolder%" if /i "%%f" neq "%~dpnx0" (
set CanCopy=true
)
if "!CanCopy!" equ "true" (
if exist "%DestFolder%\%%~nxf" (
call :GetNextFilename "%DestFolder%\%%~nxf" newfile
copy "%%f" "%DestFolder%\!newfile!"
) else (
copy "%%f" "%DestFolder%\"
)
)
)
goto :EOF


:GetNextFilename
set n=0
:loop
set /a n+=1
set %2=%~n1(%n%)%~x1
if exist "%~p1!%2!" goto loop
goto :eof



THANKS!

1734.

Solve : Writing a Test Plan for Java Programme?

Answer» HEY guys I'm doing an assignment and it's due tomorrow. Anyways, we are finishing the touches here and there but I have no IDEA how to do a 'Test Plan' for our java programme. Does anyone have a clue on how long it has to be and what should be written? Thanks.

I manage to find these two document, one is very detailed and the other one is short and simple but I'm not sure if it does/does not match our the standards for a 'Test Plan'.

http://cdn2.softwaretestinghelp.com/...estingHelp.pdf

http://www.computing.dcu.ie/~davids/...ieee829mtp.pdfHow a PROGRAM is tested depends strongly on what the program does. Neither of your links work, but in general, you want to cover expected and unexpected inputs, which seems sort of obvious. For expected inputs, verify that any result is correct. For unexpected inputs, you want to test corner CASES and extremely large or small values, or values that are the wrong data TYPE (strings being entered for numeric inputs, for example).
1735.

Solve : Schedule Macro Execution - Outlook 2003?

Answer»

I'm currently trying to make a tedious task I have to do daily much easier, and I figured I may as WELL attempt to fully automate it.
I am currently attempting to automate/schedule an Outlook 2003 Macro I wrote to download all of the files off of specific email messages by creating another macro in the ThisOutlookSession area...

However, I do not know VBA very well.

Does anyone know how I might be able to accomplish this?
Thank you in advance for your help.

So far, the only Idea I have had is the following (using a couple of test subroutines):

Private Sub Application_Startup()

test

End Sub

Sub test()

Dim CurrTime As String
Dim CurrDay As String

CurrDay = Format("ddmmyy", Date)

CurrTime = DatePart("h", TIME)

If CurrTime = "11" Then
testSend
End If

'INSERT CODE TO PAUSE MACRO WITHOUT HANGING APPLICATION
test

End Sub
Sub testSend()

SendMessage "Test Success", "The Macro Appears to Work...For Now", "[emailprotected]"

End Sub

Sub SendMessage(Subj As String, Message As String, Receivers As String)

Dim toSend As MailItem

Set toSend = CreateItem(olMailItem)
toSend.BodyFormat = olFormatPlain
toSend.Subject = Subj
toSend.Body = Message
toSend.To = Receivers
toSend.Send

SendMessage_exit:
Set toSend = Nothing
Exit Sub

End Sub



Do you have any ideas as to how I might tell the macro to wait an hour before checking the time again without causing the system to hang?Add a new module (Insert->Module)

Paste this:

Code: [Select]Option Explicit
Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerfunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long

Public TimerID As Long 'Need a timer ID to eventually turn off the timer. If the timer ID <> 0 then the timer is running

Public Sub ActivateTimer(ByVal nMinutes As Long)
nMinutes = nMinutes * 1000 * 60 'SetTimer accepts milliseconds- convert to minutes.
If TimerID <> 0 Then Call DeactivateTimer 'make sure there isn't already a timer.
TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer)
If TimerID = 0 Then
MsgBox "Timer failure."
End If
End Sub

Public Sub DeactivateTimer()
Dim lSuccess As Long
lSuccess = KillTimer(0, TimerID)

End Sub

Public Sub TriggerTimer(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long)
static lastday as integer
if lastday <> Day(Now) And Hour(Now)=11 Then
testsend
lastday = day(now)
End If
End Sub


Sub testSend()

SendMessage "Test Success", "The Macro Appears to Work...For Now", "[emailprotected]"

End Sub

Sub SendMessage(Subj As String, Message As String, Receivers As String)

Dim toSend As MailItem

Set toSend = CreateItem(olMailItem)
toSend.BodyFormat = olFormatPlain
toSend.Subject = Subj
toSend.Body = Message
toSend.To = Receivers
toSend.Send

SendMessage_exit:
Set toSend = Nothing
End Sub



Now for your Application_Startup and Shutdown events:

Code: [Select]Private Sub Application_Quit()
If TimerID <> 0 Then Call DeactivateTimer 'Do NOT skip this step!
End Sub

Private Sub Application_Startup()
MsgBox "Activating the Timer."
Call ActivateTimer(10) 'Set timer for 10 min
End Sub

Hope this helps. Basically, what it does is create a windows Timer to fire every 10 minutes , which ends up calling the "TriggerTimer()" function. Here I just plopped in your testsend and sendmessage routines and call testsend from the timer routine, after running a few checks to make sure that the hour is eleven and we haven't already sent it today. (the "static" variable keeps it's value between invocations) Thank you so much!

This works perfectly! Quote from: southpaw63119 on July 16, 2010, 08:59:27 AM

Thank you so much!

This works perfectly!

Cool! Glad I could help Sorry, I know this is a little bit of a sidetrack, but it is still relevant to this scenario.

The code works fine, but I created this code:

Code: [Select]Dim Item As Object
Dim ns As NameSpace
Dim Inbox As MAPIFolder

Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)

For Each Item In Inbox.Items
If TypeName(Item) = "MailItem" Then
If Item.Subject = "Kill Timer Macro" Then
Call DeactivateTimer
SendMessage "Macro Process STOPPED", "", Item.SenderEmailAddress
Item.UnRead = False
Item.Delete
Else
If Item.Subject = "Timer Running?" Then
If TimerID <> 0 Then
SendMessage "Is Timer Running?", "Yes, the timer is currently running.", Item.SenderEmailAddress
Else
SendMessage "Is Timer Running?", "No, the timer is not currently running.", Item.SenderEmailAddress
End If

Item.UnRead = False
Item.Delete
Else
If Item.Subject = "Reset Timer" Then
If TimerID <> 0 Then Call DeactivateTimer
Call ActivateTimer(10)
SendMessage "Timer Reset", "The timer has been reset to check every 10 minutes", Item.SenderEmailAddress
Item.UnRead = False
Item.Delete
End If
End If
End If
End If
Next Item

End Sub
as a means of controlling the timer remotely (I have the timer set to kick everything off between midnight and 1 AM).

However, when I send the message to the email account to deactivate the timer and then I send the message to see if the timer is still running, the macro responds that it is still running.

Do you know why this occurs?

Thanks.
-southpawWhen you ask wether the timer is running, you are testing wether the TimerID value is 0, but when you deactivate it the TimerID is NEVER set to zero.



I feel like such an idiot.

Thanks again!Would you recommend setting the value to 0, or is there another way I can do it?

(sorry about all of this...)Quote from: southpaw63119 on July 21, 2010, 12:15:23 PM
Would you recommend setting the value to 0, or is there another way I can do it?


I'd recommend setting it to zero in the DeActivateTimer() routine (after the call to KillTimer()).


Quote
(sorry about all of this...)

Don't be silly! you're here for help, honestly I felt bad that I couldn't help as much before and you were just posting all by your LONESOME (I'm not very familiar with the Outlook object model)
1736.

Solve : Batch, Replace file if newer?

Answer» HELLO All,

Just like the topic states, I am trying to run a batch that will backup a certain file. However at times when the backup runs, the file to be copied is older than the file it will replace, in this case, I would want it not to replace the newer file with the older one. I have attempted the FC command however that seems to be more trouble than help. If someone could show me an example of how to compare file date (and time if possible) then replace as necessary, I would greatly appreciate it. Thanks in advance.First of all, can you provide a copy of the key part of your batch file?
Both the COPY command and the XCOPY command have switches to do just what you asked. Unless I'm mistaken, you can just go to the command prompt and type /? After either of those two commands and get a list of options available.
But let me ask you why don't you use a standard utility that does exactly what you want with a simple command structure? And why do it at the command prompt?
Certainly, let's hope this doesn't further complicate the problem.

My CURRENT CODE:
Code: [Select]@ECHO OFF
TITLE Borderlands Character Backup
ECHO Initializing...
XCOPY "C:\Users\YourMother\Documents\My Games\Borderlands\SaveData\*" "F:\BackUp\Borderlands\Saves" /y /f /e
ECHO Process Completed.

The main ISSUE is that it doesn't compare the files date/time before just copying.
If I am supposed to use the /D switch with xcopy, what would be the proper syntax for this case?

The reason I run this in a batch is for its simplicity and versatility, I can put it anywhere, its standalone and requires no other apps, besides cmd ofc.This is what is says:Code: [Select]/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
Well, did you try this?
Code: [Select]XCOPY "C:\Users\YourMother\Documents\My Games\Borderlands\SaveData\*" "F:\BackUp\Borderlands\Saves" /D /y /f /eWell I certainly tried /d:(date) but it had not occurred to me to leave the COLON and date off entirely. I have since tried that, as per your advice, and it works.

Thanks again, the cmd help is misleading at times.

You can mark this solved.
1737.

Solve : Is this batch code correct??

Answer»

Code: [Select]SET dd=%date% %Time%
SET today=%dd:~4,2%
SET post=.%dd:~7,2%.%dd:~12,2%
SET /A ex1=%today%-1
SET ex2=%ex1%%post%
XCOPY "%HOMEDRIVE%%HOMEPATH%\Documents\My Dropbox\server\Mysql Backup\85 OS*%ex2% 23.5*\*.*" C:\xampp\mysql\data\serverT\ /S
What I'm trying to do, is GRAB all the files in a directory that is created daily with a timestamp. the SET /A ex1=%today%-1 minuses the current day by 1, making it yesterday. then I use the variables created beforehand in a xcopy command, I'm GETTING problems though, it seems to want to use the wildcards "*" as an actual part of the file name, that is not at all what I figured wildcards were meant to do. But it LOOKS for "85 OS*6.06.10 23.5*\*.*" Am I missing something?

Code: [Select]File not found - *.*
0 File(s) copiedQuote from: Alkamar

SET /A ex1=%today%-1 minuses the current day by 1, making it yesterday.

This is not possible when using dates. If the current day is 01 the outcome will be 0 and if the current day is 08 or 09 Set /A will fail because it will 'see' the date as Octal (base eight), in Octal 8 and 9 are invalid. Also, if today is the first day of the month and you want to get yesterday's date, the month and possibly the year must be decremented as well as the day.

e.g. (Based on a date format of dd/mm/yyyy)
Current date = 01/01/2010
Current date -1 = 31/12/2009

and

Current date = 01/03/2010
Current date -1 = 28/02/2010

To manipulate dates and times I suggest you consider VB scripting.

Below is a small script combining batch scripting and VB scripting which will reduce the date by one day.
Code: [Select]@echo off
setlocal
cls

set vbs=%temp%\vbs.vbs

&GT; %vbs% echo WScript.Echo DateAdd("d",-1,Date)

for /f "tokens=* delims=" %%a in ('cscript //nologo %vbs%') do (
set newdate=%%a
)
del %vbs%
echo Newdate=%newdate%
exit /b

Hope this helps.Ah, wow. I wasn't even thinking I guess.

Well, this definitely helps, I don't know a single thing about VB or VBS, but I'll see what I can do. Thanks Dusty.
1738.

Solve : determine file type?

Answer» my table CONTAINS both URLS(http://) and email addresses. Using PHP, I WANT to take different actions depending on the current record and dont have a clue. any ADVICE? THANKS
1739.

Solve : how to insert new menu when i right click mouse??

Answer»

I got MANY software to send using DOS prompt, for example : copy c:\a.exe lpt1
currently i need to run cmd, then type copy, then drag the file to cmd window then type again lpt1, all manually

can i add a new KEY to my RIGHT click menu, so when i point to .exe file, the system will auto add copy ... lpt1 and send my file
is that posibble?

I found one tutorial but I do not how I could apply it

http://www.jfitz.com/tips/rclick_custom.html
I found a program CALLED Context Menu Editor 1.1. It allows you to add/remove items from the right click menu.

I have not downloaded from this site before, but it seems safe.

http://www.freewarebb.com/index.php/files/file/9126-context-menu-editor-11/

1740.

Solve : *TIME SENSITIVE*vba scripting for inexperienced?

Answer»

This is a snippet of what i NEED. I need the highlighted cell on "moved" to push to "inventory" SINCE it has n/a meaning its not present currently. Then on the inventory list, i need my f row (LOCATION) to automatically update if it doesnt match with g(move). Then i need "inventory" to automatically delete if row c on "load" and row d on "inventory". Whatever vba you provide me, i need to work for to 5000 rows on each sheet. I will be your best freind if you can HELP me. I do not know anything about vba so if a quick copy paste can be provided id be in your debt

[attachment deleted by admin to conserve space]The screen shots are too hard to read. I was trying to upload a small snippet of the workbook but file too large. suggestions?If the page is too large to send an attachment, you might use ciloud or dropbox.
Make a new folder and share rte folder.

1741.

Solve : C++ output screen as text?

Answer»

How we can SAVE TURBO C++ OUTPUT screen (outrut)as text FILE for printing?[color=][/color]

1742.

Solve : Free C/C++ Compilers & Interpreters?

Answer»

Yes, you can use an Interpreter for C and C++ for some applications.
The advantage of an interpreter is less time with the trail and goof approach.
This link is for a web site with a bunch of links to various kinds compilers and interpreters. Take a look. You might be surprised.

Free C/C++ Compilers and Interpreters
He covers a very wide range of things. Good link toad to your bookmarks.

Did you know you can Python in Visual studio?
Quote

With this suite, you can develop programs for the desktop and mobile versions of Windows as well as ANDROID. The C++ compiler appears to support most of ISO C++11 and some of C++14 ...
The software also comes with support for building programs with C#, Visual Basic, F# and Python. At the time I wrote this, the site states that Visual Studio Community 2015 is "free for individual developers

Visual Studio is available for both Windows and Apple systems.
Looked at the site you LINKED. I do a lot of quick "programming for console" programming in C++ with Bloodshed Dev C++ and saw it listed there... However I had found some interesting bugs using it.

I came across Eclipse C++ IDE when playing with C++ with wanting to program for Linux Mint. It also is available for Windows. I havent learned all the features it has, but have done some small programs with it to learn how to use tip of the iceberg of features is has. Trying to get myself away from Bloodshed Dev C++, but after using it for so long its fluid in its use and I like its layout which reminds me of Bordland 5.02 C++ and Microsoft VC++6.0 which is what I ORIGINALLY coded on.

https://eclipse.org/cdt/

I have played with Visual Studio since 2008, but not sure what it is about it, but it doesnt keep my focus as an IDE for my programming use. I think it is similar to my DISTASTE for Windows 8.x and newer and liking Windows 7 and older desktop layout and its more of where if I forced myself to like it, maybe I would come to liking it. I have actually only used Visual Studio Express when using the Books with DVD learning C# and tinkering with Visual Basic which I dabbled with since VB6. It still feels foreign to me and so I only with with it when I have to, such as when I am working with someone elses open source code that was built using it and was written specifically for .NET Framework implementation.
1743.

Solve : Random name generator, save names already called and work with probability??

Answer»

Hello,

I've written a simple java program which has a string of names:

import java.util.Random;

public class RandomNames
{
public static VOID main(String[] args)
{
String[] Names = {"Bob","John","Mary","Lewis",
"Hannah", "GEORGE", "Sam", "Carl"};
Random r = new Random();
int randint = r.nextInt(Names.length);
System.out.println("Your NAME is" +Names[randint]+"");
}
}

I'd like the program to record each time it prints out who's name is called, so..

Hannah - 4 times
George - 2 times
Carl - 1 time

You GET the PICTURE.. also, how can i write this output to a file?

Thanks in advance

1744.

Solve : Quick Interview VIA Email for Anybody working in the CS or CIS field Please help?

Answer»

Hello! I am currently a student at Ball State UNIVERSITY and have declared my major as CIS. I was wondering if there is anybody with a CS os CIS DEGREE that I could email some questions to RELATING to their work EXPERIENCES. I will try to keep them as simple and quick as possible to not take up too much of your time. I dont have many connections yet in this field and really need somebody to help me with my interview project. Thanks in advance and if you are willing to help PLEASE leave an email below i can reach you at or email me directly at [emailprotected] Thanks again!

1745.

Solve : DVD Player Game Programming?

Answer»

The WIKIPEDIA STATES (in 2011) " Programming interfaceA virtual machine implemented by the DVD player runs 'bytecode' contained on the DVD. This is used to control playback and display special effects on the menus. The instruction set is called the Virtual Machine (VM) DVD COMMAND set. There are 16 general parameter REGISTERS (GPRM) to HOLD temporary values and 24 system parameters (SPRM). As a result of a moderately flexible programming interface, DVD players can be used to play games, such as the DVD re- release of Dragon's Lair, along with more SOPHISTICATED and advanced games such as Scene It, all of which can be run on standard DVD players."

But I cannot find any article based on the Virtual Machine implemented in DVD players and how to program them.I want to make a game for DVD players.But how can I do it ? I have searched Google but found no information on the VM or how to make Game for DVD players. Please help me....Please include the deference.
It should have links to relevant publications.

1746.

Solve : customizing a command?

Answer»

i want to run a program, when i type a command in the cmd prompt.
ex:
say sum.cpp is my file
if i type command like

C:\echo sample

before echo gets executed my program "sum.cpp" should run
is it possible to do so.Do not post the same question more than once. I've deleted your other post.None of this makes much sense. Try writing a batch file after you compile your C++ program.

Code: [Select]@echo off
sum.exe
echo sample

Give your script a name and save the script with a cmd extension. Run from the command line as: scriptname.



sorry!!
for the posting the question more than once

i am a beginner try to help me.

my question is

i want to attach my program to echo command .....
my program should run when i type echo command ( irrespective of the input to echo)
my program takes the input, if the input is in the range of 0 -16000 it should execute the original echo
else it should come out, showing error.

Quote from: sharath.chandra.v on July 10, 2010, 01:12:14 AM

i want to attach my program to echo command .....
my program should run when i type echo command ( irrespective of the input to echo)
my program takes the input, if the input is in the range of 0 -16000 it should execute the original echo
else it should come out, showing error.

MAYBE it's me but I'm not understanding what you're trying to accomplish. Why do you want to attach your program to the echo command?

Echo is an internal NT cmd processor command. When a command is entered at the command line, the processor first checks it's list of internal commands, then the current directory, and finally the directories listed on the path environment variable. The search also includes the extensions from the pathext environment variable if the command is external from the processor. As soon as a match is found, the command is run. If no match is found you get an error message.

If you CREATE a file named echo.bat, the only way to get it to run would be to use a fully qualified file name which will override the normal NT search sequence. If you create a file named echo with no extension, even with a fully qualified file name, the processor will not find the file (see above) and throw an error.

Duplicating Microsoft command or utility names is not considered BEST practice and will produce unpredictable results.



i am actually working on alternate data streams,
so i want to attach a program that restricts the size of alternate data streams to the commands that are used to create them.
thanks for responding to my post

how to get the fully qualified names of the commands that i need
Quote from: sharath.chandra.v on July 12, 2010, 04:07:33 AM
how to get the fully qualified names of the commands that i need

Knowing that you are working with alternate data streams is an important piece of information. Why didn't you mention that in your first post? ADS is a tried and true method to hide malicious code. It's very effective because it does not change the file size. It would help to know exactly what you're trying to accomplish.

You mentioned the echo command, but the executable instructions, like all NT internal commands are located within the interpreter code itself and there is no external file to execute.

The other day I was told I was "an hour late and a dollar short". Maybe I am slow on the uptake, or perhaps just being cautious.

thanking you once again

i have a program in cpp which can find out the size of the alternate data stream.
i want to check the size of alternate data stream, when a command related to ADS creation is used.
only if the size is less than 2k, the command should work, else it should show error "size of ADS cant exceed 2k bits" .

thus i want to restrict the size of alternate data stream

is this implementable
if so, what is the way of implementing my logic.


Quote
i want to check the size of alternate data stream, when a command related to ADS creation is used

Not sure what commands are related to ADS creation. You seem to want something that will monitor the size of the ADS in real time. I couldn't find anything on Google, but perhaps you might.

It might be possible to monitor a directory, and when a file is created or modified your program would kick in. This would be after the fact and there would be no way to prevent the ADS from exceeding 2K. It could only alert you to the size of the ADS.

It is also possible to monitor when a process starts, however NT internal commands run within the cmd shell. It is very easy to create an ADS with the echo command, but Windows only sees the processor program (cmd.exe). Hooking user code into the NT processor is beyond my capabilities.

Good luck. Quote from: Sidewinder on July 14, 2010, 06:39:59 AM
Not sure what commands are related to ADS creation. You seem to want something that will monitor the size of the ADS in real time. I couldn't find anything on Google, but perhaps you might.

It might be possible to monitor a directory, and when a file is created or modified your program would kick in. This would be after the fact and there would be no way to prevent the ADS from exceeding 2K. It could only alert you to the size of the ADS.

It is also possible to monitor when a process starts, however NT internal commands run within the cmd shell. It is very easy to create an ADS with the echo command, but Windows only sees the processor program (cmd.exe). Hooking user code into the NT processor is beyond my capabilities.

Good luck.

Only way to "properly" restrict the size of Alternate data streams would be with a filesystem driver.

Even a user-mode program build in FindFirstChangeNotification() or RegisterChangeNotification() functions won't catch everything.

writing a driver is not something you do in a weekend to pass the time. At least, not something like this.

Secondly, it is stated:
Quote
else it should show error "size of ADS cant exceed 2k bits"
First, it can. second, 2k bits is 256 bytes, which isn't very much data at all.

lastly, why would you want to restrict the ADS size in the first place? the moment you right-click on a text file or batch file or nearly any document Explorer writes a DocumentSummaryInformation Stream to the file, and that usually EXCEEDS even 2K.


Quote
i have a program in cpp which can find out the size of the alternate data stream.

you have been saying alternate data stream, as if one, and only one, can exist.

a file can have any number of alternate data streams. the size of them can be retrieved using the backupread function and reading the filesystem structures of the file itself. A more security-friendly (backupread requires BACKUP privileges, which is usually only the administrator) method is the ntQueryInformation file the best method is that with Vista and higher you can look at streams as easily as you look at files- there is now a FindFirstStream and FindNextStream set of functions.

Whatever the case, as sidewinder mentioned, you aren't going to be able to "hook" the echo command, and even if you did, that is hardly the only way to restrict the size of an alternate data stream.

1747.

Solve : Remote stop service?

Answer»

Hi All,
I would like to stop a service from one machine onto another machine. I remember in VBS I could impersonate a user and get the service to stop.

Anyone have any IDEAS as to how to get this done?

Thanks
This should do it:

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='stisvc'")

For Each objService in colServiceList
errReturn = objService.StopService()
Next

CHANGE the VALUE of strComputer to the name of your remote computer. I used stisvc as the service name. Change accordingly.

You can execute services.msc from the run box to get the names of the services. Be sure to use the service name and not the display name.

Good luck. GREAT! Thanks for your help!

1748.

Solve : I need to determine an unkown encoding of a .XLS file.?

Answer»

I am working on writing a python(3) script to take data out of an xls file, and place it in an sqlite database. The xls file is downloaded from the Internet, and encoded in a way I haven't been able to get to work with the xlrd library.

Code: [Select]Python 3.5.2+ (default, Sep 22 2016, 12:18:14)
[GCC 6.2.0 20160927] on linux
Type "copyright", "credits" or "license()" for more information.
>>> import xlrd
>>> file = xlrd.open_workbook("test.xls")
WARNING *** file size (262435) not 512 + multiple of sector size (512)
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
file = xlrd.open_workbook("test.xls")
File "/usr/local/lib/python3.5/dist-packages/xlrd/__init__.py", line 441, in open_workbook
ragged_rows=ragged_rows,
File "/usr/local/lib/python3.5/dist-packages/xlrd/book.py", line 116, in open_workbook_xls
bk.parse_globals()
File "/usr/local/lib/python3.5/dist-packages/xlrd/book.py", line 1180, in parse_globals
self.handle_writeaccess(data)
File "/usr/local/lib/python3.5/dist-packages/xlrd/book.py", line 1145, in handle_writeaccess
strg = unpack_unicode(data, 0, lenlen=2)
File "/usr/local/lib/python3.5/dist-packages/xlrd/biffh.py", line 303, in unpack_unicode
strg = unicode(rawstrg, 'utf_16_le')
File "/usr/local/lib/python3.5/dist-packages/xlrd/timemachine.py", line 30, in <lambda>
unicode = lambda b, enc: b.decode(enc)
File "/usr/lib/python3.5/encodings/utf_16_le.py", line 16, in decode
return codecs.utf_16_le_decode(input, errors, True)
UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x20 in position 108: truncated data
I was reading through the docs, and it didn't give a clear way to test how the file is encoded.
Link Related: http://xlrd.readthedocs.io/en/latest/unicode.html

I did try other codes I have heard of, but I've yet to get one to work. Any thoughts?Sounds like the file is missing the CODEPAGE information. You'll have to override it as documented here.

Code: [Select]file = xlrd.open_workbook('test.xls', encoding_override="utf_16_le")

You'll have to experiment with different encodings depending on what kind it actually is.I have been try different codecs, but have yet to get one to work. I may write a script that will just try them all...

An interesting thing I have FOUND is that no matter what codec I have given as a argument, I always get the same error:
Code: [Select]>>> xlrd.open_workbook('test.xls', encoding_override="iso8859_15")
WARNING *** file size (262435) not 512 + multiple of sector size (512)
WARNING *** OLE2 inconsistency: SSCS size is 0 but SSAT size is non-zero
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/xlrd/__init__.py", line 441, in open_workbook
ragged_rows=ragged_rows,
File "/usr/local/lib/python3.5/dist-packages/xlrd/book.py", line 116, in open_workbook_xls
bk.parse_globals()
File "/usr/local/lib/python3.5/dist-packages/xlrd/book.py", line 1180, in parse_globals
self.handle_writeaccess(data)
File "/usr/local/lib/python3.5/dist-packages/xlrd/book.py", line 1145, in handle_writeaccess
strg = unpack_unicode(data, 0, lenlen=2)
File "/usr/local/lib/python3.5/dist-packages/xlrd/biffh.py", line 303, in unpack_unicode
strg = unicode(rawstrg, 'utf_16_le')
File "/usr/local/lib/python3.5/dist-packages/xlrd/timemachine.py", line 30, in <lambda>
unicode = lambda b, enc: b.decode(enc)
File "/usr/lib/python3.5/encodings/utf_16_le.py", line 16, in decode
return codecs.utf_16_le_decode(input, errors, True)
UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x20 in position 108: truncated data
OK, then the file PROBABLY does have a CODEPAGE but the file itself is corrupted. Can you open the file in Excel/LibreOffice?Yes, I can open it in LibreOffice, and even if I change the file extension libreoffice doesn't complain. It is not an xlsx for sure because it isn't a compressed file. (I can see the text of the spread sheet with a hex editor)I have been investigating the file a bit with a hex editor...
I found the data of the first cell of the downloaded file here:
Code: [Select]4F 00 72 00 64 00 65 00 72 00 20 00 47 00 75 00 69 00 64 00 65 00
Libre Office interprets it as "Order Guide"

Now I copied this cell to a blank workbook and saved it.
I found "Order Guide" in the document as:
Code: [Select]4F 72 64 65 72 20 47 75 69 64 65

Does anyone with more experience with encodings have any idea what the downloaded file could be encoded with? If not does anyone know where else to look in the file?First example is UTF-16 Little Endian (LE).I've tried most COMMON codecs with no success.
So maybe the file is utf_16_le.

Assuming the file is intentionally corrupted (100% reproducible), with python I would like to attempt to reconstruct it.

Code: [Select]UnicodeDecodeError: 'utf-16-le' codec can't decode byte 0x20 in position 108: truncated data
Position 108 I am assuming means the 108th byte in the file.
0x20 from what I understand is usually a space, I will add 00 before it.
brbThe error message was not helpful, no byte 0x20 was near byte position 108, nor near positions of 108*2^n.

So I decided to loop through the file with:
Code: [Select]file = open("prices.xls", encoding="utf-16-le")
byte = file.read(1)
while byte != "":
byte = file.read(1)
file.close()
and I got this error:
Code: [Select]Traceback (most recent call last):
File "./test.py", line 5, in <module>
byte = file.read(1)
File "/usr/lib/python3.5/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 1018-1019: illegal encoding
Bytes in position 1018-1019 are: 00 00


On a side note, if I open the file in libreoffice and save as an xls, I can open it with xlrd, and the file shrinks significantly. 262.5kb to 217.6kb.

Any ideas on what to do next?
I do not want my script to be dependent on libreoffice being installed.Quote

Assuming the file is intentionally corrupted (100% reproducible)
Where did it come from?The working par t of the script, fills out a couple webforms, and downloads the xls file using beautiful soup.
This is the part that does it:
Code: [Select]request = browser.session.get(myURL, stream=True)
with open(path + os.sep +"test.xls", "wb") as output:
output.write(request.content)
output.close()
Quote
Assuming the file is intentionally corrupted (100% reproducible)
Sorry for not being clear to what is happening.
So the file that my code downloads, matches the file that I can download using Firefox. I know the xls file is generated by some webservice. That xls file I assume is corrupted is some form.
To clean up the xls file my current scripted solution is to run this:
Code: [Select]from subprocess import call
call(["unoconv", "-d", "spreadsheet", "--format=ods", path + os.sep +"test.xls"])
call(["unoconv", "-d", "spreadsheet", "--format=xls", path + os.sep +"test.ods"])
While this solution works, I am not happy with it because it adds dependencies of libreoffice and unoconv.
What I would like to do is accomplish the same end result, but without adding nonpython dependencies.
Any idea where to start?
1749.

Solve : Get Button Content in RoutedEventHandler c#?

Answer»

So i'm making a calculator and would like the same event HANDLER for all the numbers.
I've already tried things like sender.source.Content but I'm UNABLE to find it
My code so far:
public MainWindow()
{
InitializeComponent();
oneButton.Click += new RoutedEventHandler(oneClick);
twoButton.Click += new RoutedEventHandler(oneClick);
threeButton.Click += new RoutedEventHandler(oneClick);
fourButton.Click += new RoutedEventHandler(oneClick);
fiveButton.Click += new RoutedEventHandler(oneClick);
sixButton.Click += new RoutedEventHandler(oneClick);
sevenButton.Click += new RoutedEventHandler(oneClick);
eightButton.Click += new RoutedEventHandler(oneClick);
nineButton.Click += new RoutedEventHandler(oneClick);
}

private void oneClick(object sender, RoutedEventArgs e)
{
resultTextBox.Text += .........;

}Is this from a published source code?
Or is it it fully original work?

From:
http://www.instructables.com/id/Creating-a-Calculator-Visual-Studio-C/
There are loss of samples out there.
https://www.youtube.com/watch?v=iJqB6UsM-hsQuick Answer: You should be able to use (String)((Button)sender).Content and test the string to see what button was pressed.

Longer answer: You can set the event directly in the WPF designer, too.

Even longer answer:

When you use WPF, you should aim to have as little C# code as possible, and do as much as possible with DataBindings and RESOURCES within the xaml.

I wrote a program that has a pinpad interface and it uses the same event handler for all buttons.

Here is the XAML FILE in question.


First it defines a "StandardEntryButtonStyle" on line 22. It defines the event handler to use for elements that will use this style:

Code: [Select]<EventSetter Event="Button.Click" Handler="EntryButtonClick"></EventSetter>
Then, later in the XAML, I use the RESOURCE to set the Style of each of the Entry buttons

Code: [Select]<Button Name="EntryButton7" Grid.Row="0" Grid.Column="0" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">7</Button>
<Button Name="EntryButton8" Grid.Row="0" Grid.Column="1" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">8</Button>
<Button Name="EntryButton9" Grid.Row="0" Grid.Column="2" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">9</Button>
<Button Name="EntryButton4" Grid.Row="1" Grid.Column="0" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">4</Button>
<Button Name="EntryButton5" Grid.Row="1" Grid.Column="1" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">5</Button>
<Button Name="EntryButton6" Grid.Row="1" Grid.Column="2" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">6</Button>
<Button Name="EntryButton1" Grid.Row="2" Grid.Column="0" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">1</Button>
<Button Name="EntryButton2" Grid.Row="2" Grid.Column="1" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">2</Button>
<Button Name="EntryButton3" Grid.Row="2" Grid.Column="2" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">3</Button>
<Button Name="EntryButtonC" Grid.Row="3" Grid.Column="0" Foreground="Red" Style="{StaticResource StandardEntryButtonStyle}" Margin="3">C</Button>
<Button Name="EntryButton0" Grid.Row="3" Grid.Column="1" Style="{StaticResource StandardEntryButtonStyle}" Margin="5">0</Button>
<Button Name="EntryButtonOK" Grid.Row="3" Grid.Column="2" Foreground="Green" Style="{StaticResource StandardEntryButtonStyle}" FontFamily="WingDings" Margin="3">ü</Button>

This sets the event handler for all the buttons.

Optionally, of course, you can set the event handler for the buttons yourself by editing the XAML and setting the 'Click' attribute to point at your event method, but using a static resource allows you to make changes across all of the elements easily. The event that handles the button clicks is found here; remember this is a PIN entry, rather than a calculator, so the logic itself is definitely different than what would be used for a calculator. As you can see it uses (String)((Button)sender).Content to retrieve the text content of the button; if it is numeric it will add it to the built PIN, otherwise it will check for the wingdings font text to see if it is the Cancel or OK buttons that were pressed and act accordingly.Thanks for the resources, this was the solution:

Button button = (Button)sender;
resultTextBox.Text += button.Content;

The reason I don't like to attach the handlers in the xaml code is because when I use ValueChanged events there I get nulreferences, unless you know how to fix that (without changing the order of the Objects)Quote from: verystrengt on March 08, 2015, 05:37:57 AM

The reason I don't like to attach the handlers in the xaml code is because when I use ValueChanged events there I get nulreferences, unless you know how to fix that (without changing the order of the Objects)

I do not know what you are talking about. Since I have no idea what your code is, I cannot guess why you are getting Exceptions.
1750.

Solve : Batch file to determine size of multiple folders and add the results?

Answer»

Hi all... starting this new thread as directed.

here is what i need help with:

i need to write a batch file (preferably .bat not .vbs) that will give me the folder size of multiple directories including all sub-files and folders in MB or GB and i WOULD like it to total the sizes. i do not need it to create an out.txt file with the results. on screen display would be fine.

any and all help is appreciated.

thank you,

NFBecause the command shell cannot handle floating point calculations the end-result could be many GB less than actual. Can you accept a batch script using VBS for the evaluations?

tahnk you


www.yerindebilgisayarservisi.usDusty,

i was afraid that would be a limitation with a .bat file.

Yes, i can accept a vbs for evaluations.

thank you,

NF

all,

after Dusty's post, i decided to give up on the .bat file and started looking at .vbs. with some help this is what i came up with, and it works to show me the total size of a directory, and then display total size of a second directory, how can i modify this to show me the size in MB or GB and give me a grand total at the end.
honestly, i dont need the individual results, but only the grand total window with the results would be preferred.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("D:\FOLDERNAME")
wscript.Echo "Size: " & objFolder.Size
Set objFolder = objFSO.GetFolder("D:\FOLDERNAME")
wscript.Echo "Size: " & objFolder.Size


of course replace FOLDERNAME with the name of the folder to view the size of.

I am at the infant stages of learning .vbs so any help would be appreciated.

thanks again all

NFCode: [Select]Set objFSO = CreateObject("Scripting.FileSystemObject")

Totalbytes = 0

' Using hard coded folder names

Set objFolder = objFSO.GetFolder("F:\Download\Alacarta\Programas")

Totalbytes = Totalbytes + objFolder.Size

Set objFolder = objFSO.GetFolder("F:\Download\App-install")

Totalbytes = Totalbytes + objFolder.Size

Set objFolder = objFSO.GetFolder("F:\Download\usenet")

Totalbytes = Totalbytes + objFolder.Size

wscript.echo "CRUDE Number Representation"
wscript.echo
wscript.echo "Total size = " & Totalbytes & " bytes"
wscript.echo "Total size = " & (Totalbytes/1024) & " KB"
wscript.echo "Total size = " & (Totalbytes/(1024*1024)) & " MB"
wscript.echo "Total size = " & (Totalbytes/(1024*1024*1024)) & " GB"
wscript.echo

' I suspect that you will not require to see the max number of decimal places
' so here's how to format the number
' change false to true and see what happens...

DecimalPlaces = 2
IncludeLeadingDigit = False
UseParensForNegativeNumbers = False
GroupDigits = False

wscript.echo "Formatted Number Representation"
wscript.echo
wscript.echo "Total size = " & Formatnumber((Totalbytes/1024), DecimalPlaces, IncludeLeadingDigit, UseParensForNegativeNumbers , GroupDigits) & " KB"
wscript.echo "Total size = " & Formatnumber((Totalbytes/(1024*1024)), DecimalPlaces, IncludeLeadingDigit, UseParensForNegativeNumbers , GroupDigits) & " MB"
wscript.echo "Total size = " & Formatnumber((Totalbytes/(1024*1024*1024)), DecimalPlaces, IncludeLeadingDigit, UseParensForNegativeNumbers , GroupDigits) & " GB"

Salmon Trout,

YOU ROCK!!!!!

exactly what i needed.

thank you very much.

now as I am at "infant level" when it comes to VB knowledge, can you suggest some good sites where i can learn more about VB scripting and how to do it all.

thanks,

NFQuote from: nuckinfutz on July 20, 2010, 02:07:24 PM

can you suggest some good sites where i can learn more about VB scripting

Anybody who is thinking of learning some VBScript should download and use the Microsoft Scripting help file, script56.chm which you can get here

http://www.microsoft.com/downloads/details.aspx?familyid=01592c48-207d-4be1-8a76-1c4099d7bbb9&displaylang=en

As for websites, there are MANY but these are some I have found useful:

This one is very good

Devguru main page

http://www.devguru.com/technologies/vbscript/home.asp

Devguru index of topics

http://www.devguru.com/Technologies/vbscript/quickref/vbscript_list.html

Microsoft VBScript reference:

http://msdn.microsoft.com/en-us/library/d1wf56tt%28VS.85%29.aspx

Another VBS reference:

http://www.adminscripteditor.com/syntax.asp?l=v&lim=1

Function reference

http://www.w3schools.com/VBscript/vbscript_ref_functions.asp

VBScript forum, FAQ etc

http://www.tek-tips.com/threadminder.cfm?pid=329

download coreutils if you can. then just simply use the du command
Code: [Select]C:\test>du -sh c:\folder
the -h OPTION means display the size in human readable format, ie MB, KB.I wrote this yesterday when this thread only had dusty's response, but decided to wait to post it until the OPsaid they could use a VBScript. It's similar in many ways to Salmon Trout's except that the folder names are accepted from the command line rather then hard coded. The "FormatSize" Function is a heavily modified version of the one in my File Library.

Also, I had completely forgotten that the Size property of a folder worked to recursively acquire the entire folder's size. I originally had a routine that was doing so MANUALLY, but I have modified it since.


Code: [Select]Public Function FormatSize(ByVal Bytes)
Dim lookupprefix()



ReDim LookupPrefix(8)
LookupPrefix(0) = " Bytes"
LookupPrefix(1) = "KB"
LookupPrefix(2) = "MB"
LookupPrefix(3) = "GB"
LookupPrefix(4) = "TB"
LookupPrefix(5) = "PB"
LookupPrefix(6) = "EB"
LookupPrefix(7) = "ZB"
LookupPrefix(8) = "YB"





currval = Bytes
Do Until currval < 1024
currval = currval / 1024
countdiv = countdiv + 1
Loop

buildstr = Trim(FormatNumber(Round(currval, 2)))
buildstr = buildstr + " " + Lookupprefix(countdiv)



FormatSize = buildstr



End Function

Set FSO = CreateObject("Scripting.FileSystemObject")
For Each ARGUMENT in WScript.Arguments
wpathname = argument
WScript.Echo wpathname + ":" + FormatSize(FSO.GetFolder(wpathname).Size)

Next