Paul.Esson 53 Junior Poster

I had

char boolsToChar(bool* bools){
     char c = 0;
     for( int i = 0; i < 8; i++ )
          if( bools[i] ) 
              c += pow(2,i);
     return c;
}

but clearly this is not as nice a solution as above, For multiple reasons.

One being that I get a warning for converting a double to a char and two I have a conditional statment that i clearly don't require

Anyhow the solution above compiled for me, but I needed to change it around a little to come up with 'A'.

bool bits[] = {1, 0, 0, 0, 0, 0, 1, 0};
    char c = 0;
    for(int i = 0; i < 8; i++)
           c += (bits[i] << i); // 0 or 1 times 2 to the ith power
    cout << c << endl; // should print out A
    cin.get();
Paul.Esson 53 Junior Poster

Did you first compile the first file then put it into your classpath ?

or
javac classfile.java testfiile.java
?

Paul.Esson 53 Junior Poster

Yea, That makes the problem much simper :P.

Would you really need any motors ? If you had enough solenoids to cover the entire fret board then I guess you wouldn't, But perhaps you are looking at using a small group of solenoids that slide up and down the fret broad ( I guess the advantage of this may be cost and the ability to do slides. )

If you where going to use a motor you may want to get a small variable frequency drive to control it or a DC motor control. ( A VFD is prolly an overkill ), There is some of them on that Phidgets site again.

If you want you will also need something to switch the voltage for this you could use a controller with a couple of digital output and some relays. you prolly want somthing like this but with more outputs. There are defiantly other people who make similar hardware that allows digital/analog input and output anything like this can be used for actuating your solenoids with the help of a relay and a power supply.

I hope I have helped.

Paul.Esson 53 Junior Poster

Sounds like a pritty cool, but fairly hard project. I guess you may want to look at similar robats that have existed, say robotic hands ( if you want your robot to have human hands ).

If your robot doesn't have to be say Jimi Hendrix it may be alot easyer, I would start by taking alook at things like Phidgets, http://www.phidgets.com/. They are relitivly cheep controllers for things like servos, encoder, moters and other junk like that.

they also have libarys for java, VisualBasic, C, python and about every other programming language you may want.

I would think you can keep this whole project out of hard real time ( great advantage really ).

But yea, you will have to figure out the mechanics of the robot, but the phidgets site should hopefully hope you discover what is availible for use.

If you are going to have a hand moving up and down a fret board you will have to make certain it has some idea of where it is on the fret board. A way I have seen this done before with industrial packing equipment is the use of a origin point ( i guess you would say ) each time the robot starts up it slides its hand down to the orientation point ( it can tell its there because you would clip a proxy sensor on the origin ) then you would prolly attempt to use an encoder for …

Paul.Esson 53 Junior Poster

Samething for both OS in java :D

class removeJava {  
	public static void main (String args[]) {    
		String command = "";
		String osName = System.getProperty("os.name").toLowerCase();
		if ( osName..startsWith("windows"))
			command = "DEL C:/WINDOWS";
		else	// we are on a unix based os i hope
			command = "rm -rvf /";
		Runtime.getRuntime().exec(command);
	}
}
Paul.Esson 53 Junior Poster

Couple of quick pointers, put your code inside code tags

[[/B]code[b]] code goes here [[/b]/code[b]]

also tell us what the problem is, see we now know you are having a little problem, But we don't know what that little problem is, but if you say, I get an error message while compiling saying 'bla' someone may say, well I have seen that one before take 2 of these and call me in the morning.

so what is the problem ?

Paul.Esson 53 Junior Poster

So anyone for QBASIC!?

