riahc3 50 Â Team Colleague

It depends, but yes, in general I wouldn't shy from using the words "laborious" and "verbose" when it comes to wrapping native code.

Ill explain a bit of the original C++ program :)

Basically it is a drawing program where you set the size of a rectangular space. Afterwards a "paint" like interface is shown, where you draw the shape you want. Once you are finished, the program calculates how many of those shapes can fit next to one another in that rectangular space, also making a drawing of the rectangular space with the shapes already drawn.

If you are satisfied, you press OK the program turns the data into a binary file which then is inserted into a machine which lasers the shapes into a rectangular metal sheet.

More or less and changing a few things around, that is the current C++ program. From what I know, it uses classes.

The process goes something along these lines:

Thanks for explaining :) Hope you can help me on some points as sadly only 2 people know Java in this company which would be me and another guy they hired.

Create a new C or C++ project which would act as a "wrapper" for your library

By this I imagine that you mean that nearly all the calculations in classes, functions, procedures, etc must be turned basically into usable functions in a C++ library right?

This project would contain the "bridge" methods in the sense that they …

riahc3 50 Â Team Colleague

Is it "difficult" to do?


Most of the C++ libraries (which is currently a program but to be used by Java I imagine they have to be converted into loose libraries) are just math calculations.

riahc3 50 Â Team Colleague

Hey


Im currently working on a application server written in Java but to use information from a C++ program.


The company seems to agree that rewriting thousands of lines of code would be time consuming and simply making libraries of key functions of the C++ program and then passing them to the Java servlet would be much easier on resources and time (there are only 2 Java programmers)


Searching for information, Ive read about Java Native Interface (or JNI) which allows more or less what we are looking for.


Is this possible and is JNI heading in the right direction?


Thank you

riahc3 50 Â Team Colleague

Hey

Lets say I have 2 columns in table1

Id Value

Id is obviously primary but I want Value to be unique....

I tried "NOT EXISTS" with a subquery but I cant really seem to get it to work. It would be something like

INSERT INTO table1(value) WHERE VALUES('3');

From then on I dont want 3 to be inserted again in the Value column. I dont care about the ID column.

How do I do this in MySQL?

Thanks for the help

riahc3 50 Â Team Colleague

Hello

I have a TreeView such as this

1
2
2a
2b
3
4
4a
5

And I want to when I press a button disable 2 and 4 (with all its child nodes). How can I do this?

Thanks

riahc3 50 Â Team Colleague

Hey

Im writing a platform game "Mario style" for mobiles in Java but I seem kinda stuck. Any recommendations on some points I should do? Ill view them and post code Ive done related to them.

To recap some of the things done:
Map loads
I can "move" (what actually moves is the background)
Collision is implanted but does not work correctly
I can sorta jump (doesnt work correctly either)
Countdown time implanted (but not implanted in game)
Graphics implanted

Thanks.

riahc3 50 Â Team Colleague

Perfect. Finally, a well explained process. Thanks alot.

riahc3 50 Â Team Colleague

Hello

Ive been searching around Google and while I have found some answers, Im not sure how to implant them correctly.

I wish to disable the Close (X) button on a Windows Form. I read about ControlBox (I think that the property) but I perfer to do it another way.

Thanks.

riahc3 50 Â Team Colleague

Hello

I have a form with a textfield simply named 'textfield' on one page and a table with a recordset on another page. It has a dynamic field/text with this code

SELECT codas
FROM t
WHERE user = colname

and colname is

$_POST['textfield']

I manually replace colname with a user I have in my BD and it works perfectly. I tried switching the form on the first page to GET but it doesnt let me as it seems the wizard for login user doesnt allow me. Im kinda stuck and lost so if someone could help me, thanks.

riahc3 50 Â Team Colleague

Hey

I want to control a textbox to only allow numbers, backspace and a certain length. Ive tried with the IsNumeric function but I cant seem to get it to work.

Thanks.

riahc3 50 Â Team Colleague

Hello

I seem to have a problem with a UPDATE that just does not want to work. Im simpled it down to the most simple UPDATE possible and it simply does not want to work. Here is the simple version:

