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.

1151.

Solve : Link between two pages same web site.?

Answer»

This situation is very confusing. Page ONE is a list of post offices. Page two is Notes: on those post offices.
I made templates and use them to enter the INFORMATION. All of "A" post offices linked OK. The first four "B" post offices linked OK. but the fifth one did not go to the Post office Note: but to the head of the second (Notes:) page. Then alright down to number four in "C" post offices. The rest I had entered only went to the top of Notes: page.
I am using Yahoo Small Business on an iMac.
This is my first page, post office list page code.
I used a period for the GREATER than sign on the tags as it did not show right in preview.
Text
Displayed WordNotesThis is my second page, Notes: page template.
My web site is Postcards and Postal
HISTORY, http://www.postcards-postal-history.com.
If anyone can explain what is going on I would sure appreciate an explanation.

1152.

Solve : quick vbs help?

Answer» HI guys,

I'm converting a old (fully working batch file) to vbs. Mainly because I'm trying to learn vbs, but also because I can do a few extra things with vbs that can't be done via batch.

I'm using the following line (DOS) to install antivirus software silently.

Code: [Select]start /wait X:\setup.exe /s /v"/l*v log.txt /qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress

my vbs version reads like this;

Code: [Select]If (objFSO.FolderExists("C:\Program Files\Symantec AntiVirus") = false) Then
shell.run """X:\setup.exe"" /s /qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress", 1, True
end if

If you look closely you see that I've had to remove some of the switch's as the DOS version contained an extra " which confuses vbs.


Is there a way to have an extra " within a pair of " " while still having the commented section run to the last "


example;

"some stuff here - an extra " would stop the comments there, but I'd like to contine you here."

any ideas???

EDIT;

I have since made a new varaible with the full command (including the extra "). I managed to use the chr(34) to add it.

The problem now is I'm unsure how to run a .exe file with paramaters as a varaible.

any ideas??I've never encountered quotes and stars as run time switches, but hey, according to the TV, I'm no smarter than a fifth grader

This will balance the quotes, but testing this was limited. Perhaps it will work.

Code: [Select]shell.run """X:\setup.exe /s /v""/l*v /qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress""", 1, True

Quote
but also because I can do a few extra things with vbs that can't be done via batch.

This should win the understatement of the month award.

Cheers for the reply.

Quote from: Sidewinder on May 22, 2008, 05:16:59 AM

shell.run """X:\setup.exe /s /v""/l*v /qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress""", 1, True


Sadly that doesn't work, it looks for a file name "x:\setup.exe /s /v" and so keeps failing.

I have managed to build a varaiable with all the swicth's:

/s /v"/l*v log.txt /qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress

but I'm unsure how to get this varaiable in to the rull command. I've tried;

shell.run "x:\setup.exe", commands, 1, true

but it doesn't go. Shell.exec seems to have the same problem. Or have I missed something???


Quote
I have since made a new varaible with the full command (including the extra "). I managed to use the chr(34) to add it.

Can you not concatenate the strings on the run method:

Code: [Select]shell.run "X:\setup.exe " & parameterstring,1,True

Note: the space between setup.exe and the end quote.

Are there really quotes and stars in the parameter string? This seems very strange to me especially where switches are USED.

You may have to experiment with quotes or double quotes on the parameter string.



I've used your suggested code and from a small test case it seems to work great.

I'm working on a larger script to install programs, make system changes and generally make a fresh install of XP ready for a new user to log on.

I'm just installing XP on another machine, once that has finished I'll GIVE it a bash and I'll update you.

Cheers again sidewinder.

UPDATE:

I've noticed that if a pass this long string to a batch file and echo %1 I get everyting up to the first space, when it stops.

vbs script;

Code: [Select]set shell = WScript.CreateObject("Wscript.Shell")

par = "/s /v"
par2 = "/l*v log.txt /qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress"

compar = par + Chr(34) + par2

WScript.Echo compar

shell.run "C:\echo.bat " & compar, 1, True

wscript.quit


batch file to display echo;

Code: [Select]@echo off

echo %1

pause
exit

if you run these you'll see what I mean.

Is there a way to get %1 to see passed the space?

cheers again.Not sure what you're asking. My results displayed the entire string:

Quote
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

/s /v"/l*v log.txt /qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress

I get the same results with both CScript and WScript. If your results are different try changing echo.bat as batch code uses the space as a default delimiter:

Code: [Select]@echo off

echo %*

pause
exit

Hope this helps.
Nice,

echo %* does the job.

I think this is my problem. I guessing the setup.exe will only take %1. (hench why everytime I run it, it just opens the setup.exe and doesn't install)

I think I might have to start a batch file in vbs and have the batch file do the work. (tacky)

what do you reakon??? Quote
I think I might have to start a batch file in vbs and have the batch file do the work. (tacky)

I had a problem similar to this only the passed parameter was a switch followed by a path with those pesky embedded spaces.

Quote
I think this is my problem. I guessing the setup.exe will only take %1. (hench why everytime I run it, it just opens the setup.exe and doesn't install)

I'm guessing only the log.txt is resolving to %1 (in batch speak). The other parms should are switches and keywords which are not positional and are handled differently by the program.

This mishmash sets up a string with the embedded quote and the quotes around the entire string that the run method requires

Code: [Select]str = """X:\setup.exe /s /v" & """/l*v""" & " Log.txt " & """/qn NETWORKTYPE=1 SERVERNAME=basdc01 ENABLEAUTOPROTECT=1 RUNLIVEUPDATE=0 REBOOT=ReallySuppress"""
shell.Run str, 1, True

I'll let you test this and you can let us know how you made out.

PS. You don't have to build a string. Should be ok inline on the shell.run statement.
or just add the ascii value for " in the string, that works fine for me when I do stuff like thatHi guys,

Sorry I forgot I started this thread !!

I've got it running now, by using a bacth file to run the ACTUAL install. works a treat.



Cheers for all your help
1153.

Solve : send keys and find text VB .NET?

Answer»

Hello again and thank you for helping me every time.
Today I was thinking about some stuff in vb and had 2 questions that google didn't answer me:
1. How can I Sendkeys to another process without being focused on, I mean if I have the MS Word opened but minimized or in background, can I send a text to that process without making it on top of all?
2. Is it possible to find a text on another process and get the COORDINATES of where the text is? Ex find the Like button on a website with fb and get the coordinates? Without downloading the webpage, maybe using webbrowser controlQuote

1. How can I Sendkeys to another process without being focused on, I mean if I have the MS Word opened but minimized or in background, can I send a text to that process without making it on top of all?

In windows the only way I know how to pass keystroke info to another program is to select its focus and then enter the information, HOWEVER a memory hack could be performed to pass information into a program that is not the windows focus, but I cant show you how to hack it as for this can be used for evil intent..LOL


Quote
2. Is it possible to find a text on another process and get the coordinates of where the text is? Ex find the Like button on a website with fb and get the coordinates? Without downloading the webpage, maybe using webbrowser control

In order to access the information it will have to be loaded ( aka downloaded to your browser for example ) at least once. There is no way to get information from a website without at least 1 time download of the HTML etc to your browser or custom HTML interpreter which runs out same as a browser and loads the information to perform further tasks with it.

As far as finding the location of the like button it could be done by dumping the video data to a 2 dimensional array and then look for the LIKE SYMBOL. Then when found report back the location. THIS IS A LOT OF WORK! As for you would need to create a template of positives, and change the information from color to Black and White Binary 0's and 1's, where you perform an analysis on pixel locations to detect if the binary layout of the PIXELS match against a positive template or not. Then when found be able to report back the X,Y coordinates which would probably be some trial and error to calibrate.

If looking for text on a web page this is FAR EASIER, but IMAGE recognition of the Like symbol of Facebook would be quite an involved process.

Just had a vision of a flat screen display mated up ( duck taped ) with a DIGITAL OCR scanner to hunt for the FaceBook Like symbol...LOL
1. Not using sendkeys. I don't know what your goal is but it's probably doable using Office Automation.


2. Searching for the like button would be searching for an image, mostly.

Quote from: DaveLembke on August 08, 2012, 12:07:23 PM
If looking for text on a web page this is FAR EASIER, but image recognition of the Like symbol of Facebook would be quite an involved process.
I would think loading it into a webbrowser control and using DOM manipulation to find the image and get it's position might work. Of course as you point out the idea of getting any information from a site without downloading it is pretty silly. Also this has an issue in that if Facebook ever changes the image being pointed to, it stops working.the like button was an example, I want to find a text and click on it automatically but I won't know how to find the text in the pageWith intent of use still unclear, I have this to share:

If you are visiting sites that always have the buttons you want to click in the same location, a simple keyboard/mouse macro can run. I have used such macros to gather information in an automated manner, but they could also be used to add clicks to generate bogus traffic if one was trying to generate what looks like traffic from others to get paid per click. BUT those who pay per click traffic usually track to verify that macro bots aren't creating false traffic from a single IP origin to verify the validity of the traffic that they are paying for. I can only think of a company being a fool to pay per click without such an audit to verify validity of the traffic to be real traffic vs simulated traffic from automation.

If you are trying to find button locations that are ever changing, BC had the best option with the DOM manipulation to find the image and get its position to then send a simulated mouse click to it.

Quote
I want to find a text and click on it automatically
As far as hyperlinks in a web page, to follow those which are linked TEXT, you can create a program that loads the website and searches the HTML for keywords and then reads in the Hyperlink location for that matching text and then runs with that URL to perform additional duties. X and Y location of that text in the page is unnecessary because Hyperlinks in HTML are a standard structure and you can read in all information starting at " and ending at " of the URL to know the start and end point of the URL string in the page you are grabbing the link from. You then can pass that URL into a function that runs to the next page and performs another duty. And that is why finding text is so much easier than finding an image. The only other way i can think of finding an images link would be if the image was always the same name, but that doesnt happen 99% of the time.
1154.

Solve : delete with command prompt help?

Answer»

i used to use nero as a backup tool on an external hard drive, but i had my settings backing it up wayy too often and it has taken up a huge portion of the drive. I dont much care for the software anymore, so id rather just delete the entire folder of backups.

problem 1: it took absolutely forever to try and delete USING the recycle bin, and so i right clicked to see how big these files are.
according to windows, the file size of my backups is 964 gb.
That makes no sense whatsoever, as i have 892 gb of other material on the drive as is. and its only a 1tb drive.
My OS itself is only on a 75gb drive, and i have another 250gb drive attached also, so theres no way these backups could be anywhere else on the computer than the 1tb drive, however i dont understand why windows thinks the files take up so much space.

problem 2: these backup directories are insanely convoluted and i dont have the time or patience to go through each of the thousands of folders manually and delete all the files. so far though i have had no success with the RMDIR, DEL or RD commands in cmd; i continually get the error "The directory is not empty" -which im aware of, and id like to completely empty it all in one go. Im running windows 7 32bit, so i can't use DELTREE to my knowledge?

Can someone please help me with syntax on what i should be using to delete this backup folder through command prompt?

the exact location of the folder i want to delete is: "F:\Computer Backup\Desktop\Nero". Please keep in mind i have little/no experience with command prompt (compared with the experience on here im sure). I know how to NAVIGATE directories and such, and thats about it. deltree was "replaced" with a switch on rmdir, rmdir /s. so rmdir /s foldername would remove the foldername and all it's contents.

Also, you can shift-del in explorer to delete something without sending it to the recycle bin.

If the size is being reported wrong I'd run chkdsk on the drive it is on. Some directory entries are likely corrupted.ok ill try those. forgive my ignorance, WHATS chkdsk? is it a download or is it on my computer somewhere?you can check a disk by right clicking it in explorer and choosing properties, then on the hardware tab selecting "scan now". Make sure to check "automatically fix errors". chkdsk is also available at the command prompt-
Code: [Select]chkdsk /f C:would check drive C. For the system drive it might not work right off, INSTEAD requiring a reboot so that it can perform the check before the system starts up.chkdsk is a windows utility program that's used to fix your disk (partition specified) 4 errors!!
u can type chkdsk /? in the command window to get the menu of the parameters and uses of
chkdsk..!! NB: u cant chkdsk on the drive holding the OS (most cases C: drive) while the computer is
still on. u will need to schedule that to be performed in start up!!...

1155.

Solve : Guessing Game Program [JAVA]?

Answer»

I made a program that generates a random integer between 0 and 100, asks the user to guess it through console, and prints out results accordingly. I made use (most likely over use) of if and else if (methods? What do you call them?) and was wondering if what I have punched out is acceptable and efficient or unreadable spaghetti code.

package numberguessinggame2;
import java.util.Scanner;
public class NumberGuessingGame2 {
public static void main(String[] args) {

INT rdmint = 0;
int guess = 0;
while (rdmint == 0){
rdmint = (int)(Math.random()*101);
}

Scanner input = new Scanner(System.in);
while(guess != rdmint){
System.out.print("Enter an interger between 0 and 100: ");
String userinput = input.nextLine();
try {
guess = Integer.parseInt(userinput);
} catch (NumberFormatException e) {
}
boolean range = ((guess < 100) && (guess > 0));
if ((guess == rdmint) && range){
System.out.println("Your guess is correct");
}
else if ((guess > rdmint) && range){
System.out.println("Your guess is too high");
}
else if ((guess < rdmint) && range){
System.out.println("Your guess is too low");
}else {
System.out.println("Your guess is invalid");
}
}
}
}

Why not try something like NetBeans and run it. You'll soon find out if it works.

http://netbeans.org/Quote from: reddevilggg on June 09, 2012, 08:12:34 AM

Why not try something like NetBeans and run it. You'll soon find out if it works.

http://netbeans.org/

The program seems to run correctly. I'm more concerned with it's complexity. Am I following the correct style or reinventing the wheel?My tutor always told me "if it works, it works". Ask 10 people to do the same thing and you will probably get 10 different answers. Experience and practice will allow you to streamline code, as you progress.

Example.
Q: What 2 numbers, when ADDED, equal 10?
A: 9+1 or 8+2 or 7+3 etc

Also, test the boundries...
Quote
I made use (most likely over use) of if and else if (methods? What do you call them?
Control structures.

The code is not indented/formatted well, but I think that might be because it was placed into the post and not in a separate code tag:

Code: [Select]package numberguessinggame2;
import java.util.Scanner;
public class NumberGuessingGame2 {
public static void main(String[] args) {
int rdmint = 0;
int guess = 0;

while (rdmint == 0){
rdmint = (int)(Math.random()*101);
}

Scanner input = new Scanner(System.in);
while(guess != rdmint){

System.out.print("Enter an interger between 0 and 100: ");
String userinput = input.nextLine();
try {guess = Integer.parseInt(userinput);} catch (NumberFormatException e) {}
boolean range = ((guess < 100) && (guess > 0));

if ((guess == rdmint) && range){
System.out.println("Your guess is correct");
}
else if ((guess > rdmint) && range){
System.out.println("Your guess is too high");
}
else if ((guess < rdmint) && range){
System.out.println("Your guess is too low");
}else{
System.out.println("Your guess is invalid");
}

}
}
}

another common idiom is to label the closing brace for the larger constructs. (the second while here, the main method, and the class, for instance).

You could also replace the try..catch logic with something a bit simpler, as well as more functional:

eg. instead of:
Code: [Select]System.out.print("Enter an interger between 0 and 100: ");
String userinput = input.nextLine();
try {guess = Integer.parseInt(userinput);} catch (NumberFormatException e) {}
boolean range = ((guess < 100) && (guess > 0));

Code: [Select]do {
System.out.print("Enter an integer between 0 and 100: ");
if(scanner.hasNextInt()) x = scanner.nextInt();
else scanner.next();
} while (guess < 0 || guess > 100);
which would MAKE the use of "range" in the conditionals lower down redundant, since by that point the number has been guaranteed to be in that range by the input loop.
I put in the hasNextInt method you put down as well as removed the range variable and tried to adjust the spacing of the brackets accordingly. Does the hasNextInt method (for lack of a BETTER word) initialize the scanner?

Code: [Select]package numberguessinggame2;
import java.util.Scanner;
public class NumberGuessingGame2 {
public static void main(String[] args) {
// Initialize variables and scanners
int rdmint = 0;
int guess = 0;
Scanner input = new Scanner(System.in);
String invalidEntry = "Invalid entry.";

//GENERATE a random integer between 0 and 100
while (rdmint == 0){
rdmint = (int)(Math.random()*101);
}

//Take in a guess from user and determine if it is a valid entry. Then determine if it is the correct entry. Display results to console.
while ((guess <= 0) || (guess >= 100) || (guess != rdmint)){
System.out.print("Enter an integer between 0 and 100: ");
if((input.hasNextInt())){
guess = input.nextInt();
if (guess < 100 && guess > 0){
if (guess == rdmint){
System.out.println("Your guess is correct");
}
if (guess < rdmint){
System.out.println("Your guess is too low");
}
if (guess > rdmint){
System.out.println("Your guess is too high");
}
}
else{
System.out.println(invalidEntry);
}
}
else{
System.out.println(invalidEntry);
input.next();
}
}
}
}
1156.

Solve : Re: Visual FoxPro: Remove Duplicate entries?

Answer»

hi,
i am facing while creating actuall report in my FOXPRO base programe

actually in my records i have duplicate i LIKE to FIND those duplicate records and NEED to be delete
pls. HELP how to do through command

tnkx
thirumalai

1157.

Solve : Algorithm used in Text Twist game?

Answer»

can anyone help me with this,im trying to LOOK for algorithms possibly USABLE for a game similar to text TWIST. an algorithm that can search for character combination in a string in different LENGTH like in a seven letter word, an algorithm that can GIVE letter combination of 3 4 5 6 letter.i need to study algorithms that can has this ability or somewhat similar t this. thanks in advance

1158.

Solve : SQL Jobs, can copy file in server1,2,3 and past file in server4?

Answer»

hellou.
can you HELP, please to CREATE a job in SQL Server 2008, which will COPY a file from serveri1,server2,server3(target) and they can paste in server4,(destin) in path per EXAMPLE, D://Backup Server/Server1, D://Backup Server/Server2, D://Backup Server/Server3.
Best Regards
Eng Shyqyri Hysesani.

1159.

Solve : Help with writing to file?

Answer» HI i am having trouble with a BATCH file i am creating: i have successfully created batch files that WRITE into another batch file, but when i ADD a user-set variable to the NAME before the extension it wont create a file instead it creates a folder under the name of the user-set variable the the extension.
Can someone please tell me what is going wrong with the file Quote from: darthv55 on June 16, 2012, 11:56:21 AM
Can someone please tell me what is going wrong with the file

When we see it, maybe...
1160.

Solve : Android Game?

Answer»

Hello all,

I've started on a new android application the other day, and i'm designing it with the tablet in mind. It's going to be a multiplayer game and the basic idea of it is to have a "player" object on each side of the SCREEN and both players will be able to move and rotate their character at will and shoot at each other.

I'm getting close to getting the basic functionality working in it, but I've stumbled into a roadblock. I can't figure out how to get both objects to rotate at the same time without affecting the one that isn't MEANT to rotate. In other words, if I rotate one object, the other one either isn't being displayed on the screen, or is being rotated around the screen too, if that makes any sense.

I've included the source below and all help is hugely appreciated! Thank you

Here is my main source file, AndroidDuelActivity.java
Code: [SELECT]package com.android.androidduel;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;

public class AndroidDuelActivity extends Activity {

private Player player1;
private Player player2;

private float touchX;
private float touchY;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new Panel(this));
}

class Panel extends SurfaceView implements SurfaceHolder.Callback {
private AndThread _thread;

public Panel(Context context) {
super(context);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getHolder().addCallback(this);
_thread = new AndThread(getHolder(),this);

player1 = new Player(50, 250, 250);
player2 = new Player(925, 250, 725);
}

public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
public void surfaceCreated(SurfaceHolder holder) {
_thread.setRunning(true);
_thread.start();
}
public void surfaceDestroyed(SurfaceHolder holder) {
boolean retry = true;
_thread.setRunning(false);
while (retry) {
try {
_thread.join();
retry = false;
} catch(InterruptedException e) {
// ... again and again..and again!
}
}
}

public void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
//canvas.restore();

Matrix matrix = new Matrix();
if (touchX < player1.getRLimit()) {
matrix.setRotate(player1.getRotationAngle(),
player1.getX()+player1.getImage().getWidth()/2,
player1.getY()+player1.getImage().getHeight()/2);

canvas.setMatrix(matrix);
//canvas.drawBitmap(player1.getImage(), player1.getX(), player1.getY(), null);
}

if (touchX > player2.getRLimit()) {
matrix.setRotate(player2.getRotationAngle(),
player2.getX()+player2.getImage().getWidth()/2,
player2.getY()+player2.getImage().getHeight()/2);

canvas.setMatrix(matrix);
//canvas.drawBitmap(player2.getImage(), player2.getX(), player2.getY(), null);
}

canvas.drawBitmap(player1.getImage(), player1.getX(), player1.getY(), null);
canvas.drawBitmap(player2.getImage(), player2.getX(), player2.getY(), null);

canvas.save();
canvas.setMatrix(null);
}

/*
* Get the touch coordinates to detect the angle
*/
public boolean onTouchEvent(MotionEvent event) {
touchX = event.getX();
touchY = event.getY();
if (touchX < player1.getRLimit())
Log.i("AndroidDuel", "Mouse detected at -- "+touchX+" "+touchY);
if (touchX > player2.getRLimit())
Log.i("AndroidDuel", "Mouse detected at -- "+touchX+" "+touchY);
return true;
}
}

/*
*
* Player class
*/
class Player {

private Bitmap image;
private int x;
private int y;
private int rLimit;

Player(int x, int y, int rLimit) {
image = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
this.x = x;
this.y = y;
this.rLimit = rLimit;
}

public float getRotationAngle() {
float centerX = x+image.getWidth()/2;
float centerY = y+image.getHeight()/2;
float radians = (float) Math.atan2(centerX-touchX, centerY-touchY);
float degrees = (57.2957795f*radians) * -1;

return degrees;
}

public Bitmap getImage() { return this.image; }
public int getX() { return this.x; }
public int getY() { return this.y; }
public int getRLimit() { return this.rLimit; }
}
}
I'm also using a custom thread class, AndThread.java, but I didn't include this because I didn't think that it would help with my issue, but if anyone thinks that i should include it, just let me know so I can throw it up on here.You should move the drawing code into the player itself:

Code: [Select]public void draw(Graphics g){
Matrix cached = g.getMatrix();
canvas.setMatrix(matrix);
if (touchX < this.getRLimit())
matrix.setRotate(player1.getRotationAngle(),
getX()+getImage().getWidth()/2,
getY()+getImage().getHeight()/2);


canvas.drawBitmap(getImage(), getX(), getY(), null);
canvas.setMatrix(cached);
}


Basic idea is to save the initial rotation, rotate if NECESSARY, draw, and then reset it to what it was.Thank you for your post BC_Programmer. I don't know why I didn't think of that, actually. But I will surely give this a shot.

1161.

Solve : Managed arrays as SAFEARRAYS in native C++?

Answer»

Hey all:

I have a question I would like to POSE regarding a resulting SAFEARRAY from managed code. I have a C# class that contains a struct and a METHOD that returns an array of that struct. For example:

Code: [Select]
struct myStruct
{
[MarshalAs(UnmanagedType.R8)]
double val1;
[MarshalAs(UnmanagedType.R8)]
double val2;
[MarshalAs(UnmanagedType.R8)]
double val3;
[MarshalAs(UnmanagedType.R8)]
double val4;

[MarshalAs(UnmanagedType.BStr)]
string name;
}

myStruct[] buildStructArray(Rectangle rect);


I can follow the progression of the method when I call it from the native C++ source code. Inside there, the code is running through and building the myStruct[] accordingly. When the C# class is COM interopped, the struct array is converted to a SAFEARRAY so the C++ progression looks something like:

Code: [Select]
SAFEARRAY *pStructArray = NULL;

myClass->buildStructArray(rect, &pStructArray );

// Get the IRecordInfo object associated with the structure.
IRecordInfoPtr spIRecordInfo = NULL;
SafeArrayGetRecordInfo(pStructArray , &spIRecordInfo);

// Get the lower and upper bounds for the inner safe array data.
long lBound = 0;
long uBound = 0;
SafeArrayGetLBound(pStructArray , 1, &lBound);
SafeArrayGetUBound(pStructArray , 1, &uBound);

long dimSize = uSubBound - lSubBound + 1;
long rgIndices[1];

for(int i = 0; i &LT; dimSize; i++)
{
rgIndices[0] = i;

myStruct* curMyStruct;

memset(&curMyStruct, 0, sizeof(curMyStruct));

SafeArrayGetElement(pStructArray , rgIndices, &curMyStruct);

// Try to read the values from the SAFEARRAY here. The values are garbled or non-existent.

spIRecordInfo -> RecordClear((PVOID)&curMyStruct);


OK. So getting the values from the SAFEARRAY is erroneous. I am trying view the name using something along the lines of:

Code: [Select]
DisplayMessage((const char *)curMyStruct->name));


...and the double values using the code:

Code: [Select]
double curVal1 = 0.0;
double curVal2 = 0.0;
double curVal3 = 0.0;
double curVal4 = 0.0;

curVal1 = curMyStruct->val1;
curVal2 = curMyStruct->val2;
curVal3 = curMyStruct->val3;
curVal4 = curMyStruct->val4;

std::stringstream val1ss;
std::stringstream val2ss;
std::stringstream val3ss;
std::stringstream val4ss;

val1ss<< curVal1 ;
val2ss<< curVal2 ;
val3ss<< curVal3 ;
val4ss<< curVal4 ;

DisplayMessage(_T(val1ss.str().c_str()));
DisplayMessage(_T(val2ss.str().c_str()));
DisplayMessage(_T(val3ss.str().c_str()));
DisplayMessage(_T(val4ss.str().c_str()));


I am confident in the DisplayMessage function because it is used successfully throughout the code quite frequently. I am going to have to figure out why the SAFEARRAY has bogus values or find another option to using arrays.

So my question: why am I getting the erroneous values when I can see the values being stored inside the managed method when being called from the C++ code?

THANKS for any input.

1162.

Solve : Strange Pointer-Like Behaviour VB.NET?

Answer»

I have this piece of code, as an example and I'm totally confused why it's not working properly.
Code: [Select]Dim p(0) As Planet
Dim m(0) As Planet
p(0) = NEW Planet
m(0) = New Planet
p(0).IsMoon = False
m = p
m(0).IsMoon = True
MsgBox("P: " & p(0).IsMoon & " M: " & m(0).IsMoon)And here's the planet class:
Code: [Select]Public Class Planet
Private _radius As Integer
Private _Inhabited As Boolean
Private _NaturalSatellite As Boolean
Private _Population As Integer
Private _NumberOfMoons As Integer
Private av_temp As Integer
Private av_temp_variation As Integer
Private satellites() As Planet
Private _ismoon As Boolean
Private _res() As Resources
Private _Neutral As Boolean
Private _GoodGuys As Boolean
Private _HelpingEramind As Boolean
Private _ContainerCSV As String
Public Property ContainerCSV As String
Get
Return _ContainerCSV
End Get
SET(value As String)
_ContainerCSV = value
End Set
End Property
Public Property Radius() As Integer
Get
Return _radius
End Get
Set(value As Integer)
_radius = value
End Set
End Property
Public Property Inhabited() As Boolean
Get
Return _Inhabited
End Get
Set(value As Boolean)
_Inhabited = value
End Set
End Property
Public Property HasMoon() As Boolean
Get
Return _NaturalSatellite
End Get
Set(value As Boolean)
_NaturalSatellite = value
End Set
End Property
Public Property POPULATION() As Integer
Get
Return _Population
End Get
Set(value As Integer)
_Population = value
End Set
End Property
Public Property AverageTemp() As Integer
Get
Return av_temp
End Get
Set(value As Integer)
av_temp = value
End Set
End Property
Public Property TempVariation() As Integer
Get
Return av_temp_variation
End Get
Set(value As Integer)
av_temp_variation = value
End Set
End Property
Public Property NumberOfMoons As Integer
Get
Return _NumberOfMoons
End Get
Set(value As Integer)
_NumberOfMoons = value
End Set
End Property
Public Property Moons As Planet()
Get
Return satellites
End Get
Set(value As Planet())
satellites = value
End Set
End Property
Public Property IsMoon As Boolean
Get
Return _ismoon
End Get
Set(ByVal value As Boolean)
_ismoon = value
End Set
End Property
Public Property PlanetResources As Resources()
Get
Return _res
End Get
Set(ByVal value As Resources())
_res = value
End Set
End Property
Public Property Neutral() As Boolean
Get
Return _Neutral
End Get
Set(value As Boolean)
_Neutral = value
End Set
End Property
Public Property GoodGuys() As Boolean
Get
Return _GoodGuys
End Get
Set(value As Boolean)
_GoodGuys = value
End Set
End Property
Public Property HelpingEramind() As Boolean
Get 'okay
Return _HelpingEramind
End Get
Set(value As Boolean)
_HelpingEramind = value
End Set
End Property
End Class
Now, the weird thing is that when the MsgBox comes up, it prints "P: True M: True". Shouldn't it be "P: False M: True"? Why is vb.net, a language completely devoid of pointers, suddenly behaving as if it has them all of a sudden?Quote from: glaba on August 01, 2012, 11:45:25 AM

I have this piece of code, as an example and I'm totally confused why it's not working properly.
It is working 'properly'. Actually, it would work similarly in VB4, VB5, or VB6.
Code: [Select]Dim p(0) As Planet
Dim m(0) As Planet
p(0) = New Planet
m(0) = New Planet
p(0).IsMoon = False
m = p
m(0).IsMoon = True
MsgBox("P: " & p(0).IsMoon & " M: " & m(0).IsMoon)
the assignment between arrays copies the array p to the array m.

However, the array p is a 1-item array of "Planet". A Object VARIABLE is actually a REFERENCE to the actual object, not the object itself. Assigning Objects does not copy them. You assigned them both to new instances, but then set the m(0) to the same object as p(0).




Quote
Now, the weird thing is that when the MsgBox comes up, it prints "P: True M: True". Shouldn't it be "P: False M: True"? Why is vb.net, a language completely devoid of pointers, suddenly behaving as if it has them all of a sudden?
VB.NET has never been devoid of pointers in the form of references. A Object variable is a reference(pointer) to a instance of that object (or Nothing). If you really want them to be separate, you will need to implement a method within the class to clone them. Alternatively, you can make the class a struct.oh, i didn't realize that assigning objects didn't copy them thanks. i still find it odd that vb should copy the reference, though. I thought it was only C-based languages that did this.Quote from: glaba on August 01, 2012, 02:57:58 PM
oh, i didn't realize that assigning objects didn't copy them thanks. i still find it odd that vb should copy the reference, though. I thought it was only C-based languages that did this.

I don't know of any language that doesn't.
1163.

Solve : automated emails for document modification?

Answer»

I am working with WINDOWS xp and have basically no programming experience... I have a basic excell (2010) document saved on a shared drive over the company network. The goal is to have a batch (or any language really, I'm not picky) program that will check if the document has been saved (ie modified RECENTLY) and SEND me an email (using outlook 2010) if it has been. I figured I can used Task Scheduler to run the Batch file every ten minutes or so, but I'm basically at a loss as FAR as the program itself. Any thoughts would be appreciated thanks!Welcome to CH.
You NEED to resolve this with other users in your group.
Excel has some work group rules about how a document can be changed. One rule is that a change has to become a new document, the old document is still there for reference.

In your documentation find "Workgroup Rules" as see if that fits your problem.

1164.

Solve : How does it work?? sequence points???

Answer» INT i=0;
i= ++i + i++ + ++i ;
printf("%d",i);Result is five.

Assuming standard C code. Left to right associativity is present for operators with equal precedence.

++i is evaluated first. The prefix operator RETURNS the incremented value. in this case, 1.

1 + i++ + ++i

and i has the value 1.

next, i++ is evaluated. this returns the value before increment; 1.

1 + 1 + ++i

last, the prefix operator returns the incremented value, or three.

1 + 1 + 3


i changes value throughout the expression as it is evaluated. each increment operation is guaranteed to be complete before the value is used in an expression, so in that SENSE the binary + operators can be considered SEQUENCE points.
thanx
1165.

Solve : Microsoft Visual Foxpro Newbie?

Answer» GOOD morning sorry to disturb i wanna know how to lessen the NUMBER zeros when i compute a tuition fee program for example 10% discount of 1000 is 900.00 but it appears 900.000 instead . Any suggestions please . ty.Welcome to CH. Some THINGS to need to do.
1. Please include the NAME of the OS you use.
2. Provide some specific details about how you do the calculation. Fox PRO has the same expression rules as do similar programs.
1166.

Solve : C# Copy file problem.?

Answer»

Hello, I am having some problems with a code that I am working on it is supposed to copy everything in one folder and then place the copy where the file is.

The Problem is when I test it, it incorrectly creates the exe files and they end up beeping at me several times before closing when I run the copies.

is there a way I could improve this code or is it not possible to copy exe files? Every other file type I have tried worked with this method.

Code: [Select]using System;
using System.IO;
namespace CopyFiles
{
public class Copy
{
public static void Main()
{
int Byte;
string Lines;
Byte = 0;
Lines = "";
string [] files = Directory.GetFiles("TestFolder");
foreach(string file in files)
{
Lines = "";
string filee = file.Replace("TestFolder\\", "");
FileStream A = new FileStream(@file, FileMode.Open);
for (int i = 0; (Byte = A.ReadByte()) != -1; i++)
{
char by = (char)(Byte);
Lines = Lines + by;
}
A.Close();
FileStream B = new FileStream(@filee, FileMode.Create);
foreach(char l in Lines)
{
Byte = (int)(l);
B.WriteByte(Convert.ToByte(Byte));
}
B.Close();
}
}
}
}

C#/.NET use Unicode.
a Unicode char is 2 bytes in size. A byte is one... byte. Converting LIKE this will not work. Additionally, when you have certain code points in a string it will create different unicode characters. You should not be using a string. I am not on Windows atm so I cannot test with an EXECUTABLE but you could use SOMETHING like fc on the original and destination to see how the conversions are screwing up the executable.

You are reading the entire file into memory, then writing that to a new file. Why? Why not do both at once? eg.

Code: [Select] int bufferSize = 1024 * 64;
using(FileStream is = new FileStream("source",FileMode.Open,FileAccess.Read))
{
using (FileStream fs = new FileStream("destination", FileMode.OpenOrCreate, FileAccess.Write))
{

int bytesRead = -1;
byte[] bytes = new byte[bufferSize];

while ((bytesRead = is.Read(bytes, 0, bufferSize)) > 0)
{
fs.Write(bytes, 0, bytesRead);
}
fs.Flush();
}
}
Or, could do something really crazy like use the provided .NET framework method for this purpose:

Code: [Select]File.Copy("Source","Destination");

Well so far I tried to test your code by compiling and it doesn't like your using statements here is the error.

Copy.cs(10,22): error CS1031: Type expected
Copy.cs(18,21): error CS1525: Invalid expression term 'is'

I think I'll go through msdn.microsoft.com to see if I can find another way to do this. Your idea is really good THANK you for the help =)

EDIT: No the problem seems to not be the using but the first FileStream itself, I'll see if I can figure this out >.<

EDIT AGAIN: okay the problem was the file streams name all it needed was to be changed from is to just about anything else >.>Thank you, you solved my problem I re tested the code and it works =)
Quote from: hibyy on July 26, 2012, 06:28:16 AM

EDIT AGAIN: okay the problem was the file streams name all it needed was to be changed from is to just about anything else >.>

Yep, sorry about that. 'is' is a C# keyword, so using it as a variable name was a mistake on my part.
1167.

Solve : Which language to choose between QBASIC or C++?

Answer»

I learned intro to C# off one of those MS Books and its a great book with examples and at the back of the book it came with a DVD containing all the Express packages C++, C#, Visual Basic, etc. They must have made 1 DVD for every Express Programming book they made vs making 3 or more different discs. My favorite project in the MS C# Express book was making your own custom browser, spinoff of IE. I found C# very easy given that I came from a background in Basic, C++, Perl, and a few other languages and scripting languages. Was amazed at how simple it is to use and it automatically populates sections of code when adding features to your programs in addition to how it starts you out with a template SORT of, of the necessities to make any program without having to type in what would be redundant to every program. C# was definately designed for RAPID development and ease of use. I too suggest C#. I started with GW-Basic way back in the 1980s and worked my way from that to QBasic, then C, then C++. I find C++ for the most part easy but its only because I have written programs in it for the past 14 years. Anyone jumping from say Basic with line numbers to C++ or any other modernized language for that sake is in for a challenge when they have to break the spaghetti code habits of what Basic with line numbers created. Teaching others programming basics I find it easier to train people with no experience than those with exposure to Basic with line numbers, as for some habits are hard to break, and although you can add goto's in modern languages its poor programming grammar to add them when they can be avoided with cleaner coding. Have I added goto's...YES... sometimes its nice to throw one in there for a 10 SECOND fix, but I generally avoid them when POSSIBLE.

1168.

Solve : VB Cross-Thread Operation not valid?

Answer»

Hello again!
I encountered another strange thing while programming for fun, this is the sub where I get an error:
Code: [Select] Private Sub checkversion()
Me.VersionTableAdapter.Fill(Me.Update.version)
onlineversion1 = ListBox1.SelectedItem("version").ToString()
onlineversion = CDbl(onlineversion1)
AccessControl()
textonline.Text = "Versiune Online: " & onlineversion
Label1.Text = onlineversion1
If version = onlineversion Then

Else
actualizaredisp = 1
MsgBox("A aparut o versiune mai noua! Apasati Ok pentru a face update." & vbLf & "Versiunea programului: " & version & vbLf & "Versiunea noua: " & onlineversion & vbLf & vbLf & "Apasati F1 pentru actualizare!", MsgBoxStyle.YesNo, "Actualizare disponibila!")
End If
End Sub
I get the error "Cross-thread operation not valid: Control 'Form1' accessed from a thread other than the thread it was created on."

Code: [Select]System.InvalidOperationException was unhandled by user code
Message=Cross-thread operation not valid: Control 'pornire' accessed from a thread other than the thread it was created on.
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.get_InternalHandle()
at System.Windows.Forms.Control.get_CreateParams()
at System.Windows.Forms.Label.get_CreateParams()
at System.Windows.Forms.Control.SizeFromClientSize(Int32 width, Int32 height)
at System.Windows.Forms.Control.SizeFromClientSize(Size clientSize)
at System.Windows.Forms.Label.GetBordersAndPadding()
at System.Windows.Forms.Label.GetPreferredSizeCore(Size proposedConstraints)
at System.Windows.Forms.Control.GetPreferredSize(Size proposedSize)
at System.Windows.Forms.Label.GetPreferredSize(Size proposedSize)
at System.Windows.Forms.Control.get_PreferredSize()
at System.Windows.Forms.Label.AdjustSize()
at System.Windows.Forms.Label.OnTextChanged(EventArgs e)
at System.Windows.Forms.Control.set_Text(String value)
at System.Windows.Forms.Label.set_Text(String value)
at centrala_concurs.pornire.Button10_Click() in C:\Users\alecs_000\Documents\Visual Studio 2010\Projects\centrala_concurs\centrala_concurs\pornire.vb:LINE 106
at centrala_concurs.pornire.BackgroundWorker1_DoWork(Object sender, DoWorkEventArgs e) in C:\Users\alecs_000\Documents\Visual Studio 2010\Projects\centrala_concurs\centrala_concurs\pornire.vb:line 116
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
InnerException:

I searched on Google but didn't actually understand the code and I don't use pieces of code that I don't understand.

Thank you again:DWhen accessing Windows Forms from another thread, you need to use Invoke on the TARGET control. eg. to set the text of a label from another thread:


Code: [Select]Label1.Text="hello"


will throw an error.

Code: [Select]Me.Invoke((Function() Label1.Text="hello"))
I'm not 100% Sure for VB; this is AFAIK the equivalent to this C#:
Code: [Select]this.Invoke((MethodInvoker)(()=>Label1.Text="hello"));

Figured it out, works now:D
now i'm getting another error:
Code: [Select] If version = onlineversion Then

Else
MsgBox("A aparut o versiune mai noua! Apasati Ok pentru a face update." & vbLf & "Versiunea programului: " & version & vbLf & "Versiunea noua: " & onlineversion & vbLf & vbLf & "Apasati F1 pentru actualizare!", MsgBoxStyle.YesNo, "Actualizare disponibila!")
actualizare.Show()
End If
An error occurred creating the form. See Exception.InnerException for details. The error is: CONVERSION from string "" to type 'Double' is not valid.

Visual Studio shows that the error is at actualizare.show()Quote from: alecsillidan on July 21, 2012, 11:53:19 AM

It works setting the label text, the error occures in line "If version = onlineversion Then" and I'm not getting the ideea...how i'm supposed to make the if condition if vb can't read those variables or idk why i'm getting that error:|

The exception message indicates the error is caused by attempting to set the text of the label:

Quote
StackTrace:
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.get_Intern alHandle()
at System.Windows.Forms.Control.get_Create Params()
at System.Windows.Forms.Label.get_CreatePa rams()
at System.Windows.Forms.Control.SizeFromCl ientSize(Int32 width, Int32 height)
at System.Windows.Forms.Control.SizeFromCl ientSize(Size clientSize)
at System.Windows.Forms.Label.GetBordersAn dPadding()
at System.Windows.Forms.Label.GetPreferred SizeCore(Size proposedConstraints)
at System.Windows.Forms.Control.GetPreferr edSize(Size proposedSize)
at System.Windows.Forms.Label.GetPreferred Size(Size proposedSize)
at System.Windows.Forms.Control.get_Prefer redSize()
at System.Windows.Forms.Label.AdjustSize()
at System.Windows.Forms.Label.OnTextChange d(EventArgs e)
at System.Windows.Forms.Control.set_Text(String value)
at System.Windows.Forms.Label.set_Text(String value)

at centrala_concurs.pornire.Button10_Click() in C:\Users\alecs_000\Documents\Visual Studio 2010\Projects\centrala_concurs\centrala_concurs\pornire.vb:line 106
at centrala_concurs.pornire.BackgroundWork er1_DoWork(Object sender, DoWorkEventArgs e) in C:\Users\alecs_000\Documents\Visual Studio 2010\Projects\centrala_concurs\centrala_concurs\pornire.vb:line 116
at System.ComponentModel.BackgroundWorker. OnDoWork(DoWorkEventArgs e)
at System.ComponentModel.BackgroundWorker. WorkerThreadStart(Object argument)

What is line 106 and 116 of "pornire.vb"?
nvm i'm noob, i modified the previous POST, read it again please:))See Exception.InnerException for details.

Sounds like an error within the Form_Load to me, but without the InnerException it's hard to say exactly where it is.

EDIT: if you are using Visual Studio, the "Exception Helper" should let you look at the inner exception.It's working! I was using a double variable with a string text =))
Thank you dude, you're life saver
1169.

Solve : PHP - Help Scrape a page?

Answer»

Hey guys,

Can someone help me scrape this page please: http://director.flyerservices.com/SOB/default.aspx?banner=Sobeys&pubtype=1&language=en&view=Text&storeNumber=743

The page seems to redirect to another page and my PHP result from cURL says "Object moved here".

Can someone please PROVIDE me with a solution on how to scrape this page?

Thank you in advance,


- ultimatumI always feel slightly uneasy about helping out with screen scraping. There are plenty of legitimate use cases, of course, and I am not for one second suggesting that your intentions are dark - but the intentions of many reading this thread may be less scrupulous.

So let's keep this to helpful pointers.

Firstly, I'd strongly recommend reading up on curl_setopt(): http://uk3.php.net/manual/en/function.curl-setopt.php Pay particular attention to the myriad of options and the effects they have. HINT: one of my web apps uses the following, but these of course may not be appropriate for your needs:

Code: [Select] curl_setopt($this-&GT;_ch, CURLOPT_POST, 1);
curl_setopt($this->_ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($this->_ch, CURLOPT_COOKIEJAR, '/tmp/cookies/cookie_'.$cookie_serial.'.txt');
curl_setopt($this->_ch, CURLOPT_HEADER , 1);
curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->_ch, CURLOPT_TIMEOUT, 25);
curl_setopt($this->_ch, CURLOPT_CONNECTTIMEOUT, 25);
curl_setopt($this->_ch, CURLOPT_SSL_VERIFYPEER, false); // cURL having problems with CA certificates

Secondly, get yourself a copy of Fiddler. Understand what it does. It will help you immensely with tricky web transactions: http://www.fiddler2.com/Fiddler2/

1170.

Solve : AS3 Rotating a sprite?

Answer»

Hey all,

I am in the process of MAKING a game using Actionscript 3 in FlashDevelop. In this game, you will have a player object located in a fixed position (for now..) on the screen and can control your player using your mouse. I want this sprite to ROTATE from it's CENTERPOINT and facing the mouse. I'm having a heck of a time getting this to work how I want it to, and the closest I can get is to get it to rotate from it's top left corner. I've googled for hours on the subject, but if anyone knows a good tutorial on this, or a snippet of code for me, that would be super helpful. Thank you I am not familiar with action-script (i wish i was), but is it possible to copy the sprite image file multiple times and have it partially rotated with your graphics editor

Then in your program have the sprite redrawn as the partially rotated sprite files?
Does this make sense? Seems the commonly accepted method is to put the bitmap in a sprite and rotate it that way:
Code: [SELECT]var spriteContainer:Sprite = NEW Sprite ();
bitmap.x = - bitmap.width / 2;
bitmap.y = - bitmap.height / 2;
spriteContainer.addChild (bitmap);
addChild (spriteContainer);
spriteContainer.rotation = 30; //put your rotation here

1171.

Solve : python and tk?

Answer»

I'm starting to create a program but when it run an undesired result occurs.
CODE: [SELECT]import sys
from Tkinter import *
import ttk
import tkFileDialog

def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
root.title('GUI')
root.geometry('273x450+123+194')
w = GUI (root)
init()
root.mainloop()

w = None
def create_GUI (root):
'''Starting point when module is imported by another program.'''
global w, w_win
if w: # So we have only one INSTANCE of window.
return
w = Toplevel (root)
w.title('GUI')
w.geometry('273x450+123+194')
w_win = GUI (w)
init()
return w_win

def destroy_GUI ():
global w
w.destroy()
w = None
def files():
tkFileDialog.askopenfile(mode='r')



def init():
pass


class GUI:
def __init__(self, master=None):
# Set background of toplevel window to match
# current style
style = ttk.Style()
theme = style.theme_use()
default = style.lookup(theme, 'background')
master.configure(background=default)

self.Entry1 = Entry (master)
self.Entry1.place(relx=0.11,rely=0.09,relheight=0.06,relwidth=0.64)
self.Entry1.configure(background="white")

self.Button1 = Button (master)
self.Button1.place(relx=0.77,rely=0.09,height=27,width=51)
self.Button1.configure(pady="0")
self.Button1.configure(text='''...''')
self.Button1.configure(command=files())







if __name__ == '__main__':
vp_start_gui()
For some reason when you run it the button's command is run and doesn't run when you click it.TheWaffle,

It can help a lot if you indicate what OS you have and which version pf Python. And how does TK fit in here?

Did you copy this code from a sample file?It's because you are CALLING the files command as a parameter. You need to pass the Function object itself. Leave off the parentheses, for example, rather than this:
Code: [Select]self.Button1.configure(command=files())

try this:

Code: [Select]self.Button1.configure(command=files)


Answer to Geek-9pm
windows xp
python 2.7
it came in the msi
NO i didn't copy this it is one i started to writeBut now how can i display the file path in the Entry1 object from the files function?CURRENT CODE:Code: [Select]import sys
from Tkinter import *
import ttk
import tkFileDialog

def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
root.title('GUI')
root.geometry('273x450+123+194')
w = GUI (root)
init()
root.mainloop()

w = None
def create_GUI (root):
'''Starting point when module is imported by another program.'''
global w, w_win
if w: # So we have only one instance of window.
return
w = Toplevel (root)
w.title('GUI')
w.geometry('259x244+115+138')
w_win = GUI (w)
init()
return w_win

def destroy_GUI ():
global w
w.destroy()
w = None

def init():
pass

def files():
global fp
fp = tkFileDialog.askopenfile(mode='r')
Entry1.delete(0, END)
Entry1.insert(0, fp)


class GUI:
def __init__(self, master=None):
# Set background of toplevel window to match
# current style
style = ttk.Style()
theme = style.theme_use()
default = style.lookup(theme, 'background')
master.configure(background=default)
global Entry1
Entry1 = Entry (master)
Entry1.place(relx=0.11,rely=0.09,relheight=0.06,relwidth=0.64)
Entry1.configure(background="white")

self.Button1 = Button (master)
self.Button1.place(relx=0.77,rely=0.09,height=27,width=51)
self.Button1.configure(pady="0")
self.Button1.configure(text='''...''')
self.Button1.configure(command=files)


if __name__ == '__main__':
vp_start_gui()
SEE ABOVE POSTYou might want to look up some of the python documentation for 'global'.I looked into that and found my problem but I expanded on my project to create a gui for a python code freezer
for some reason now the RADIO buttons are stuck together when you choose one you choose the one under itCode: [Select]import sys
from Tkinter import *
import ttk
import tkFileDialog
import os
import tkMessageBox



def vp_start_gui():
'''Starting point when module is the main routine.'''
global val, w, root
root = Tk()
root.title('Freezer')
root.geometry('254x244+119+190')
w = Freezer (root)
init()
root.mainloop()

w = None
def create_Freezer (root):
'''Starting point when module is imported by another program.'''
global w, w_win
if w: # So we have only one instance of window.
return
w = Toplevel (root)
w.title('Freezer')
w.geometry('254x244+119+190')
w_win = Freezer (w)
init()
return w_win

def destroy_Freezer ():
global w
w.destroy()
w = None




def init():
pass

def files():
global fp
file_opt = options = {}
options['filetypes'] = [('python files', '.py'), ('python no-console files', '.pyw'), ('all files', '.*')]
options['initialdir'] = 'C:\\'
options['parent'] = root
options['title'] = 'Choose a File'
fp = tkFileDialog.asksaveasfilename(**file_opt)
Entry1.delete(0, END)
Entry1.insert(0, fp)
fp = Entry1.get()
global ol
def rb1():
ol='1'
def rb2():
ol='2'
def rb3():
ol='3'
global conc
def rb4():
conc='console'
def rb5():
conc='windows'
def TB():
pass

class Freezer:
def __init__(self, master=None):
# Set background of toplevel window to match
# current style
style = ttk.Style()
theme = style.theme_use()
default = style.lookup(theme, 'background')
master.configure(background=default)

global Entry1
Entry1 = Entry (master)
Entry1.place(relx=0.12,rely=0.12,relheight=0.11,relwidth=0.69)
Entry1.configure(background="white")

self.Button1 = Button (master)
self.Button1.place(relx=0.79,rely=0.12,height=27,width=31)
self.Button1.configure()
self.Button1.configure(pady="0")
self.Button1.configure(text='''...''', command=files)

global rol
rol=''
self.Radiobutton1 = Radiobutton (master)
self.Radiobutton1.place(relx=0.12,rely=0.45,relheight=0.09
,relwidth=0.13)
self.Radiobutton1.configure(offrelief="groove")
self.Radiobutton1.configure(text='''1''', value=1, variable=rol, command=rb1)
self.Radiobutton1.select()

self.Radiobutton2 = Radiobutton (master)
self.Radiobutton2.place(relx=0.39,rely=0.45,relheight=0.09
,relwidth=0.13)
self.Radiobutton2.configure(offrelief="groove")
self.Radiobutton2.configure(text='''2''', value=2, variable=rol, command=rb2)

self.Radiobutton3 = Radiobutton (master)
self.Radiobutton3.place(relx=0.67,rely=0.45,relheight=0.09
,relwidth=0.13)
self.Radiobutton3.configure(offrelief="groove")
self.Radiobutton3.configure(text='''3''', value=3, variable=rol, command=rb3)

global con
con = ''
self.Radiobutton4 = Radiobutton (master)
self.Radiobutton4.place(relx=0.04,rely=0.66,relheight=0.13
,relwidth=0.41)
self.Radiobutton4.configure(indicatoron="0")
self.Radiobutton4.configure(text='''console''', value=1, variable=con, command=rb4)
self.Radiobutton4.select()

self.Radiobutton5 = Radiobutton (master)
self.Radiobutton5.place(relx=0.55,rely=0.66,relheight=0.13
,relwidth=0.41)
self.Radiobutton5.configure(indicatoron="0")
self.Radiobutton5.configure(text='''no console''', value=2, variable=con, command=rb5)

self.Message1 = Message (master)
self.Message1.place(relx=0.35,rely=0.29,relheight=0.16,relwidth=0.32)
self.Message1.configure(justify="center")
self.Message1.configure(text='''Optimize Level''')

self.TButton1 = ttk.Button (master)
self.TButton1.place(relx=0.35,rely=0.82,height=24,width=67)
self.TButton1.configure(takefocus="")
self.TButton1.configure(text='''Freeze!''')







if __name__ == '__main__':
vp_start_gui()



1172.

Solve : LabView programming?

Answer»

I am on a robotics TEAM and I want to know if anyone knows any Kinect CODES in LabView to possibly make it easier to use.Welcome to CH.
No, I don't. What are you USING?
Is this project built around a kit by National Instruments?
http://www.ni.com/robotics/
Yeah it is...Well more of FIRST Robotics... http://www.usfirst.org/

1173.

Solve : Delphi 5 programming?

Answer»

I use a button to view a PDF (using a 3RD party) with the ShellExecute command. I WANT code to insert text and date () (auto update onto each PDF DOCUMENT viewed so that if printed it APPEARS at the bottom of the document.
Text 'CONTROLLED COPY DATE()'

1174.

Solve : C++ question regarding #import and Microsoft logic?

Answer»

Hey people...

I have a C++ project that contains a stdafx.h file which tries to import a TLB (we'll call it MYFAVLibrary.tlb). When I go to compile the project I get an error on the line

Code: [Select]#import "MYFAVLibrary.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids

The error is

Code: [Select]error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder

I have tracked down which types were replaced with '__missing_type__' and they are IXMLDOMDocument, IXMLDOMNodeList, and IXMLDOMnode. These types are defined in the msxml.h header file derived from msxml3.dll. The header file is listed in the external DEPENDENCIES for the project and if I try to add one of those types in the code it is recognized so I am not sure why they are not being seen when #import tries to build the TLH file.

Microsoft states the following about error C4772:

Quote

Note that the compiler will not find type libraries in different directories if you use the /I (Additional INCLUDE Directories) compiler option to specify those directories. If you want the compiler to find type libraries in different directories, add those directories to the PATH environment variable.

My project does use the Additional Include Directories switch which could have something to do with this. However, msxml3.dll lives in C:\Windows\System32 which is part of the path so I am not sure why this wouldn't be working. Anybody have any experience with this situation?

Thanks!I couldn't say if it was the CAUSE of the problem, but using MSXML from C++ usually means using the MSXML SDK; this SDK includes header files for you. if I understand correctly you used the "import" functionality to create the header file you are using now. It might help to use the "actual" header files, though I don't know that for sure.

Hey BC_Programmer... Good to talk to you again. I guess saying the header file was derived from the dll is a poor choice of words on my part. Actually, the header file is part of the Microsoft Windows SDK which is indeed installed on my system. But the types are also found in the msxml dlls. Sorry about that.

The code

Code: [Select]#import "MYFAVLibrary.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids

will write out a MYFAVLibrary.tlh file that requires the types from MSXML. Somehow, I am missing where that reference needs to come from. The quoted text that I took from Microsofts website confuses me a little bit. So if you specify additional include directories, the compiler can't search them... That is how I read that and it seems counterproductive. But, the header file from the SDK is recognized in the project and the dll lives inside a directory found in the PATH environment variable. Hmm...I wonder if maybe MSXML might refer to other types, say from olelib? (I'm just guessing here, never really used COM & C/C++)Quote from: BC_Programmer on June 22, 2012, 09:32:40 AM
I wonder if maybe MSXML might refer to other types, say from olelib? (I'm just guessing here, never really used COM & C/C++)

I really don't know. I guess that would be a possibility but there are plenty of OLE headers being passed in as external dependencies as well, and from the same Windows SDK. The main problem is that I inherited this project so I don't FULLY understand all of it's intricacies. The people that gave it to me can build it just fine in a WinXP environment using the same compiler I am using (VS2010). I don't see how the OS (mine being Win7) would be what makes a DIFFERENCE. A different compiler, yea, maybe so. I have got to be missing something, either a library altogether or how something is referenced...

Thanks.well, the only thing I can figure is maybe the DLL (MSXML3.dll) differs enough from the XP version that it won't compile with the same code- a source level incompatibility preventing things from linking properly (I'm not sure but I think there is some sort of linking taking place in the guts of a #import).

Also, possibly dumb question: the XML include is before the #import for the external library?
1175.

Solve : Augh! Help, MS-DOS File???

Answer»

Aaughh!!!

I was RECENTLY talking to a friend on msn messenger when somethin started downloading, before i could STOP it had downloaded. It was, wat i believe to be an MS-DOS VIRUS which sends to everyone when i log on to msn.

I found the folder it was living in and also descovered 8 others!! i was happy and jus deleted them and emptied my recycle bin and THOUGHT nothing of it. Went back a bit later to find them back again.

Descovered if i delete them, a shortcut copy of them automatically comes back.

Anyone know how to completely get rid of them? Or what i need to BUY to do so??

Thanks http://Just get the latest Anti Virus software with Up-to-date virus deffinintions. Norton AntiVirus is the best one. Another thing is that you can also scan your PC online from Norton Antivirus web site:
http://www.symantec.com/

Hope this will solve our problem.
Take care of you and others and be happy.
DrWahab

1176.

Solve : C++ Int Array Sorter?

Answer»

I typed up a SMALL C++ program for sorting int arrays. I was wondering if there are any issues with the program. As always, all help is appreciated.
Code: [Select]#include <iostream>

void swap(int& a, int& b)
{
int temp;
temp = a;
a = b;
b = temp;
}


int main()
{
//Create an array of integers.
const int SIZE_OF_A = 10;
int a[SIZE_OF_A];
int i = 0;
int j;
//Generate an array of random integers.
for(int k = 0; k < SIZE_OF_A; k++)
{
a[k] = rand()%11;
}
//Sort the array values from smallest to largest
// if one index is greater than the next, swap the indexes go back to beginning of CHECK
while(i != (SIZE_OF_A - 1)){
j = i + 1;
if (a[i] > a[j]){
swap(a[i], a[j]);
i = 0;
} else if (a[i] <= a[j]){
i++;
}
}
//Print the sorted array to console.
for(int i = 0; i < SIZE_OF_A; i++)
{
STD::cout << a[i] << std::endl;
}
//Pause and wait for USER to exit.
std::cout << "Enter any alphanumeric value(s) and press enter to exit. " << std::endl;
char response;
std::cin >> response;
return 0;
}

1177.

Solve : C# Updating changes back to SQl database?

Answer»

Can someone please help me on this problem. I am trying to send the updated changes to the sql database when I remove a row. I use the delete method to delete the numbered row and then use the upadte command to update the changes. However, when I reload the PROGRAM all the rows are still showing again. Below is the current code I am using for forms 1 and 2. This has been giving me a headache for awhile now and any further help would be appreciated:

Code: [Select]
//form1

private void UpdateSavebtn_Click_1(object sender, System.EventArgs e)
{
Mcon.Open();
UpdateVal = 1;
if (UpdateVal == 0)
{
CurCol = dataGrid1.CurrentCell.ColumnNumber;
CurRow = dataGrid1.CurrentCell.RowNumber;
CellValue = dataGrid1[CurRow, CurCol].ToString();
MessageBox.Show(CellValue.ToString());


if (CellValue == "")
{

MessageBox.Show("No FIELDS can be Blank - update failed");
Movset1.RejectChanges();
ImageMain();
CurRow = -1;
CurCol = -1;

Mcon.Close();
return;

}
CellValue = dataGrid1[CurRow, CurCol].ToString();
CurRow = -1;
CurCol = -1;
}


MovAdapt.UpdateCommand = cb.GetUpdateCommand();
MovAdapt.Update(Movset1.Tables[0]);
Movset1.AcceptChanges();


MessageBox.Show("New MOVIE added");

Mcon.Close();
UpdateVal = 0;

dataGrid1.RowHeadersVisible = true;
}


Code: [Select]
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show(" Please enter a title to be DELETED ");
return;
}



DSMethod();
DV2 = new DataView(ds2.Tables[0]);
F1.dataGrid1.DataSource = Dv2;
Dv2.RowFilter = "Title ='" + textBox1.Text + "'";

if (Dv2.Count < 1)
{
MessageBox.Show("Movie does not exist in MovieBase, please try again");
return;
}
else
{

int rownum = (F1.dataGrid1.CurrentCell.RowNumber);
Dv2.Delete(rownum);

ds2.AcceptChanges();
//MovAdapt.UpdateCommand = cb.GetUpdateCommand();
//MovAdapt.Update(Movset1.Tables[0]);

this.Hide();

//Dv2.Table.Rows.Remove(Dv2.Table.Rows.current)

MessageBox.Show("Movie has been deleted");

}

Try updating the whole DataSet, as in

Code: [Select] MovAdapt.Update(Movset1);

1178.

Solve : vbscript shell.run help....?

Answer»

hi guys,

The code below is used to remotely install 0ffice 2007 viewer. It does work but it has some bugs and I'm hoping that you guys might be able to help me out.....


the 'shell.run' LINE (in red) doesn't wait for the batch file to finish before continuing the script. I've checked and re checked the run line and it all seems fine but it still won't wait until it's finished.

Any ideas???


'
'Script to remotely install Office 2007 viewer
'
'
'
'setting objects
Dim net, objFSO, shell

Set net = CreateObject("wscript.network")
Set objFSO = CreateObject("scripting.filesystemobject")
Set shell = CreateObject("wscript.shell")

'getting IP address
IP=InputBox("Enter the IP or computer name of remote machine:", "Install Office 2007 Viewer Script")

'Mapping drive to source folder
If (objFSO.DriveExists("X:") = False) Then
net.MapNetworkDrive "X:", "\\basdc01\it\my name\scripts"
End If

'mapping drive to remote machine
net.MapNetworkDrive "Z:", "\\" & IP & "\c$"

'creating folder for install exe on remote machine
If (objFSO.FolderExists("Z:\2007_viewer") = False) Then
objFSO.CreateFolder "Z:\2007_viewer"
End If

'copying exe to remote machine
objFSO.CopyFile "X:\2007_viewer\viewer.exe", "Z:\2007_viewer\viewer.exe"

'creating app variable to incudle IP
app = "C:\scripts\install_viewer.bat " & IP

'echoing for confrimation - commented out as not needed
'WScript.Echo app

'running batch to install (should wait for it to finish before going to next step)
shell.Run app, 1, True

'checking if FAIL file is present (indercating that install failed - echoing messages to screen to say such.
If (objFSO.FileExists("Z:\installfailed.txt") = True) Then
WScript.echo "Unable to install Viewer. Please check network connections and try again"
objFSO.DeleteFile "Z:\installfailed.txt"
Else
WScript.Echo ("Office 2007 Viewer Install on " & IP & " on " & Time & " " & Date)
End If

'starting batch file to send message to remote machine about completation of script
shell.Run "C:\scripts\NetSend07viewer.bat " & IP, true

'removing mapped drives
net.RemoveNetworkDrive "Z:"
net.RemoveNetworkDrive "X:"

'quit
wscript.quit
Quote

shell.Run app, 1, True

Quote
app = "C:\scripts\install_viewer.bat " & IP

It might be helpful to see the contents of install_viewer.bat. It could be the batch file started up a secondary process, terminated, and returned control to the VBScript.

Quote
shell.Run "C:\scripts\NetSend07viewer.bat " & IP, true

I believe you're missing a comma in this line.

Quote from: Sidewinder on June 06, 2008, 06:24:33 AM
[Quote
shell.Run "C:\scripts\NetSend07viewer.bat " & IP, true

I believe you're missing a comma in this line.

That one seems to be working fine ??!!??

install_viewer.bat;

Code: [Select]@echo off

start /wait /b e:\"my stuff"\pstools\psexec \\%1 c:\2007_viewer\viewer.exe /quiet


if %errorlevel% gtr 0 (goto fail)

exit


:fail

echo FAil >>\\%1\c$\installfailed.txt

exit
Seems like the start command cranks up psexec which in turn cranks up viewer.

Question 1: Who has control? After psexec cranks up viewer does psexec terminate immediately and return control to the start command? Or does psexec wait for viewer to terminate before terminating itself?

Question 2: Is the errorlevel returned from the start command or psexec? Highly unlikely it's from viewer.

Once the batch file terminates, return reverts to the VBScript and life GOES on as we know it.

Try inserting a pause after the start command, and use the task manager to see if viewer is still executing. I realize your logic is for a network, but you may have to debug on the local machine.



PS. Is any of this related to this post?cheers for the reply;

1 - psexec starts viewer and then waits for it to exit (by defult) before returning control.
2 - the error level comes from the remote program.

I've already put a pause in after the start line but to no effect.

psexec /? >>

PsExec executes a program on a remote system, where remotely executed console
applications execute interactively.

Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,...] cmd [arguments]
-a Separate processors on which the application can run with
commas where 1 is the lowest numbered CPU. For example,
to run the application on CPU 2 and CPU 4, enter:
"-a 2,4"
-c Copy the specified program to the remote system for
execution. If you omit this option the application
must be in the system path on the remote system.
-d Don't wait for process to terminate (non-interactive).
-e Does not load the specified account's profile.
-f Copy the specified program even if the file already
exists on the remote system.
-i Run the program so that it interacts with the desktop of the
specified session on the remote system. If no session is
specified the process runs in the console session.
-l Run process as limited user (strips the Administrators group
and allows only privileges assigned to the Users group).
On Windows Vista the process runs with Low Integrity.
-n Specifies timeout in seconds connecting to remote computers.
-p Specifies optional password for user name. If you omit this
you will be prompted to enter a hidden password.
-s Run the remote process in the System account.
-u Specifies optional user name for login to remote
computer.
-v Copy the specified file only if it has a higher version number
or is newer on than the one on the remote system.
-w Set the working directory of the process (relative to
remote computer).
-x Display the UI on the Winlogon secure desktop (local system
only).
-prioritySpecifies -low, -belownormal, -abovenormal, -high or
-realtime to run the process at a different priority. Use
-background to run at low memory and I/O priority on Vista.
computer Direct PsExec to run the application on the remote
computer or computers specified. If you omit the computer
name PsExec runs the application on the local system,
and if you specify a wildcard (\\*), PsExec runs the
command on all computers in the current domain.
@file PsExec will execute the command on each of the computers listed
in the file.
program Name of application to execute.
arguments Arguments to pass (note that file paths must be
absolute paths on the target system).

You can enclose applications that have spaces in their name with
quotation marks e.g. psexec \\marklap "c:\long name app.exe".
Input is only passed to the remote system when you press the enter
key, and typing Ctrl-C terminates the remote process.

If you omit a user name the process will run in the context of your
account on the remote system, but will not have access to network
resources (because it is IMPERSONATING). Specify a valid user name
in the Domain\User syntax if the remote process requires access
to network resources or to run in a different account. Note that
the password is transmitted in clear text to the remote system.

Error codes returned by PsExec are specific to the applications you
execute, not PsExec.

lol, No this has nothing to do with my other project. I supposed I could add it later, but for now I'm doing them as and when.

cheers again.sorted.

I changed the start psexec line in my batch file and removed the /b switch. (which starts psexec in the same window.)

anyway.

Cheers for your help, yet again sidewinder!!

legend!
1179.

Solve : List to byte array in C#?

Answer»

If I have the following CODE:

Code: [Select]List<object> objList = new List<object>();
objList.Add(object1);
objList.Add(object2);

and object2 is not can not be serialized, how can I get this into a byte array?

You can not use:

Code: [Select]BinaryFormatter formatter = new BinaryFormatter();
MemoryStream memStream = new MemoryStream();

formatter.Serialize(memStream, objList);

byte[] listBytes = memStream.ToArray();


because of object2 and:

Code: [Select]byte[] byteArray = (byte[])objList.ToArray();
will not get it either. Any other simple possibilities?

Thanks.Quote from: dbran on March 12, 2012, 12:32:58 PM

and object2 is not can not be serialized, how can I get this into a byte array?
You can't. There is nothing to put in a byte array. What do you expect to be written for the nonserializable object?

an Object that isn't serializable has no persistent representation by definition.OK. I kinda figured. What I am really trying to do is replace some old VB6 code that looks something like this:

Code: [Select]Dim propBag As PropertyBag
Set propBag = New PropertyBag

propBag.WriteProperty "MyObject1", object1
propBag.WriteProperty "MyObject2", object2

Dim byteArray() As Byte
byteArray = propBag.Contents

The problem with my previous code snippet falls with object2.
So can you think of a way to do something like this? What is "object2" in the VB6 code? Or, more precisely, what type of object is object2?

if that works with the VB6 code, than WHATEVER object2 is (in VB6) is Persistable/Serializable.object2 is a C++ class that represents a geographical object and is accessed through an interface. But since it was used in VB6 like it was, I didn't think there would be an issue with serializing it.

I just attempted a serializable class and passed the two objects in through its constructor and the results were the same. This doesn't seem like there should be much to it but I am stumped right now.

I appreciate your input. Keep it coming... Well, that helps...

That means the Object in question is a COM object (that's the only way a VB6 consumer could access a C++ object); which also answers the question of how it works. a COM Object implements persistence by implementing the IPersist,IPersistStream, and/or IPersistFile interfaces.

Visual Basic's PropertyBag is smart enough to see when the object you pass it implements one of those interfaces and handles it appropriately; that is, it goes, oh, hey, this object is persistable! And writes the bytes to it's bag.

HOWEVER, the .NET SerializationInfo class (the propertybag equivalent) is a managed class and has no understanding of COM; in a similar way to the propertybag, it looks at the object, but it doesn't understand IPersistStream, IPersistFile, ETC. It only understands ISerializable and the Serializable attribute.

I tried to create a test, but it bloated very quickly. I'm not 100% sure how you access the IPersistStream interface and there are about a dozen examples on the web, all implemented in different ways. I ended up with a C# project that had a definition for IPersist, IPersistStream, A wrapper around a COM stream, but no way to create a IStream (ideally, a memory stream...) so I got stuck.

Basically, it would boil down to this:

1.Determine if the object supports IPersistStream
2. if so, create an IStream, and call the objects Save() routine to write it to the stream.
3. retrieve the bytes from the IStream.

2. and 3. are a bit of a hairy bit because much like the IPersistStream there is varying information on it. I did find that IStream is present in System.Runtime.InteropServices.ComTypes, at least, but I have no idea how you could such a stream. It's possible to create a wrapper that exposes an existing IStream object, but what you really need is a way to create one, and I wasn't able to find a way to do that.


I can however, think of a cheap workaround. Instead of trying to implement all this in C# where COM stuff is foreign, you could create a small Wrapper in VB that exposes a method for converting a COM object ot a sequence of bytes by way of the method you illustrated. The only down-side is that you would be forced to compile to 32-bit, but if you are using an Object from a C++ COM DLL already, you are already restricted to 32-bit, so that shouldn't be an issue. Basically, it could be a simple ActiveX DLL that has a single class with a method like this:



Code: [Select]Public Function ComObjectToBytes(Object serializeme) As Byte()
Dim PropBag As PropertyBag
Set PropBag = new PropertyBag
PropBag.WriteProperty("Object",serializeme)
ComObjectToBytes = PropBag.Contents

End Function
Public Function ComObjectFromBytes(Byte readfrom()) As Object
Dim PropBag As PropertyBag
Set PropBag = New PropertyBag
PropBag.Contents = readfrom
Set ComObjectFromBytes = PropBag.ReadProperty("Object")
End Function

You can reference the compiled DLL in Visual Studio, which will create a Wrapper .NET Assembly for you. At that point, you can create the class defined above (whatever it may be called) and call the ComObjectToBytes() method to convert your object2 to a sequence of bytes, which you can then write to your stream. If you want to turn that array of bytes back again, you call the second method in the COM component.

[/code]

The COM Interop available with C# is pretty good, but it's also very finicky. Then again, that's COM for you, really Wow. Thanks a bunch for sitting down with that! I am going to look at it again in the morning with fresh eyeballs when I am back in my office. I follow everything your saying. I have done a lot of stuff dealing with COM and Interops but never had to deal with serialization before. I will let the forum know what comes from this tomorrow...

Thanks again!OK, so I will throw this out there real quick...

I have built the class and added it to my project. The interop gets built as expected. Here's the catch. The calling program is installed to the GAC. When I get to the class creation in the code, the application will fail saying that the file (the new interop for the VB6 code) can not be found. I have seen this with a couple of other interops in my project. When the interops are created, they are created as strong named and sharing the same key as the calling application. With the others, I simply added them to the GAC and they worked as expected.

With this one, however, the installation to the GAC says that it failed because it was expecting an assembly manifest. I need a quick fix for this one as well. Anyone have any ideas?
1180.

Solve : Access database/Producing a message when the weekday turns to Friday?

Answer»

I'm LOOKING for Code that will allow me to PROGRAM a command button whose function is to CLOSE the database to produce the MESSAGE "Happy FRIDAY and have a nice weekend" - only, of course, when the weekday becomes Friday.

Any help will be appreciated.Something like this may help:

Code: [Select]if weekday(now) = vbFriday then msgbox("Happy Friday and have a nice weekend")

Use the code in the button click event along with the code to close the database.



Thanks Sidewinder - your suggestion works perfectly!!!

1181.

Solve : Access database combo box issue?

Answer»

I have 2 forms in a database which I’ll call form A (BASED on table A) and form B (based on table B.) A field on form B is populated using a combo box ( a list of names) based on table A. If the name is missing in the combo box it needs to be added to table A but I don’t want to have the user exit form B, GO into form A, enter the item and reopen form B. I used a command button to bring up a pop-up form on form B where the user can enter the name to go into table A. The newly entered name won’t show up in the combo box unless form B is closed and then REOPENED.

How can this be made to work without having the user exit form B? What other WAYS are there to do this?

Thanks, in advance, for any assistance.Do you have VBA code behind these forms? You might be able use the AfterUpdate event for the combo box or add to the logic where the popup occurs and CLEAR the combo box and reload after the database update.

Good luck.
In Form A, in the COMBO box, go into VBA & in the ComboBox_GotFocus() put "ComboBox.Requery". Be sure to substitute the name of your combo box for "ComboBox".

1182.

Solve : Access Database?

Answer»

I have added a TEXT BOX on a form that performs a calculation. Is there code that would ALLOW me to SAVE the results in a table?

Any help would be appreciated.You will need a SQL INSERT statement or a SQL UPDATE statement.

Check out:

http://www.1keydata.com/sql/sqlinsert.html

http://www.1keydata.com/sql/sqlupdate.html

Hope this helps.

1183.

Solve : Access Database - required fields?

Answer»

I have 2 databases where I've set up certain fields to be required or not null. The fields are required, at the table level, based on a Validation Rule and Validation Text not by setting the property Required to Yes. In one database, this is WORKING perfectly. If a user doesn't fill out one of the "required" fields and tries to close the form using a "close form " command button, the user keeps getting the Validation Text message until they enter data in the field.

In the other database, the "this field is required message" only pops up if the user closes the form using the built-in X in the corner of the form. If the "close form" command button is used, the form just closes without popping up the validation text. It just seems to be IGNORING the validation rules and validation text messages that have been set up.

The database where this is working correctly was created a few years ago in Access 2000 and later converted to Access 2003. The database where the validation isn't working was created in Access 2003. That's the only difference between the 2 that I can think of.

Any SUGGESTIONS?

1184.

Solve : About NSIS?

Answer»

Does anyone KNOWS something about the NSIS (Nullsoft Scriptable Install System)?, specifically if someone have an explicit manual, I'll glad with it.

CheersDo you already have the product? You can download from here. It comes with help files (.chm) and online documentation.

Good luck. THANKS, I've been found it! It's excellentI had it a while back. Pretty good for making setups.Quote from: Sidewinder on July 24, 2008, 12:03:39 PM

Do you already have the product? You can download from here. It comes with help files (.chm) and online documentation.

Good luck.

Holy CRAP!! Sidewinder, You're STILL around!!! Do you remember me from like one or two years AGO?? Quote from: Mr. Google on July 28, 2008, 08:25:24 AM
Holy CRAP!! Sidewinder, You're still around!!! Do you remember me from like one or two years ago??

My single living brain cell keeps me from remembering what I had for breakfast, much less stuff from 1 or 2 years ago. Quote from: Sidewinder on July 29, 2008, 07:50:43 AM
Quote from: Mr. Google on July 28, 2008, 08:25:24 AM
Holy CRAP!! Sidewinder, You're still around!!! Do you remember me from like one or two years ago??

My single living brain cell keeps me from remembering what I had for breakfast, much less stuff from 1 or 2 years ago.

Haha, well I remember you. You were the most famous person on CHF pretty much back then. Now it seems some more geniuses have strolled into rewardedness-if that makes SENSE... Doesn't mean he isn't our friend anymore.

Quote
You were the most famous person on CHF pretty much back then.

I can't imagine that ever being the perception. Much like the White Rabbit, I prefer to keep a low profile, surfacing occasionally with a burst of unbridled brilliance and humor, before retreating back into the rabbit hole. HAHA, funny. Dudeoxide- I never said that, did I... I just wanted to post the picture of the car. Quote from: Carbon Dudeoxide on July 31, 2008, 10:04:47 AM
I just wanted to post the picture of the car.

Alright, sounds good...
1185.

Solve : C++ program for this formula?

Answer»

How do I WRITE a program to convert centigrade temperatures to Fahrenheit temperatures, using this formula: F=9 0ver 5 C + 32? pow....maybe? pow is still confusing me. HELP!It's just math. It doesn't matter much what the programming language is, it is just math.
1. Create some interface to gather the centigrade temperature from the end user.
2. Do the math.
3. Provide some feedback to the user with the result.

Below is a Visual Basic Script that will do what you ask in 5 lines. It is not much different in Java Script, Visual Basic, C++, C#, VBA, etc., etc., etc.

dim c
dim f
c = InputBox("Please enter centigrade temperature")
f = (9 / 5) * c + 32
msgbox f

C++ is a very difficult language to get your head round for the first time. I'd advise you either learn C (which is similar, but if you've programmed before it should make sense) or better yet use my favourite language, Python - www.python.orgLooks awfully like homework!!!Thanks gussery! Needless to say, I also forgot the floating-point. Had to use 9.0.
Yes....Dusty......it's homework. ENCARTA directed me to this site for help. As a C++ student, with lousy math skills, I'm trying to educate myself on these mathematical assignments. Sorry to have bothered you with my needs.
Thanks for the suggestion corrosive; however, the college only teaches C++ at this time. Bummer.......Okay - mebbe my comment was kinda unnecessary.. but the usual way to get help on programming is to submit what you've written and ask for assistance

If you want to do some work at home on C/C++ you need:

a. Access to a tutorial. Here's one and OK its C but it will help

http://computer.howstuffworks.com/c.htm


b. Access to a compiler to allow you to test-run what you've written - see here http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/index.html#Top


c. Access to a specialised forum where help is always willingly given - but note you will have to provide what code has already been written by you... The link below has tutorials & forum available

http://www.programmersheaven.com/zone3/index.htm

Good luck - C/C++ is fun (believe it or not!!)

Since you want floating point, you'd probably want:

f = (9.0 / 5.0) * c + 32

A plain 9 or 5 is interpreted as an integer, and the result of that division would be 1, so I SUSPECT the results would not be as intended.


1186.

Solve : Can I make VoIP in Java...??

Answer»

Hello how are all of you? I am learning Java language. I want to make a VoIP (VOICE Over Internet Protocole) application. So is it possible in Java?

Seondly, if also use VB then can I use Java langnage code in VB also?

Third ANYONE who KNOWS any Operational Documents on how to make VoIP, AVAILABLE on web sites?

I shall be very thankfull to you.
Take care of you and others and be happy.
DrWahabDr Wahab,

Don't know about the VoIP specs.

But you cannot use JAVA inside a VB application, you can only use VB. They are seperate languages.

You can use VB Script and Java Script inside the same web PAGE, but I suspect this is not what you are after.

Gary

1187.

Solve : make VB.net find operating language?

Answer»

I am USING vb.net to write a program and I NEED it KNOW if I'm in 1033, 1046, or 2052 (that's ENGLISH, portuguese and CHINESE). Any idea how this could be accomplished?

1188.

Solve : WSH Scripting?

Answer»

What is the best book to learn WSH scripting? I have done alot of UNIX shell scripting, but WANT to learn WSH scripting. I LIKE the format of the SAMS Teach Yourself books. The WSH scripting book on that topic is dated 1999, so I don't know if it would have any info on Win 2000 or AD.

Any help would be greatly appreciated!!!

Thanks!!!Everything you need is already on your WINDOWS MACHINE. You can download the documentation for WSH from:

http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

The file will install a compiled help file that has great examples of practically anything you need to do. (Cut & Paste is a wonderful thing )

Good LUCK.

1189.

Solve : vxd?

Answer»

I am getting the MESSAGE cannot find device filed that may be NEEDED to run windows or a windows application.
The windows registry or system.ini file refers to this device file but the device file no longer exist.
Cannot LOAC enable 2VXD
Cannot loand enable 4VXD
I am a Grandmother trying to LEARN how to use these new gadgets. Please email me.
I really appreciate any help you can GIVE me.
Thanks

1190.

Solve : Trying to install JAVA program?

Answer»

Hello. I am taking a computer science course at my high school and i needed help installing the program on my computer at HOME. i downloaded java and jcreator, but now i need to copy 3 files into 2 CERTAIN directories. I am not sure how to do this. Can SOMEONE please tell me how to deal with directories??thanks.A directory is the proper term for a folder. And if you don't know what a folder is then GOD help you in your course.

1191.

Solve : VB Sendkeys problem?

Answer»

Hello guys.
Today, while PLAYING with VS2010, I discovered a strange ISSUE: the sendkeys.send code isn't sending "(" or ")", it REPLACES them with spaces.
I tried PUTTING the string in a string variable but the result was the same.
How can I send "(" ")" like the NORMAL text?
Thank you, guys:Dhttp://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx

Quote from: MSDN

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use "{+}". To specify brace characters, use "{{}" and "{}}". Square Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces.
1192.

Solve : Error using DELOLDER Script to delete old files?

Answer»

i don't know if anyone here has ever used the DELOLDER script found on http://www.ss64.com/ntsyntax/, but basically it deletes all files older than a certain number of days. for example:

C:\> DELOLDER 90 "C:\TEMP\*"

will delete anything in C:\TEMP older than 90 days old. this works on every SERVER we have except for one and i can't figure out why.

i've NARROWED down the problem to one line. here's what happens when i set the echo on for that line. my file variable seems to get lost.

---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---

SERVER_A (BAD)

C:\ORAMAINT>delolder 120 "C:\test\*"

FOR /f "tokens=*" %G IN ('XCOPY "c:\test\*" /D:03-08-2006 /L | FIND "\"') DO IF """=="%G" (GOTO :eof)

