homeryansta 36 Junior Poster in Training

Hello,

I know RIM is pretty much dead, but I need help with some development. I'm currrently developing an app that pushes data to my device.

I downloaded some code that was supposedly developed by blackberry called the Emergency Contact List.

Here is my issue: The gui isn't popping up when the app runs. I believe that the code is simple enough so that you may help me figure out this issue.

The source code can be found here: [url]http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/796557/800451/1055819...[/url]

However, here is my short version of the code just so that you can see what I'm doing.

This is the the file that contains main(). The first condition of the if statement just creates a GUI and displays it onto the screen.

[CODE=java]
/**

  • main() - controls the startup of the application...thread will start in the background
  • and the GUI starts when user clicks from main menu
    **/
    /**

    • Starts the push data listener intially
    • @param args
      */

    public static void main(String[] args) {
    if( args != null && args.length > 0) {
    ECLApplication theApp = new ECLApplication();
    theApp.enterEventDispatcher();
    }
    else {
    PushedDataListener.waitForSingleton().start();

    }

    }
    [/CODE]

Well, of course the inital argument is null and the length is certainly not greater than 0 so we invoke the static function "waitForSingleton".

[CODE=java]
/**

  • BackGround waitForSingleton() - returns an instance of a listening thread
    **/
    public static PushedDataListener waitForSingleton(){
    //make sure this is a singleton instance
    RuntimeStore store = RuntimeStore.getRuntimeStore();
    Object o = store.get(RTSID_MY_APP); ...

you're missing the parameter.

what is the question?

You might want to format your code.... it's pretty hard to read.

nvm, got it to work with double buffering :D

homeryansta 36 Junior Poster in Training

I created a piece of code that simulates a pendulum with the gravity(assuming no friction or resistance). However, it is not as smooth as I want it to be. So.. does anyone know what I can do to make it smoother?

[CODE=java]
import java.awt.;
import java.awt.event.
;
import java.lang.Math;
import java.lang.Runnable;

class gui extends Canvas
implements Runnable{
int x_not,
y_not;

gui(int width, int height){
   x_not = width/2;
   y_not = height - (height - 50);
}   //end constructor

public void paint(Graphics g) {
    double phi;

    try {
//The sleep() method is invoked on the main thread to cause a one second delay.
        Thread.currentThread().sleep(100);
} catch (InterruptedException e) {}

    phi = (Math.PI/4)*Math.sin(Math.sqrt(9.8/200)*System.currentTimeMillis()*Math.pow(10.0, 3.0));
    buildPendulum(phi, g);
    repaint();    
} //end paint method

void buildPendulum(double phi, Graphics g)
{
    //
    //  build the pendulum with respect to the angle phi
    //

    double Ax,Ay,
           Bx,By,
           Cx,Cy,
           Dx,Dy,
           Ex,Ey,
           Fx,Fy,
           Gx,Gy,
           Hx,Hy;

    Ax = x_not + 2*Math.cos(phi);
    Ay = y_not + 2*Math.sin(phi);

    g.drawLine(x_not, y_not, (int)Ax, (int)Ay);

    Bx = Ax + 200*Math.cos(phi + (Math.PI/2));
    By = Ay + 200*Math.sin(phi + (Math.PI/2));

    g.drawLine((int)Ax, (int)Ay, (int)Bx, (int)By);

    Cx = Bx + 7*Math.cos(phi);
    Cy = By + 7*Math.sin(phi);

    g.drawLine((int)Bx, (int)By, (int)Cx, (int)Cy);

    Dx = Cx + 30*Math.cos(phi + (Math.PI/2));
    Dy = Cy + 30*Math.sin(phi + (Math.PI/2));

    g.drawLine((int)Cx, (int)Cy, (int)Dx, (int)Dy);

    Ex = Dx + 20*Math.cos(phi + (Math.PI));
    Ey = Dy + 20*Math.sin(phi + (Math.PI));

    g.drawLine((int)Dx, (int)Dy, (int)Ex, (int)Ey);

    Fx = Ex + 30*Math.cos(phi - Math.PI/2);
    Fy = Ey + 30*Math.sin(phi - Math.PI/2);

    g.drawLine((int)Ex, (int)Ey, (int)Fx, (int)Fy);

    Gx = Fx + 8*Math.cos(phi);
    Gy ...

yes the content within the arrays are the exact same junk(binary) in the file when you open it up with notepad or something. BTW, the picture is a grayscale.

here are the pictures so you have an idea.
[url]http://web.stcloudstate.edu/bajulstrom/cs440/find-box/find-box-new.html[/url]

The language I'm using is C/C++. I'm not sure, but I stored the header into a separate arrays and the image(probably the rgb value) into it's own array. The image is black and white so it makes the problem simpler.

homeryansta 36 Junior Poster in Training

Greetings fellow programmers!

I'm doing a computer vision project in my AI class and am looking for some tips.

My task is to read a bitmap into memory and alter that image file and find an object within it. In my case, I'm searching for a box that appears in the picture. For simplicity, the images are only black and white (0-255).

So far, I'm able to read the file into memory and store them into an array for both the header and the image data.

My plan is to convert the data in the array(each array element is the binary representation of one pixel) into integers so I can analyze them. However, I'm not sure how to approach this.

If anyone have any idea how to accomplish this or have other ideas. Please do tell.

Thanks

I'm still having issues with this passing of a form. It is not recognizing a1 as a picture box.

[CODE=c++]
void BOARD::BOARD_CPU_TURN(VAR &objr_VAR, System::Windows::Forms::Form^ Frm)
{
//
// CPU's move
//

int intl_level = 0; //  initial level is set to 0 for root(current state)
int intl_depth = 3; //  plies we want to look ahead
int intl_alpha = -999999;   //  initial value of alpha
int intl_beta = 999999; //  initial value of beta
String^ stwl_move = "";
int intl_move;

MessageBox::Show("in cpu move mode");

intl_move = BOARD_min_alpha_beta(objr_VAR, intl_alpha, intl_beta, intl_level, intl_depth);
stwl_move += intl_move;
MessageBox::Show(stwl_move);

// cpu does random move towards opponent's den
if(intl_move == 0)
{
    srand(time(NULL));

    intl_move = rand() % 4;

    if(intl_move == 0)
    {
        Frm->a1->BackgroundImage = Image::FromFile("elephant_cpu_select.gif");
    }
    else if(intl_move == 1)
    {
        //Frm->BackgroundImage = Image::FromFile("elephant_cpu_select.gif");
    }
    else if(intl_move == 2)
    {
        //Frm->BackgroundImage = Image::FromFile("elephant_cpu_select.gif");
    }
    else
    {
        //Frm->BackgroundImage = Image::FromFile("elephant_cpu_select.gif");
    }
}

}

[/CODE]

Here is a snapshot of what's in Form1.h just to show that a1 does indeed exist and can be used if I'm passing in a1 as parameter instead of the whole form itself.

[CODE=c++]
.
.
.
.
private: System::Windows::Forms::Label^ lbl_d;
private: System::Windows::Forms::Label^ lbl_c;
private: System::Windows::Forms::Label^ lbl_b;
private: System::Windows::Forms::Label^ lbl_a;
private: System::Windows::Forms::ToolStripMenuItem^ exitToolStripMenuItem;
private: System::Windows::Forms::MenuStrip^ menuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^ fileToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^ resetToolStripMenuItem;
private: System::Windows::Forms::PictureBox^ a1;
private: System::Windows::Forms::PictureBox^ a2;
private: System::Windows::Forms::PictureBox^ a3;
private: System::Windows::Forms::PictureBox^ a4;
private: System::Windows::Forms::PictureBox^ a5;
private: System::Windows::Forms::PictureBox^ a6;
private: System::Windows::Forms::PictureBox^ a7;
private: System::Windows::Forms::PictureBox^ b7;
private: System::Windows::Forms::PictureBox^ b6;
private: System::Windows::Forms::PictureBox^ b5;
private: System::Windows::Forms::PictureBox^ b4;
private: System::Windows::Forms::PictureBox^ b3;
.
.
.
. ...

the syntax for C++ is different from vb.net and c# it looks like. As you can see from my example above, it is not the same as what we thought it was.

note that if I was passing in a picturebox instead of a form then this is the correct syntax in C++. However, I need a form to be passed in so I can extract all the picturebox from it. Let's just say that there are 42 different picture boxes that I need to bring in. As you can tell... that is alot of parameter if I were to bring in all of them. Hence the reason why I need the form to be passed in instead.

[CODE=c++]
void BOARD_Unselect_All(System::Windows::Forms::PictureBox^ a1)

{

a1->BackgroundImage = Image::FromFile("elephant_pla.gif");

}
[/CODE]

it doesn't work....

that is the correct syntax for vb.net which I know pretty well since I interned over the summer for a company that utilizes it. From my understanding, the keyword "this" works in the form itself through the event handlers and other functions, so it will not work when passed into a function of another class. And believe me, I've tried searching and searching, but cannot find anything.

However, from the form, this is how the item passed in looks like.

[CODE=c++]
BOARD.BOARD_Unselect_All(this);
[/CODE]

where board is the object name and "this" referring to the form itself since it is being passed into BOARD from there.

yeah, the click event handler is taken care of. This is just setting the background image which shouldn't have to be done in the event handler. I just need to know how to access that picturebox so I can change it's image, this must be done through a parameter like this because of the situation I'm in with the program.

come on, someone's gotta know the answer.

homeryansta 36 Junior Poster in Training

[CODE=cpp]void BOARD_Unselect_All(System::Windows::Forms::Form^ Frm)
{
Frm.a1->BackgroundImage = Image::FromFile("elephant_pla.gif");
}[/CODE]

a1 is a picturebox from the form. How do you use the buttons, picturebox, etc from the form being passed in?

homeryansta 36 Junior Poster in Training

I'm currently converting an application that utilize sqldmo which has a feature .script that can just magically retrieve a script for a particular index for me. Is there a query I can write or a already built in stored procedure I can use to do similar things? Any help would be greatly appreciated.

thanks,

Homer

thank you!

homeryansta 36 Junior Poster in Training

as the title states. Is there a way to determine if both datatypes are the same?

[QUOTE=tesuji;1249112]Sorry, this has been my mistake, I thought we were talking about mysql.
MS sql server has much more comprehensive system tables. You can get a good impression by downloading one of those great [URL="http://www.kronester.com/?p=514"]posters[/URL] (such an originally colored poster of sql server 2008 is pinned on a wall in my office)

For example table sys.foreign_key_columns contains all foreign keys of a database..

-- tesu[/QUOTE]

Thank you for your time and posts. I didn't fully understand what I was doing, but my real question is, How do you count the number of rows with constraints in a table. However, I've figured out a way to do that.

[QUOTE=tesuji;1249037]I see, all information on them can be found in MySQL's Information-schema tables (system tables, cataloge), for example, information on primary keys, foreign keys etc. is in table_constraints table.[CODE]select * from table_constraints;[/CODE]Enough privileges?

-- tesu[/QUOTE]
Msg 208, Level 16, State 1, Line 1
Invalid object name 'table_constraints'.

forgot to mention, I'm using MS-SQL 2008

[QUOTE=tesuji;1248479]Well, primary key, foreign key, not null, unique, check clause, also sometimes triggers
etc. are or may define constraints. So which of them are meant?

-- tesu[/QUOTE]
Every single one of them.

homeryansta 36 Junior Poster in Training

hello all! Anyone know how to count all the constraints in a given table? I'm new to stored procedure and need it to finish some work.

and also, is it possible to pass the progress bar as a function parameter?

homeryansta 36 Junior Poster in Training

can I have 2 form share the same progress bar? If so how does this work?

[QUOTE=wildgoose;957324]What were the rules your teacher gave you?
Which flavor of MIPS are you using?

There are scalar and vector square root functions and estimated reciprocal square root vector functions, dependent upon which MIPS family chipset you're using!

There are also algorithmic guesstimation formulas for integer only processors.[/QUOTE]

there are different MIPS?

here is the program i'm working on. hopefully you can determine what flavor it is by looking at it because I'm clueless.

[CODE]

stuck, cannot figure out square root
.text
.globl __start

__start:

la $a0, prompt      #print the directions to screen
li $v0,4

    la      $a0,prompt          # prompt user for a
    li      $v0,4               # print string
    syscall

    li      $v0,6               # read single
    syscall                     # x stored to f0

mov.s  $f2,$f0

la      $a0,prompt2         # prompt user for b
    li      $v0,4               # print string
    syscall

    li      $v0,6               # read single
    syscall 

    # evaluate a and b to get c

    mul.s   $f2,$f2,$f2         # square a

    mul.s   $f0,$f0,$f0         # square b

add.s   $f2,$f2,$f0     # add a^2 and b^2

    # print the result
    mov.s   $f12,$f2            # $f12 = argument

li      $v0,2               # print single
    syscall

    la      $a0,newl            # new line
    li      $v0,4               # print string
    syscall

    li      $v0,10              # code 10 == exit
    syscall                     # Return
Data Segment
    .data

pi: .float 3.14
degree: .float 180.0

prompt: .asciiz "Enter a: "
prompt2:.asciiz "Enter b: "
blank: .asciiz " "
newl: .asciiz "\n"

[/CODE]

newton's method means i have to use derivative.... according to that formula.

homeryansta 36 Junior Poster in Training

I've been working on this for hours! the code makes perfect sense, but wont' work!!! aaah! about to pull my hair out.

the code is suppose to do get the sum of this

1/1 + 1/2 + ..... + 1/n

I blocked all the codes and just print out the v0 value in float form, but it's the same problem so I'm assuming its coming from the conversion. But I followed the codes closely, shouldn't be any errors.

[CODE]
.text
.globl __start

__start:

la $a0, prompt      #print the directions to screen
li $v0,4

    # Register Use Chart
    # $f0 --- x
    # $f2 --- sum of terms

    la      $a0,prompt          # prompt user for v0
    li      $v0,4               # print string
    syscall

    li      $v0,5              # read single
    syscall                     # input stored to v0

li  $t0,1       #assign 1 to t0
l.s  $f2,1      #assign 1 to f2
l.s  $f10,0     #assign 0 to f10

do:

#NOTE
#f2 is the number 1
#f4 is the float value of the input integer
#f6 is the value after the division operation
#f10 is the sum of all the added values

mtc1 $v0, $f4       #
cvt.s.w $f4, $f4    #convert from int to float

div.s $f6,$f2,$f4   #divide 1/n and store in f6

add.s $f10, $f10, $f6   #add f6 to the sum(initial 0)

sub $v0,$v0,$t0     #n-1

beq $v0,0,next      #if n==0 go to next
    bne $v0,0,do    #if n!=0 go to do

next:

    #print the result
    mov.s   $f12,$f10            # move sum to f12 register

li      $v0,2               # print single
    syscall

    la      $a0,newl            # ...

[QUOTE=Salem;956048]> the only ones I came upon requires me to split the number being rooted by 2's. Not possible.
Are there more restrictions on the answer that you're not telling us?

What does "split the number by 2" mean anyway - divide?[/QUOTE]

the instruction just says, find the hypotenuse of 2 user input leg of a right triangle. the 2 input are floating points.

not divide by 2 but separate the digits into 2.

example: if the number I want to root is 96358

9, 63, 58 is what i split it into.