public static string CambiarDatosUsuarios(string usuario,string contr,string pregunta,string respuesta,string correo)
    {
        string res;
        try
        {
            comando = new MySqlCommand("UPDATE usuario SET pregunta=@preg,respuesta=@resp,email=@cor WHERE nombreu=@usud", conexion);
            comando.Parameters.Add("@usud", MySqlDbType.VarChar, 50).Value = usuario.ToUpper();
            comando.Parameters.Add("@preg", MySqlDbType.VarChar, 50).Value = pregunta;
            comando.Parameters.Add("@resp", MySqlDbType.VarChar, 50).Value = respuesta.ToUpper();
            comando.Parameters.Add("@cor", MySqlDbType.VarChar, 50).Value = correo;
            AbrirConexion();
            comando.ExecuteNonQuery();
            comando.Parameters.Clear();
            comando.Dispose();
            res = "Usuario actualizado con excito";
        }
        catch (Exception ex)
        {

            res = ex.Message;
        }
        finally
        {
            CerrarConexion();
        }
        return res;
    }

It gives NO errors but doesnt UPDATE any columns. I replaced it with a SELECT COUNT(*) and it works perfectly so I know I dont have column names or the table wrong.

If someone could help, thanks alot.

riahc3 50 Â Team Colleague

(I know this is the C++ section but since Im not sure where to put this...)

I have a movie clip that with ActionScript I would like to do a gotoandStop on (for example) frame 3 of Layer 1 but I would like to keep playing Layer 2. How do I do this?

riahc3 50 Â Team Colleague

Read that first page already but I see that its with a class and everything. Nothing built in?

riahc3 50 Â Team Colleague

Hey

How can I send mail thru C#? It seems that it can be sent only thru Smtp (from Googling) but there has to be a way to do it thru POP3 as Windows Live Hotmail supports it and AFAIK VB.NET also supports it.

If someone can give me a snippet as I cant find any information, thanks.

riahc3 50 Â Team Colleague

Setting a "watch" is a function of the Debugger the IDE uses, so read the IDEs documentation.

I searched around but did not see anything.

riahc3 50 Â Team Colleague

Hey

This might sound like a dumb question but I simply dont know how to do it. Not only that but for some reason I do not know, my professor refuses to teach me how to use debugging and watch variables. He wants the "change, try, and test" method....

I think debugging is alot better so I wish someone could help me.

In the IDE, I load up my project and have a variable under

public class Main extends Frame {

simple declared as:

byte x=1;

I hit the Debug menu then New Watch...

In the window I simply enter x and the Variables windows shows with under the column Name and variable I just put which is x.

I hit Debug Project and where it says Value it says >No current context (stack frame)<

How can I view the value of this variable while Im debugging the program? I debug the program like normal (the value of this variable is at one time or another modified while Im debugging the program) but the column Value always shows the same thing.

Thank you

riahc3 50 Â Team Colleague

Hello

Im intrested in making a small online store mockup just to test a bit how it would work. Id like simply a "shopping cart" with a login system where I can add products to the shopping cart and "buy" them.

Any guides, tutorials, tips, snippets, etc? Thank you :)

riahc3 50 Â Team Colleague

Hey

Im having a hard trouble drawing in a Java window so if there is a plugin that shows the coordinates in a Java window when I hover my mouse over that spot it would make my coordinate easier.

riahc3 50 Â Team Colleague

Hello

I want to use a CustomValidator using ASP.NET/C# to make sure a textbox isnt empty (no spaces, no blanks, no nulls, etc)

How do I do it?

Thanks

riahc3 50 Â Team Colleague

The class Math in the package java.lang has a static method random() which returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
I use this method to generate random number. For example, to generate a integer varying from 0 to 255 [0,255], one may call the method by the following code:

int a = (int) (Math.random()*256);

Please study the API for reference.

First, thank you for the reply.

Also, how about negative numbers? And is there a method just using:

import java.util.*;
import java.io.*;

?

Again, thank you for the help.

riahc3 50 Â Team Colleague

Im wondering how do I correctly generate a random number in Java. Sometimes it gives me a negative, positive, very small range ,etc. Id like a simple formula that can give me some examples to control this better.

Thank you very much.

riahc3 50 Â Team Colleague

Would you care to explain more? You need an IDE and it supposed to handle other languages or you just want IDE that is not based on Java?

My mistake for not explaining right :)
My ideal IDE would be a IDE that is not written in Java but can code and comply Java code.

riahc3 50 Â Team Colleague

I tried Eclipse once with C and didnt really like it much; Switched from Eclipse to Codeblocks (all this C) and fell in love :P Too bad Codeblocks cant do (complie) Java

riahc3 50 Â Team Colleague

Hey