---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---

SERVER_B (GOOD)

C:\ORAMAINT>delolder 120 "C:\test\*"

FOR /f "tokens=*" %G IN ('XCOPY "C:\test\*" /D:03-08-2006 /L | FIND "\"') DO IF "C:\test\poop.txt"=="%G" (GOTO :eof)

---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---*---

both servers are windows 2003. there's got to be some SETTING or something that i'm missing, but i think i'm staring at it too hard.

the scripts are in a zip file here:

http://www.ss64.com/ntsyntax/delolder.zipThe technique for aging files is actually quite clever. Unfortunately the truckload of supporting batch code is enough to choke a horse.

Best I could COME up with is that this is the line in question:

FOR /f "tokens=*" %%G IN ('XCOPY %v_source% /D:%v_mm_str%-%v_dd_str%-%v_yy_int% /L ^| FIND "\"') DO IF %1=="%%G" (GOTO :eof)

Since there is no error in the code, check out the data. Run the XCOPY with the /d and /l switches at the command prompt and check the results. Turn ECHO ON so you can see what's passed to the subprograms and what data is returned.

Date calcs in batch seem to be this weeks hot topic. Given a choice, use one of the Windows scripting languages. They all have functions which are designed for just this purpose. Batch code is a command language not a programming language.

8-)the xcopy seems to work fine, but when i set ECHO on in the last line...


