Let's say you have this program:
public class sample
public static void main(String args[])
{
System.out.println("Hello world!");
}
}
... is there a converter that will turn it into this:
import java.applet.Applet;
import javax.swing.*;
public class sample extends JApplet
{
public static JTextArea area;
public void init()
{
area = new JTextArea();
add(area);
area.append("Hello world!");
}
}
I mean, I can do it by hand... but it would take some time.
as i said i get this horrible error i dont really know what to do anymore
float n= xAxis[i].Normalize();
thats where i get the error and i get it cuz normalize is a void function this is it
void CVector::normalize()
{
float len=Magnitude();
this->x /= len;
this->y /= len;
}
i need normalize to stay as void tho i tried normal casting like this
float n= (float)xAxis[i].Normalize();
and it doesnt work also with static,dynamic cast,reinterpret,const cast and cant make it work any help would be really apreciated...
thank you .<
I have a program that handles byte arrays in Java, and now I would like to write this into a XML file. However, I am unsure as to how I can convert the following byte array into a sensible String to write to a file. Assuming that it was Unicode characters I attempted the following code:
String temp = new String(encodedBytes, "UTF-8");
Only to have the debugger show that the encodedBytes contain "\ufffd\ufffd ^\ufffd\ufffd-m\ufffd\ufffd\/ufffd \ufffd\ufffdIA\ufffd\ufffd". The String should contain a hash in alphanumerical format.
How would I turn the above String into a sensible String for output?
I'm looking to export a page that looks good in print media, to word.
Can this be done automatically, or mostly automatically with office apis?
The alternative is to create a program that reads all our style meta data and font meta data and convert to word and force a download.
The issue is our style metadata is already built for css, its a web app after all. And writing my own css parser, doesn't sound like a good use of time.
I just started using C# and I've got a couple of issues.
I hook several controls to one event handler as in the following and I want to perform a slightly different action for each control:
Private Sub Button_Click(sender as Object, e as EventArgs) _
Handles button1.Click, Button2.Click
'do a general activity
Select CType(sender, Button).Name
Case button1.Name
'do something
Case button2.Name
'do something else
Case Else
'do the defalut action
End Select
End Sub
Is there any way of doing the above select statement in C# without having to use nested ifs?
I am trying to convert a 24bit Hexadecimal string (6 characters) signed in two's complement to a long int in C.
This is the function I have come up with:
long int hex2li (char string[])
{
char *pEnd;
long int result = strtol (string, &pEnd, 16);
if (strcmp (pEnd, "") == 0)
{
if (toupper (string[0]) == 'F')
{
return result - 16777216;
}
else
{
return result;
}
}
return LONG_MIN;
}
Is it valid? Is there a better way of doing this?
I have a need to convert a string value in the form "YYYYMMDDHHMMSS" to a DateTime. But not sure on how, may be a DateTime.Tryparse can be used to make this happen. Or is there any other way to do it. I can do this using some string operations to take "YYYYMMDD" alone, convert to a datetime and then add HH, MM, SS separately to that DateTime. But is there any DateTime.TryParse() methods that I can use in one line to convert a "YYYYMMDDHHMMSS" format string value to a DateTime value?
I have a SQL Server 2000 database with a column of type VARCHAR(255). All the data is either NULL, or numeric data with up to two points of precision (e.g. '11.85'). I tried to run the following T-SQL query but received the error 'Error converting data type varchar to numeric'
SELECT CAST([MyColumn] AS DECIMAL)
FROM [MyTable];
I tried a more specific cast, which also failed.
SELECT CAST([MyColumn] AS DECIMAL(6,2))
FROM [MyTable];
I also tried the following to see if any data is non-numeric, and the only values returned were NULL.
SELECT ISNUMERIC([MyColumn]), [MyColumn]
FROM [MyTable]
WHERE ISNUMERIC([MyColumn]) = 0;
I tried to convert to other data types, such as FLOAT and MONEY, but only MONEY was successful. So I tried the following:
SELECT CAST(CAST([MyColumn] AS MONEY) AS DECIMAL)
FROM [MyTable];
...which worked just fine. Any ideas why the original query failed? Will there be a problem if I first convert to MONEY and then to DECIMAL?
Thanks!
Good day everyone and happy holidays.
I'm trying to create a "simple" program that allows me to create a list of video files (Youtube video's to be precise) that are then run through by my program and converted any given format to pure MP3 audio. For this purpose I'm trying to use the BASS.dll and well it isn't going so well.
I was wondering if anyone has used BASS to convert from one audio format to another?
Or is there another library better suited for this?
I'm having trouble understanding the result of the following statements:
>>> from array import array
>>> array('L',[0xff,0xff,0xff,0xff])
array('L', [255L, 255L, 255L, 255L])
>>> from array import array
>>> array('L','\xff\xff\xff\xff')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: string length not a multiple of item size
I'm writing a C# frontend to a legacy database that uses VB6 Rnd() and Randomize() methods for user password encryption. The encryption function is very simplistic and really not all that secure, but it's what all current passwords are stored with.
What I'd like to be able to do is authenticate legacy users from a C# application. I can write new encryption (or preferably hashing) code for VB6 so that all future users have a more secure password, and that can be duplicated in C#. But I don't want to require current users to have had their password reset before they can use the new frontend.
Is there any way I can reimplement that algorithm in C# so that it produces identical results to the legacy VB6 code?
I was wondering if anyone would be able to help me convert the below code to c#? From what I have read it seems to be similar however I am not sure if my 'case' statements are still able to be used?
Public Class Form1
Dim dteStart As Date
Dim dteFinish As Date
Dim span As TimeSpan
Public Sub KeyDown(ByVal Sender As System.Object, ByVal e As _
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.Q
Label1.BackColor = Color.Green
dteStart = Now()
Case Keys.W
Label2.BackColor = Color.Green
Case Keys.E
Label3.BackColor = Color.Green
Case Keys.R
Label4.BackColor = Color.Green
dteFinish = Now()
span = dteFinish.Subtract(dteStart)
Label5.Text = span.ToString
End Select
End Sub
Public Sub KeyUp(ByVal Sender As System.Object, ByVal e As _
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
Select Case e.KeyCode
Case Keys.Q
Label1.BackColor = Color.Red
Case Keys.W
Label2.BackColor = Color.Red
Case Keys.E
Label3.BackColor = Color.Red
Case Keys.R
Label4.BackColor = Color.Red
End Select
End Sub
End Class
Hi,
I cannot initialize a non-const reference to type T1 from a convertible type T2. However, I can with a const reference.
long l;
const long long &const_ref = l; // fine
long long &ref = l; // error: invalid initialization of reference of
// type 'long long int&' from expression of type
// 'long int'
Most problems I encountered were related to r-values that cannot be assigned to a non-const reference. This is not the case here -- can someone explain? Thanks.
I'm using XML::XML2JSON in Perl to convert JSON data to XML, I am passing through the following data (snippet):
{"question":{"isrequired":{"$t":"0"}}}
and when I use the XML:XML2JSON-json2xml function to convert the JSON data into XML, I get the following (snippet):
<isrequired/>
I need to retain the "0" element in the "isrequired" tag, because at times, I will have empty JSON elements, and need the empty XML tag. I think the documentation is a bit vague (either that, or I don't understand it), but is this possible to do with this module?
I would appreciate the help. Thanks.
I’m looking for a solution to send DRY multipart emails in Rails. With DRY I mean that the content for the mail is only defined once.
I’ve thought about some possible solutions but haven’t found any existing implementations.
The solutions I’ve thought about are:
load the text from I18n and apply Markdown for the html mail and apply Markdown with a special output type for the text mail where
links are put in parenthesis after the link text
bold, italic and other formatting that doesn't make sense are removed
ordered and unordered lists are maintained
generate only the html mail and convert that to text according to the above conditions
Is there any available solution out there? Which one is probably the better way to do it?
Dear all,
Hello Guys!!
This is my first post in the forum . I am really looking forward to having good fun in this site. My question is :
int mem_size = 10;
char *start_ptr;
if((start_ptr= malloc(mem_size*1024*1024*sizeof(char)))==NULL) {return -1;}
I have allocated a chunk of memory of type char and size is say 10 MB (i.e mem_size = 10 );
Now I want to store the size information in the header of the memory chunk,
To make myself more clear
Lets Say : start_ptr = 0xaf868004 (This is the value I got from my execution, it changes every time)
Now I want to put the size information in the start of this pointer..
i.e *start_ptr = mem_size*1024*1024;
But I am not able to put this information in the start_ptr. I think the reason is because my ptr is of type char which only takes one byte but I am trying to store int which takes 4 bytes, is the problem .
I am not sure how to fix this problem..
I would greatly appreciate your suggestions.
Cheers!!
Aditya
Hi,
I am trying to convert an integer number in C into an array containing each of that number's digits
i.e. if I have
int number = 5400
how can I get to
int numberArray[4]
where
numberArray[0] = 0;
numberArray[1] = 0;
numberArray[2] = 4;
numberArray[3] = 5;
Any suggestions gratefully received
--dave
I don't suppose anyone knows of a function (PHP, preferably) that can take a hex color code and give an approximate color name for that hex value. I don't need a solution with 100s of colors. Even if it just amounted to the colors white, black, red, green blue, brown orange and yellow, I'd be pretty well in shape.
If you don't know of an existing resource, does anyone know of a good way to approach this problem?
Thanks in advance for the help.
Hi,
I made a small RGB to HSV converter algorithm with C. It seems to work pretty well, but there is one strange problem: If I first convert i.e. a 800x600 picture into HSV map and then back to RGB map without doing any changes in the values, I get some pixels that are convertet incorrectly. Then if I try to convert those misbehaving single pixels alone to and back, they're converted correctly. Any idea what could be the problem? I'm using Daniel Karlings PNGLite to open that PNG file.
Here are the source code of my main.c, rgbtohsv.c and rgbtohsv.h
rgbToHsv.h
rgbToHsv.c
pngmain.c
I linked pngmain only that if somebody wants to test and run this on his own system.
-zaplec
Hello
I'm developing a scientific application using .net framework.
The application depends heavily upon a large data structure (a tree like structure) that has been serialized using a standard binaryformatter object.
The graph structure looks like this:
<serializable()>Public class BigObjet
inherits list(of smallObject)
end class
<serializable()>public class smallObject
inherits list(of otherSmallerObjects)
end class
...
The binaryFormatter object does a nice job but it's not optimized at all and the entire data structure reaches around 100Mb on my filesystem. Deserialization works too but it's pretty slow (around 30seconds on my quad core).
I've found a nice .dll on codeproject (see "optimizing serialization...") so I wrote a modified version of the classes above overriding the default serialization/deserialization procedure reaching very good results.
The problem is this: I can't lose the data previosly serialized with the old version and I'd like to be able to use the new serialization/deserialization method. I have some ideas but I'm pretty sure someone will be able to give me a proper and better advice !
use an "helper" graph of objects who takes care of the entire serialization/deserialization procedure reading data from the old format and converting them into the classes I nedd. This could work but the binaryformatter "needs" to know the types being serialized so........ :(
modify the "old" graph to include a modified version of serialization procedure...so I'll be able to deserialize old file and save them with the new format......this doesn't sound too good imho.
well any help will be higly highly appreciated :)
Hey there, this is part of a question i got in class, im at the final stretch but this has become a major problem. In it im given a certain value which is called the "gold value" and it is 40.5, this value changes in input.
and i have these constants
const int RUBIES_PER_DIAMOND = 5; // relative values. *
const int EMERALDS_PER_RUBY = 2;
const int GOLDS_PER_EMERALDS = 5;
const int SILVERS_PER_GOLD = 4;
const int COPPERS_PER_SILVER = 5;
const int DIAMOND_VALUE = 50; // gold values. *
const int RUBY_VALUE = 10;
const int EMERALD_VALUE = 5;
const float SILVER_VALUE = 0.25;
const float COPPER_VALUE = 0.05;
which means that basically for every diamond there are 5 rubies, and for every ruby there are 2 emeralds. So on and so forth.
and the "gold value" for every diamond for example is 50 (diamond value = 50) this is how much one diamond is worth in golds.
my problem is converting 40.5 into these diamonds and ruby values. I know the answer is 4rubies and 2silvers but how do i write the algorithm for this so that it gives the best estimate for every goldvalue that comes along??
please help!, im at my wits end
I'm familiar with:
Convert.ToInt32(texthere);
But is there another cleaner way to do it? I like having readable code for coworkers and I'm always on the lookout for anything that'll make my work seem more obvious.