Ive been hearing about Netbeans but Id like alternatives. Any out there? If the program is not written in Java (ironic I know) I would perfer it.

Thanks

riahc3 50 Â Team Colleague

I think a second later I just solved :P

This would generate 1, 0, -1:

num = Int(Rnd() * (2 - 0 + 1)) + -1

This would generate 0, -1, -2:

num = Int(Rnd() * 3 - 0 + 1) + -3

Correct?

riahc3 50 Â Team Colleague

Hey

I want to generate 3 different types of arrays but 2 include a negative number and Im not really sure how to do that.

The first type should generate 0 to 2 (which works):

num = Int(Rnd() * (2 - 0 + 1)) + 0

Now I need one that generates -1, 0, or 1.
and another that generates -2, -1, or 0.

If someone could help me out quickly, thank you very much as it is driving me nuts.

riahc3 50 Â Team Colleague

Answer: the "gets" function *IS* a bug. kill it before it breeds.

The problem was that the size I was passing in the first function was a incorrect size and it had problems.

This is something simple so gets works OK for this :)

riahc3 50 Â Team Colleague

Try running this code...What do you notice about the output. Is match different than str?

#include <stdio.h>
#include <stdlib.h>

char match[] = "123";

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

	fputs("enter a value->", stdout);
	fgets(str, 25, stdin);
	

	fputs(str, stdout);
	fputs(match, stdout);


	exit(EXIT_SUCCESS);
}

Well it seems that in the main function it works always but using 2 functions, it doesnt. So if you dont mind a example using 2 functions :)

>>Now if I input 32432, 23432, 23234, 1233,9898, 87343, 238432

gets() is a horrible function because if the input buffer is not large enough to hold all the characters you type then it will just scribble any excess characters all over memory. So if you typed that all on one line before hitting the <Enter> key then gets() will crash your program. gets() doesn't stop at the first spaces, but only when '\n' is encountered.

A better way to do it is to use fgets(), which will limit the input to the size of the input buffer. The problem with fgets() is that it may put the '\n' in the buffer too, which you will have to remove.
fgets(stn, sizeof(stn), stdin);

If I want it to only get 8 characters, I should set it to 9? (To include the /0 character)

riahc3 50 Â Team Colleague

You can't use this

stn!="123"
str=="123"

Try looking up strcmp or the string library of functions

It is not a literal example :) Im very sorry that I did not state that.

void valid(int stringi,int *var)
 {
     char strings[20];
     itoa(stringi,strings,10);

        if (strlen(strings)==8)
        {
            if ((stringi>=11111111) || (stringi<=99999999))
            {
                    printf ("Valid!\n");
                    (*var)=1;
            }
        }
        else
        {
            printf ("Invalid!\n");
            (*var)=0;
        }
 }

 void insertstring(char *string)
 {
     int var=0;
     do
     {
        fflush(stdin);
        printf ("Insert:\n");
        gets(string);
        //fgets(string,sizeof(&string),stdin);
        valid(atoi(string),&var);
     }while(var==0);
 }

This is a quick rough up of my real example. fgets is something I tried as well but it doesnt work correctly.

riahc3 50 Â Team Colleague

Hey

Im doing a loop with somthing similar to this:

char stn[25];
do
{
  printf ("Insert a number:\n");
  gets(stn);
}while (stn!="123");
if (str=="123")
{
 printf ("Good value!");
}

Now if I input 123, it enters the if that prints "Good value!" and the program ends naturally.

Now if I input 32432, 23432, 23234, 1233,9898, 87343, 238432 (all of this it would continue inside the do while loop) and finally I enter 123, it prints "Good value!" but the program itself crashes.

Very strange. I think it is a error with the buffer overfilling or something similar. I tried with fflush(stdin) before/after/both in the gets() loop but nothing.

How can I solve this?

riahc3 50 Â Team Colleague

Does ncurses for Windows exist?

riahc3 50 Â Team Colleague

forget getch and getche ever existed. the need for unbuffered terminal input has become obviated since the widespread adoption of GUIs, like, about 15 to 20 years ago.


or dont, and hobble yourself with reliance on non-standard, non-portable library functions that will render your code unusable on most systems other than your own.


.

This is a small project for school but I perfer that it stay standard so it can run on Windows, OSX, and Linux as I on a personal level use Windows AND Linux.

riahc3 50 Â Team Colleague

>I rather not use conio.h for cross compatibility
Good idea.