:s_match_older
echo FOR /f "tokens=*" %%G IN ('XCOPY %v_source% /D:%v_mm_str%-%v_dd_str%-%v_yy_int% /L ^| FIND "\"') DO IF %1=="%%G" (GOTO :eof)
DEL %1

it throws a double quote in where there should be a file name. not only should there be a file name there instead, but the double quote screws up the whole line because it's looking for an "ending" double-quote to pair up with the extra one.

C:\ORAMAINT>DELOLDER 20 "C:\test\*.*"
FOR /f "tokens=*" %G IN ('XCOPY "C:\test\*.*" /D:06-20-2006 /L | FIND "\"') DO IF """=="%G" (GOTO :eof)

so:
• it's not the code (because the SAME code works on other servers).
• it's not the xcopy.

there's got to be some setting that's different on this server than the others, but i hav eno idea what it could be.

Actually I meant to turn ECHO ON in the first line of DELOLDER.CMD. Using ECHO on the FOR line turns the statement into a ECHO instruction with FOR as a literal.

The only settings I'm aware of for the cmd processor are enableextensions and enabledelayedexpansion, both of which can be set within the batch file. Since the author saw no need to turn them on, it's doubtful they're needed.

Without knowing the data you're working with it's difficult to debug. Adding to the difficulty are the calls to subprograms (DateMath and GetDate) where data gets passed around. With ECHO ON (you may also have to turn on ECHO in the subprograms), you should be able to see how each statement is resolved. Work backwards to determine where the variables got their values from.

Considering that this works on other machines, try concentrating on unexpected data on this one machine.

Good luck. 8-)





1193.

Solve : VBA programming with FTP sessions?

Answer» HELLO all,

There is a problem I can't get my head around. I have this code for example:Code: [Select] Dim vPath As String
Dim vFTPServ As String
Dim fNum As Long

vPath = "C:"
vFTPServ = "www.domain.com"
fNum = FreeFile()

Open vPath & "\FtpComm.txt" For Output As #fNum
Print #1, "USER myUN" ' your login
Print #1, "pass" ' your password
Print #1, "dir " & Me.namefield & " c:\test.txt"
Print #1, "close"
Print #1, "quit"
Close

Shell "ftp -n -i -g -s:" & vPath & "\FtpComm.txt " & vFTPServ, vbHide
i am doing this everytime I want to view the contents of the TEST text file. my question is, is there a way that I can leave the FTP session open, and keep printing lines in the FTPCOMM file and keep EXECUTING DOS commands one at a time this way instead of opening and closing the connection each time?

I am getting a huge delay in updates when I run this procedure seperately evertime I want to update my interface with the DOS output, so if I can leave the session open I think I can completely eliminate the time I have to wait! I am using VBA with OFFICE 2003 and windows vista. thanks all!do you absolutely have to do this with VBA? you are using the wrong choice of tools to do FTP.i do NEED to do it in VBA, yes. I searched for the INET active X, but apparently you have to pay to get it downloaded. is that true?Quote from: ajetrumpet on November 02, 2009, 06:53:21 PM
i do need to do it in VBA, yes. I searched for the INET active X, but apparently you have to pay to get it downloaded. is that true?
I am not sure because I don't have to pay to do programming. If you are being forced to pay to program, then you are being ripped off. A lot of stuff to do programming are free. Perl/Python etc comes with excellent FTP libraries that makes your file transfer job easier. If you can find a library that you can use with VBA that is free, go ahead and use it.
1194.

Solve : (VBA) myCell.Value= 2, myCell.Text=xlLandscape?

Answer»

How do I ACCOMPLISH this? As in setting myCell to set the integer to 2 for any references, but to the end-user, it should just show "xlLandscape"

Thanks in advNot sure that myCell would have a text property. You COULD reference another cell to get a value.

A1 = 2
A2 could then have a formula: =if(A1=2,"xlLandscape")

You'll create a circular reference if you attempt to use the cell being REFERENCED in it's own formula.

8-)Thanks Resolved!

1195.

Solve : (VB 6.0) Auto-execute via Combo Box Selection?

Answer»

Can anyone help me... I NEED to ensure whenever I select a Combo Box Option, it will run the respective command.

This is for Visual Studio 6.0. Thanks in advance.Try using the SHELL function:

Code: [Select]dim rc as INTEGER
rc = shell("notepad.exe")

Note: if it's a batch command, you need to include the command PROCESSOR in the shell function:

Code: [Select]dim rc as integer
rc = shell("cmd /c copy fileA fileB")

Happy programming. 8-)Thank you! But how do i integrate it into my code... i know Combo Box options can be identified by integer as well.

Quote

Private Sub Combo3_Change()

xlDoc = cbx_DailyRep.Text

Set xlApp = New Excel.Application

Set xlBook = xlApp.Workbooks.OPEN("d:\oss\" & xlDoc & ".xls")

xlApp.Visible = True

Set xlBook = Nothing
Set xlApp = Nothing

End Sub

In here, how do i encode it so that a specific excel document will open when i choose the option from the combo box? Is it possible or is there something i'm missing out on?Quote
I need to ensure whenever I select a Combo Box Option, it will run the respective command

Misread read your question to imply an external command. What was I thinking :-?

This should work:

Code: [Select]Private Sub Combo3_Change()
xlDoc = cbx_DailyRep.Text
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open("d:\oss\" & [highlight]combo3.seltext[/highlight] & ".xls")
xlApp.Visible = True
Set xlBook = Nothing
Set xlApp = Nothing
End Sub

Naturally all the choices in the list need to be Excel workbooks.

8-)sry for the tardy reply, but thanks for your help
1196.

Solve : running a batch file?

Answer»

I do have a question on a batch file if you do not mind.

I am creating this batch file below:

1. Create a batch file, Micr.bat, which will accomplish the following:
a. Update a log file on your C:\root folder. Call this log file cleanup.log. Each time your batch file is run it should over-write this log file which CONTAINS the User Name (utilizing the %USERPROFILE% environmental variable),
b. Merge this file onto the back-end of the file cleanup.hst which will also be stored in the C:\ root folder.
c. List the directory contents of this TEMP folder.
d. Ask for the user’s permission to proceed with the deletion of all these files.
E. If the user responds positively, then delete all the files from the user’s TEMP file.
f. Remember to copy the textbook’s REPLY.COM to the folder containing your batch file.
g. Place this batch file in the C:\BatchFiles folder.


This is what I have come up with:

@echo off
rem (BAT)
rem (EVA)
rem (dec 2 2004)

FOR %%a IN (%USERS%) DO IF "%1"=="%%a" GOTO OKAY
:NO
ECHO YOU, %1, are NOT allowed in the system.
GOTO END
KAY
ECHO Welcome %1 to the system.
:END
c:\setup.exe /L2 c:\Logfiles\cleanup.log
c:\ move cleanup.log a:\cleanup.hst
c:\ dir /TEMP
REM This Batch program DELETES all files in the TEMP folder in the current folder.
REM I will give the user to react and abort this process.
@ECHO OFF
ECHO WARNING: Going to delete all files in the temp folder
ECHO Press CTRL+C to abort or simply press a key to continue.
PAUSE
DEL TEMP *.*
c:\ copy REPLY.com C:\EVA
IF %1==Eva GOTO EVA
Echo Is anyone there?
GOTO FINISH
:end

Can you please tell me if i am on the correct track?I can't give you much advice on batch files (I rarely use them anymore) but your logic seems to be correct, although I believe you mis-spelled the word "OKAY" in line 10.Thank you.

I was really not to sure where "forum topic" to send my issue. Well I guess I am were I was before I made the post.

I APOLOGIZE for the repeated posts.

1197.

Solve : need help when compiling?

Answer»

Im just beginning to learn how to USE C. i got this script from this site: http://randimus.freeservers.com/ctut1.html and after i compile this:
#include
main ( )
{
PRINTF ("Hi Cruel World");
return (0);
}

it keep SAYING that line2 warning no newline at end of file
did i type anything wrong?
btw im using dev-C++4.9.9.1Does the guide mention you have to use that compiler? Some guides are focused on different compilers..

There are more patient and serious guides out there..I THINK you may also need to include the STDLIB library as well. Add "#include " just below or just above the other one. Or maybe try replacing "printf" with "puts"

1198.

Solve : RightCLick and it's Invisible??

Answer»

Hi All..
I'm new as you can see.. I don't even know if I'm in the right area. But I will post and see if I'm even in the general area.
ok.. here it goes..

One of my kids was on the computer. When I went to use it.. I right click and scroll either up and down on the dropboxes.. only my dropboxes are "invisible" until I scroll over them. I don't know how this setting got "on" but I do so HATE it..
Can someone help me?
I would very MUCH be greatful for it if you did.
Thank you. DQ :-/
Have you scanned for spyware and VIRUSES?

Ask your children what they have done. Use force if necessary.Hi Raptor,
ACTUALLY my 6 year old has no idea what he did. And he really didn't mean to do it as he was clicking with the mouse.

This did happen once before about a month after I got my computer. I was able to find the issue and fix it but all be darned if I can remember how!! :-/

I know it's fixable, I just can't remember....
Thanks anyways!Maybe it's not invisible but instead a part of the spirit realm.. as a psychic you should contact it and ask it to come back or something.Joleen has a good point there. It may be HAUNTED by undeadware.

Have you tried sprinkling holy water on your monitor? The flashing effect means that the spirits have now been driven out.

1199.

Solve : Help with conditional statements on C programming?

Answer»

I am a BEGINNER on C programming and an error message (underlined) that I have typed on the below program is not working....can anyone help please???
I am solving a quadratic equation the -b +/- root(b*b-4ac)/2a. If b*b is less than 4ac then there are no real roots so I need an error message. So i have made the bracket (f) and said that if it is less than zero the error message should come up....but its not! Any help would be grateful!!!



#include
#include
int MAIN() {
FLOAT a, b ,c, d, e, f, root, x1,x2, b2;
printf("Enter a: ");
scanf("%f",&a);
printf("Enter b: ");
scanf("%f",&b);
printf("Enter c: ");
scanf("%f",&c);
b2 = pow(b,2);
d = (4*a*c);
f = (b2-d);

if(f<0) {
printf("Error - no real roots!\n"); /*Error messaging*/
return 0;
}
root = sqrt(f);
e = root/(2*a);
x1 = ((-b)+e);
x2 = ((-b)-e);
printf("Solution=%f\n",x1);
printf("Solution=%f\n",x2);
return 0;
}
wel i understand your problem , the small thing that is missing in your code is
" #INCLUDE header FILE because of which you are unable to calculate..
1>. " sqrt " function.

2>. " Pow " function so are getting unexpected RESULTS..

i am pasting the correct code , just check it out

#include
#include
#include
int main()
{
float a,b,c,d,e,f,root,x1,x2,b2;
printf("enter a: ");
scanf("%f",&a);
printf("enter b :");
scanf("%f",&b);
printf("enter c: ");
scanf(" %f",&c);
b2=b*b;
d=(4*a*c);
f=(b2-d);
printf("the value of F is = %f",f);
if(f<0)
{
printf(" error - no real root") ;
return 0;
}

root = sqrt(f);
e=root/(2*a);
x1=((-b)+e);
x2=((-b)-e);
printf("solution =%f\n",x1);
printf("solution =%f\n",x2);
return 0;

}I know nothing about C. That said, I used the Tiny C Compiler and your code works just dandy.

Results:
Quote

C:\Temp\tcc>test
Enter a: 12
Enter b: 1
Enter c: 3
Error - no real roots!

Quote
C:\Temp\tcc>test
Enter a: 1
Enter b: 5
Enter c: 2
Solution=-2.938447
Solution=-7.061553

Seems fine to me.

PS. You did too include the math header file.
1200.

Solve : Programmers?

Answer»

Quote from: Carbon Dudeoxide on August 20, 2008, 07:22:21 AM

What's with all these questions?

Quote
Is AI definable? If so what is it?
What do you mean here?

Also, my ICT Teacher was talking about AI's before school let out and he said that it will start to become a possibility when our processor speeds start reaching as high as 10GHz.

Well the IBM Roadrunner, is runnin at 1PetaFlop. so it could probably have AI, like in T3. Terminator: "SkyNet is now self-aware, it will launch a nuclear attack to destroy its enemy in 1 hour and 46 minutes."

But if you want to see some simple AI, because proccessor speed is not really were AI will start, AI depends upon how the program is wrote, by what kind of althithograms its uses(srry for my spelling), my Lego Mindstorms robot, learns how to sort bricks through TRIAL and ERROR, and its proccessor speed is about 8MHz so i has a simple AI but without the speed like the Roadrunner.

You can see the video of my Learning Brick Sorter in action at youtube, here: http://www.youtube.com/watch?v=6iflWlWs3ss
Back then we KNEW we were on the cutting edge of technology. One of the engineers that i worked with used to say: When we walk through that back door ( no one ever used the front door...MAYBE that's a metaphor for other things? ) we walk into a computer; the whole building is a computer.
After it was "cut over": turned over the Bell Telephone the building/computer was unmanned. Every once in awhile humans had to go there to change a light bulb at the back door, or to dust a few things.
Drove by the building a few months ago and it looks exactly the same as it did when i worked there except the parking lot is gone.I'm not a programmer in any sense of the word. I am also an ME that has found that purely mechanical systems are amazing in their complexity and functionality and in their ability to be REPLACED by a few hundred lines of code. Basically I try to program in order to find ways to automate the "15 year old" tasks that I am faced with. (15 year old tasks are things that a 15 year old could do with limited training that I find myself doing now and again rather than doing what I would call real work.) By combining a mechanical system with an appropriate electrical systems and a program it is amazing what can be accomplished.

Unfortunatelly this means that eventually my job will be replaced by machines, but until then it keeps the lights on. well no machine can replace any job that involves people, such as a phycologist (srry for my spelling)it's not your spelling that's the problem it's your phrasing... Quote from: macdad- on August 25, 2008, 04:08:16 PM
well no machine can replace any job that involves people

what like manual labour?? or welding bits of car together?? I understand what you mean but your sentence is rather confusing!

FBi mean interacting with them, understanding them and all.