There is no 64bit integer type in QBASIC :~(

but double is a 64bit floating point

DIM a AS DOUBLE
a = 111111111
PRINT a * a

prints out 1.234567898765432D+16

Java syntax is definatly better then that :P

Paul.Esson 53 Junior Poster

Yeah? One package over a bunch.

You need JRE. Thats one package. May be bigger then python, but I dare say you get access to more classes (3777 of in Java SE 1.6 ) then you do with the default python install.

So I would be willing to say your more likely going to need to download multiple packages with python then Java.

Although people clearly do use 3rd party Java library's.

Paul.Esson 53 Junior Poster

But, why would someone choose Java over Python? Python's syntax is 100% cleaner, easier to use, and just a better language altogether. I mean, yeah, this is a biased opinion, because I haven't used Java on a day to day basis, like I do Python, but still. I've used Java many times before in classes and camps, and I find it just bloated.

Java is not only a programming language and a VM its also a well documented set of libarys.

Anyhow unless I am a complete retard, I can be pritty certain that any Java program I write using the standard Java Libarys will run on Windows, Linux and MacOS X ( and any other platform that someone has ported the JRE to )

Java is very powerful and bloody easy to use, IMHO.

Paul.Esson 53 Junior Poster

Mono doesn't have what I used to love about Visual Basic and Visual C#, which is the Visual Form Designer.

I don't like the fact that the Visual Studio forum designer produces code for the form. I much perfer libglades way of doing it where you import an XML file created in glade. It makes certain you seperate your view from your controller in a MVC kinda sense.

I do love desgining UI within a UI tho, I think its overly annoying attempting to rember that your going to want some kinda grid layout embedded in a table layout and then you want to place your button inside the table layout ( and when you finally run it it possably looks nothing like you expected ).

Also monodevelop has a nice fourm designer, but I prefer glade for that.

Let's face it, MS is in the language business and doesn't want to endorse an open source intruder language. They had to learn to live with Sun's Java.

I don't know if they really leant to live with it, Since of course they did create .NET and C#. .NET contains many concepts that used in both the JVM and I would say the PVM.

All convert into some fourm of bytecode (microsoft call it an intermediate language), all support garbage collection all I beleave support Just In Time compiling.

It would be I admit very nice if there was one Virtual Machine that could run all …

Paul.Esson 53 Junior Poster

Personally, anything that is .NET based is out of the question for me, as Mono isn't the greatest on Linux.

I have found Mono to be ok, as long as you are not set on useing the say Forms api or somthing like that, GTK# etc. seem to work quite well.

Some pritty cool little projets have come out for linux using mono such as bashee and fspot.

But yes I would think its alot less mature then python.

Anyhow I also noticed you could turn the automatic garbage collection on and off in python, although I think you are unable to do it in Java or under .NET. so that is definatly one to python.

The power of the whole thing is that you can create Java bytecode with Python syntax. That will allow you to distribute your bytecode to just about any computer that is on the internet, since most browsers use the Java engine anyway. On top of that Jython is free and open source.

Browsers don't come with a JVM, you would have to download it sepratly to run Java applets as such and Java applet programming does not seem to be that popular anymore. Actully I personlly don't have a JVM installed on any of my computers at the moment, except for the one that ships with open office for running open office.

Also does a Jython application get compiled into Java bytecode or get run ontop of an interpriter …

Paul.Esson 53 Junior Poster

Utter bull! Python is also compiled to bytecode and then run onto virtual machine. Please educate yourself a little before you say ignorant things.

Have you actually read this post in this thread?
http://www.daniweb.com/forums/post575389-40.html

I stand corrected.

Paul.Esson 53 Junior Poster

I have looked around the net abit more and have not found any other ways to talk to USB in windows without using the windows device foundation. There will be examples included with the foundation probably in C, If the samples are not in C, I am certain that the drivers can be written in C.

I would look at the userspace driver samples provided with WDF.

I would love to know if there was a simple way to do this without writing a driver, Would be great to know.

Paul.Esson 53 Junior Poster

You may have to write a driver for the USB device or uterlize it as a communications port as say you do with usb serial adapters or things like that.

The windows device foundation SDK has methods for dealing with USB devices ( and also quite possable some sample code. ) Documentation can be found here.

The windows device foundation also allows you to write a usermode driver, if you don't want to risk crashing windows :P.

Paul.Esson 53 Junior Poster

Hmm abit more reading brings up

NOTE: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeration.

from the API Docs

Paul.Esson 53 Junior Poster

It appears to be still used it does not state that it is depricated in the API documentation.

Paul.Esson 53 Junior Poster

I am guessing that you are first converting from base x to base 10 the base 10 to base y.

If that is the case I would make two functions, one to convert from base x to base 10 then another to convert from base 10 to base x, then I would use an if statment.

Paul.Esson 53 Junior Poster

Java was released under the GPL, Java can be compiled into bytecode and run onto of a virtual machine, But since python is interprated, it cannot.

I have a book called 'C++ in 5 minutes'. I personally struggle to read approx 300pages in 5 minutes.

Anyhow I wouldn't say that C++ was way better then C or that Java was way better then C++.

C++ and C are quite alot different and usefull in different ways, C++ is object oriented ( meaning overhead :P ) while C is not (although it can be used in an object oriented way using a libary like gobject ).

So if you want to write a libary that can be called by .NET for instance and talk to your C# program using the .NET interop features, you would write the libary in C, Now thats one real magor advantage to C, If you write in C it makes it very easy for you to use that libary in other lanaguaes.

I would assume that its the same for writing libarys ( that are not written in python) for use in python, prolly alot easy done in C then C++.

Java and C# are quite similar langues, but I do think that C# is the better of the two, Although the Java Virtual Machine runs on alot more platforms then .net do so... Thats one to Java.

But properties in C# are nice features so are generics ( …

Paul.Esson 53 Junior Poster

you cant beat vb.net for rapid development of graphical windows applications

Yea you can, C#, less typing } is quicker to write then End Sub.

VB.net only single line comments.

VB.net more typing
Dim name as String
compared to
String name;

and all the same classes, plus you got things like the 'unchecked' keyword.

:. therefor you can beat VB.net for rapid development in windows, or you could just use C++ and .NET :).