>is there any way to make my own "conio.h" and just include it in my compilation
Um, conio.h offers functionality that's non-portable by nature. No matter how you do it, you'll end up rewriting your replacement for every target to maintain portability. Is it possible to reproduce the functionality of conio.h? Absolutely, but all of those methods are (surprise surprise!) non-portable. Thus, you're right back where you started.

My usual recommendation with conio.h is to seriously consider whether it's needed in your program. Most of the time it's not.

I personally wanted to use getch and getche

riahc3 50 Â Team Colleague

Hey

I rather not use conio.h for cross compatibility so is there any way to make my own "conio.h" and just include it in my compilation.

Thanks.

riahc3 50 Â Team Colleague

I imagine this means it is impossible to do :(

riahc3 50 Â Team Colleague

I know my problem is difficult and actually may be impossible, but I hope Ive explained it well. If not, please ask.

Thanks for all the help given already :)

riahc3 50 Â Team Colleague

So you want to set background color for selected labels. Prepare an array/list of selected labels.

Dim lst(3) as Label
 lst(0)=Label18
 lst(1)=Label19
 ....
 For I=0 To lst.GetUpperBound(0)
    lst(i).BackColor=Color.Red 'Put your code here...
 Next

Well in the list I would have to include the names of all the labels right? So I would have to type them out anyways....


The only way Ive thought of (thanks to your idea) is to go thru the groupbox with the labels inside them that I specifically want their labels' background color to change when I click on them and add all their object names in the list with a for. Would this be possible?

But even then, what would I do on handling the event?

riahc3 50 Â Team Colleague

Hey

I have a use for working with basic binary search trees but I cant seem to find good examples on the basic operations such as sorting, insert data, delete and search for data.

Can someone give some basic examples? Thanks.

riahc3 50 Â Team Colleague

>POST #1 - so they are labels inside of groupboxes.

For Each cnt As Control In Me.Controls  
..

All controls added into Form's collection (Label,TextBoxe, etc) are subclasses of Control class.

Me is an object variable has reference of activeform. Me.Controls is a property of Form has references of all controls (collection) added/placed into a form. For Each statement iterates Me.Controls collection by assigning reference of each control to the cnt - Control class variable.

If TypeOf cnt Is GroupBox Then 
...

TypeOf and IS operator check the datatype/classtype of an object which is currently referenced by the cnt variable.

I hope this will help you to understand code-snippet.

Thanks for the help first off :)

I believe you send all the objects inside the forums into cnt and make all the labels turn from white to red and red to white, but there are only specific wants I want. Lets say I want label18-label20 and label25-label27

I dont want to have to put:

Private Sub LabelClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label18.Click, Label19.Click, Label20.Click, Label25.Click,Label26.Click,Label27.Click

All these labels are in groupboxes (in my project).....I might not be understanding you or visaversa. So one more time, if you dont mind explaining your code again if it does what Id like. Thanks for all the help.

riahc3 50 Â Team Colleague

>But this will only work if I click one label right?

No. It works for all labels in all the groupboxes on a form.

So therefore the code would be:

Private Sub LabelClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label14.Click, Label15.Click, Label16.Click, Label17.Click  
For Each cnt As Control In Me.Controls    
        If TypeOf cnt Is GroupBox Then   
             For Each child In cnt.Controls           
         If TypeOf child Is Label Then           
             CType(child, Label).BackColor = Color.Red      
              End If               
 Next           
 End If      
  Next
    End Sub

And it would work for the groupboxes that I require for this action to happen and all the labels in them? There are other groupboxes with labels that I do NOT want this to happen....

If you can give me a small explanation on the code, thank you because I dont understand the "cnt" part of the code.

riahc3 50 Â Team Colleague

>Is there anyway to put the rest of them?

....
 For Each cnt As Control In Me.Controls
            If TypeOf cnt Is GroupBox Then
                For Each child In cnt.Controls
                    If TypeOf child Is Label Then
                        CType(child, Label).BackColor = Color.Red
                    End If
                Next
            End If
        Next
..

But this will only work if I click one label right?
Lets say I have
1 2 3
all three are with background color white. When I click, I want it to change to red and if I click again back to white. But this for alot of labels.

riahc3 50 Â Team Colleague

Hey

I currently have

Private Sub LabelClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label14.Click, Label15.Click, Label16.Click, Label17.Click

        If sender.backcolor = Color.LightGray Then
            sender.backcolor = Color.Green
        ElseIf sender.backcolor = Color.Green Then
            sender.backcolor = Color.LightGray
        End If
    End Sub

But there are ALOT of labels (about more than 300) and typing them out (or selecting them in the menu) consumes alot of time. Is there anyway to put the rest of them? I have about 8 groupboxes with these labels that need to be changed (there is another one that doesnt need this) so they are labels inside of groupboxes.

How can I do this?

So noone knows how to do this or there simply is no way?

riahc3 50 Â Team Colleague

Hey

I currently have

Private Sub LabelClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label14.Click, Label15.Click, Label16.Click, Label17.Click

        If sender.backcolor = Color.LightGray Then
            sender.backcolor = Color.Green
        ElseIf sender.backcolor = Color.Green Then
            sender.backcolor = Color.LightGray
        End If
    End Sub

But there are ALOT of labels (about more than 300) and typing them out (or selecting them in the menu) consumes alot of time. Is there anyway to put the rest of them? I have about 8 groupboxes with these labels that need to be changed (there is another one that doesnt need this) so they are labels inside of groupboxes.

How can I do this?

riahc3 50 Â Team Colleague

First loop - say i - for each line so it runs from 0 to n-1
Inside this loop
{
First loop - j - goes from i to (2*i - 1) - print each j
Second loop (not nested in the j loop above) - j - goes from (2*i - 2) to i (backwards)
}

I am really curious? Is what you wrote actually what you think I wrote? Could you explain, please, how you translated my info? It makes no sense to me.

for (i=0;i<=n-1;i++)    {        for (j=i;j<2*i-1;j++)        {            printf ("%i",j);        }        for (j=2*i-2;j<i;j--)        {            printf ("%i",j);        }    }

Exactly what I wrote..... :S

Word by word I translated what you wrote into code.

riahc3 50 Â Team Colleague

Simplify your work. First ignore the spaces to simplify your problems.

First loop - say i - for each line so it runs from 0 to n-1
Inside this loop
{
First loop - j - goes from i to (2*i - 1) - print each j
Second loop (not nested in the j loop above) - j - goes from (2*i - 2) to i (backwards)
}

Once you get this working, add one more loop before the First loop j to add spaces.

Your instructions which result this code:

for (i=0;i<=n-1;i++)
    {
        for (j=i;j<2*i-1;j++)
        {
            printf ("%i",j);
        }
        for (j=2*i-2;j<i;j--)
        {
            printf ("%i",j);
        }
    }

Gives me a infinite loop just printing out numbers

riahc3 50 Â Team Colleague

Three loops.
Loop one -- prints a full line
Inside that loop is two loops:
Loop 1 prints the spaces before the '*'s
Loop 2 prints the '*'s

*? Im guessing you mean that Loop 1 prints the number, Loop 1 inside of Loop 1 prints the /n, and Loop 2 inside of Loop 1 prints..............what?

riahc3 50 Â Team Colleague

Hey

I wanted to know how to make a number pyramid with (for example) the following formation:

(This would be for 5 rows, with 5 being a variable and as you can see in the last row the last number is 5 on each end)

[IMG]http://img199.imageshack.us/img199/2239/numbers.png[/IMG]
http://img199.imageshack.us/img199/2239/numbers.png

So far I have this:

int j,i,n;
n=5; //Example
for (i=1;i<=n-1;i++)
    {
        printf ("%i",i);
        for (j=i;j<n;j++)
        {
         printf ("/n");
        }
        
    }

But I seem to be stuck..........I have a feeling another loop is required but I just dont seem to know how to place it correctly.

Thanks for any help :)

riahc3 50 Â Team Colleague

Hey

I was wondering how is the easiest way to send a email thru VB .NET 2005. I want to send a email every 5 minutes a certain text (that I have no problem the only problem is how to send the email with the address, server address, user name, password, etc).

Thanks

riahc3 50 Â Team Colleague

Hey

This is going to be hard to explain but oh well....


I have a form with a menu. When I hit option one, it opens another form (form2) inside that same form (mdiparent). When I hit X on form2, then try to open it again from the original form with a menu thru the menu, It says it cant access a disposed object. Here is the code:

Form1:

Public Class Form1
    Dim f As New Form2

    Private Sub arandomname(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stripMenuItem.Click
        f.MdiParent = Me
        f.Show()
    End Sub
....

Form2:
?

(The code above is just example. Dont worry about the names just the f and all that)
What do I do to fix it or make it all work?

riahc3 50 Â Team Colleague

Maybe I didnt understand someone correctly...