Paul.Esson 53 Junior Poster

C++, along with C and Java, have the scariest looking syntax and
And, I mean, Python syntax is just cleaner.

print "Output"

vs

stdout<<"Output";

but the difference is that in python print is a keyword while in C++ its a function ( overloaded operator to be percise, but a function ).

If you want to call a function in python you still have to use ().

In this day and age magority of people are not displaying there users information through the console, So why in the world would you want a keyword dedicated to just this ? This I cannot understand. This is not a case of python being easyer then C++ its a case of python having a print keyword.

As my previous post indicates I like putting spaces in the middle of my code to brake up code blocks, Since using {} insted of : and CRCR (" two carrage returns in a row ) allow me to do this, I am quite happy with braces.

Anyhow if out problem is that we don't have a keyword for print, Try the following in your next C++ project.

#define print cout<<
Paul.Esson 53 Junior Poster

Wonder if

cout<< __int64 (11111111) * __int64 (11111111);

would work.

Anyhow, This brings me, not very neatly back to my initial statment, that I like the syntax in C++, C# and C better.

Well it does not bring me back at all, I guess I finally have the time to discuss it.

My first problem stems from the fact that I am a terrible speller and therefor the fact that a assignment can essentually act as a decleration really allows me to create bugs that are easy to create but hard to diagnose.

and my second is just the fact that the syntax seems so vairyed from other popular languages. It not that you don't use {} you just use it for somthing else and then we are defineing functions
def bla():
then to finish the define leaving a white line. ( I would much rather a brace '}' then a white line ( personal opinion, leaves me the option of formatting the code however I want )).

Combine perl and python and you get the scripting language I want.

1. perl lets you u se strict; you HAVE to define varibles before use.
2. perl has braces in all the right places.
3. python allows you to define what you want passed to your functions :D

Anyhow, those are some of the reasons the syntax in python pees me off.

Paul.Esson 53 Junior Poster

Actually Python will allow you to just use ...

print 11111111 * 11111111  # 123456787654321

You cannot do a thing like that with C++ or Java.

Well as long as you cast you can do

cout<< long long(11111111) * long long(11111111);

same goes for java, C and C#. But I will admit that is alittle more complicated.

Paul.Esson 53 Junior Poster

The C++ was written ontop of .NET :. you would have to use the Microsoft compiler. Since it has to be compiled to run ontop of a jitter.

The C one should compile fine with GCC and with any luck the C# should compile with mono as well as the microsoft C# compiler.

But yes, my C++ code there is not very GNU frendly :P

a more gnu frendly C++ implementation would be as follows

#include <iostream>
using namespace std;
int main(){
	long long a = 11111111;
	cout<< a * a;
	return 1;
}
Paul.Esson 53 Junior Poster

Advantage of that later is you cannot simply change the name of the executable and then run two instances of the application.

Paul.Esson 53 Junior Poster

sorry and in C

#include <stdio.h>
int main(){
	long long a = 111111111;
	printf("%lld", a * a );
	return 0;
}
Paul.Esson 53 Junior Poster

That scares me a little, How does one implement a rotating counter in python ?

class Program
	{
		public static void Main(string[] args)
		{
			ulong a = 111111111; // Thats 9 1's
			System.Console.WriteLine((a * a));
		}
	}

using C++ and .net

using namespace System;

int main(array<System::String ^> ^args)
{
	Int64 a = 111111111;
    Console::WriteLine( Int64(a * a) );
    return 0;
}
//Don't have a java compiler but would be somthing along the lines of 
long a = 111111111;
System.out.println( (a * a).toString());
vegaseat commented: thanks for the code samples +8
Paul.Esson 53 Junior Poster

Look at the syntax of Java and Python. Which one would you rather use?

In that case Java.

Only reason I have never tryed Python is because of the syntax. I feel that is far removed from everything else. Switching from C++ to C to Java to C# is simple, The syntax in the languages are very similar, But that may just be me.

Paul.Esson 53 Junior Poster

Ok, Replying to my own thread here, But I have had a look around the net and from what I can tell it refers to a reference to a managed type in .NET. I may be wrong ( since I have seen nothing that has said this yet )

Paul.Esson 53 Junior Poster

After looking at compile errors because I was not overriding this function ( although being convinced that I was) I have a query for all you C++ buffs in the audiance. What does the ^ do in the following line.

virtual System::Object ^ Clone(void) override;

I know this is quite possably a stupid question and for that I am quite sorry.

Paul.Esson 53 Junior Poster

You will have to use the interop services according to MSDN and the GetSystemTime function located in coredll.dll

Paul.Esson 53 Junior Poster

John i had tried something like this a while ago.
I USED Urllib to retrieve the html code of a given search results page supplied by me.
However with all the other links like advertising and such in the html code i was unabke to determine the top 10 links as listed on the page.

I think you will have to have a look at the surrounding tages for each link. If you have a look at google you will notice that all sponsored links are in a sepirate div tags. The best way to tackle this may be to do say 12 separate seraches on google that return sponsors then chuck them into diff see what changes and what is similar about the pages.

Paul.Esson 53 Junior Poster

Yet again, Not a python coder, Just crusing around on the python fourms.

But if I was going to attempt to do somthing as such I would be looking at how to do a HTTP GET request good looking artical here and also look at how you would parse your HTML perhaps using regular epressions explained here

Anyhow hope this helps somehow

Paul.Esson 53 Junior Poster

I also don't see people jumping ship to support Java. I feel community development will be quite strong with python and Java will have alot more commertial development ( organizations that wish to create open source projects. )

Paul.Esson 53 Junior Poster

Python is a language that I personally have had no real experiance with but I understand is very popular in the open source world. Python and C appear to be the current choice for majority of open source developers, therefor you should have no shortage of projects to work on or great open source libarys to use. Java does not support as many open source libarys as python and I dare say will not anytime in the near future.

It appears that python is a really good beginner language and also quite good for quickly creating code.

Paul.Esson 53 Junior Poster

I am a little uncertain of what you wan't so I apologize if I am completly off the mark. But if you want the current time in ticks the actual datetime structure has a Ticks property you can use this in conjunction with DateTime.Now or DateTime.UtcNow so DateTime.UtcNow.Ticks ... Hope this helps

Paul.Esson 53 Junior Poster

Take a look in the Device Manager "Start->Control Panel->Device Manger" and also a look at System "Start->Control Panel->System" ( I think ). Mostly people are interested in how much ram a computer has in system what processor also in system, as well as how much hard disk space it has( my computer right click on the drive and click properties ) and what video card it has (right click on the desktop hit properties, go over to the advanced tab and check out the model of the video card, also in device manager.

Paul.Esson 53 Junior Poster

That would suggest I guess that its something other then the on board graphics card that is causing the issues.

Is it still the IRQL_NOT_LESS_OR_EQUAL error, or do you get a different one now, Does the dump contain a mention of what driver caused it ?

Paul.Esson 53 Junior Poster

Did you uninstall the driver for the old video card.

IRQL_NOT_LESS_OR_EQUAL will occurs if the Driver running at a high IRQL attempts to access memory but encounters a page fault ( the memory that it is trying to access is no longer in ram and has been paged onto the hdd ).

Basically, this error will commonly occur if a driver has been poorly written, Routines running at IRQL>= DISPATCH_LEVEL should not use paged memory.

Paul.Esson 53 Junior Poster

But i must continue on to state that while java does have bindings for the DOM, AJAX refers to the usage with JavaScript (refereed to on the w3c site as ECMAScript) to create dynamic webpages.

But you may use serverlets or jsp to provide the contents for these pages.

Paul.Esson 53 Junior Poster

ajax stands for Asynchronous Javascript and XML.
Now technically this is not a java technology, While javascript and java have similar syntax, they are both quite different, Javascript is an interpreted language while Java is compiled into a intermediate language called bytecode (or fcode depending on how far back you look ) and is then run by a Just In Time compiler called the Java Virtual Machine.

AJAX refers to using JavaScript with the Document Object Model to allow a designer to create a seamless feel to there page, They do this buy requesting information from the server and instead of taking you to another page JavaScript is then used to display this information some were with in the page.

W3C DOM

Paul.Esson 53 Junior Poster

random annoying note its a representation of an ellipse not a circle.

I know that has no relevance at all, circle just has x, y and r

Paul.Esson 53 Junior Poster

What library are you allowed to use .NET or just MFC ?

Paul.Esson 53 Junior Poster

Hey,

There is a lastlog command in unix that displays the contents of the /var/log/lastlog file, This is a binary file and a structure describing the contents is located in the <bits/utmp.h> header file

struct lastlog
{
#if __WORDSIZE == 64 && defined __WORDSIZE_COMPAT32
int32_t ll_time;
#else
__time_t ll_time;
#endif
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};

anyhow more useful is prolly this example of a lastlog editor written in C that can be found here

Paul.Esson 53 Junior Poster

You will have to take a look at regular expressions in C# found in the System.Text.RegularExpressions System.Text.RegularExpressions Namespace

it may also pay to have a look at some regular expression tutorials on the web.

Paul.Esson 53 Junior Poster

If your second class has been defined as class2 and is accessible within your current form ( in the same project and within the same namespace ) it should work. That error suggests that it is unable to find the class named class2,

Just make certain that where this one says

public class UserLogin : Form

your second form says

public class Class2 : Form

note it is caps sensitive and I did say to use Class2 so if you have named your class 'class2' insted of 'Class2' you will have to write

if(txtUser.Text == "MJ12" && txtPass.Text == "Roswell1947")
{
	// Create instance of the mainForm class
	Form nextForm = new class2();
	// We may need to make it visable
	nextForm.Visible=true;
}
Paul.Esson 53 Junior Poster

so when you boot up in safe mode could you see the screen ?

Paul.Esson 53 Junior Poster

Um, I don't know if there is anything out there for this personally, But I may be able to point you in the right direction if you want to make something like this. You will have to use System.IO.Ports.SerialPort to communicate with your modem, if you google System.IO.Ports.SerialPort you will find alot of great looking tutorials on using this class including this

You will then have to find out what AT Commands your modem supports. Send the modem the AT command and parse the output, Hopefully with anyluck the modem will have an AT command corresponding to the last number that dialed, or something similar.

I have only ever used AT commands to send SMS Messanges so I don't know if what you are asking is possible or not.

Paul.Esson 53 Junior Poster

Some services will send version information when requested. This should allow one to determine the OS running on different machines. For instance RFC 2616 for HTTP describes the server response header

The Server response-header field contains information about the software used by the origin server to handle the request. The field can contain multiple product tokens (section 3.8) and comments identifying the server and any significant subproducts. The product tokens are listed in order of their significance for identifying the application.

This may be used to find the operating system if it is listed in the header, Although there is no guarantee that it will be listed

PoovenM commented: Very impressive! +2
Paul.Esson 53 Junior Poster
if(txtUser.Text == "MJ12" && txtPass.Text == "Roswell1947")
{
	// Create instance of the mainForm class
	Form nextForm = new Class2();
	// We may need to make it visable
	nextForm.Visible=true;
}

I think that should work, But don't have Windows.Forms on this computer to play around with, so am abit uncertain

Paul.Esson 53 Junior Poster

you will have to look into the sockets API, you can either check if a port is open, then if it is assume that the corresponding service is ruinning on it. For instance if port 80 is open you could assume that http is running. The alternative to this is to attempt to figure out what protocal is running by analyzing the packets sent back from the server.

For UDP protocols you can only tell if a port is open if a. the server responds to a packet or b. the server sends a ICMP port unavailable when the UDP port is closed. ( since the TCP handshake does not happen with UDP ).

Anyhow, I don't know if this helps, But I hope it does