c# how to call functions  
Author Message
SOAC





PostPosted: Visual C# General, c# how to call functions Top

I have been converting a c++ program into c#. I am using Windows Application. I have a basic structure now for C# all through my program. Except I think I have it all wrong. The program compiles on the first pass, and on the second pass all my functions are flagged with an error.

namespace WindowsApplication1

{

using System;

using System.Windows.Forms;

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void Form1_Load(object sender, EventArgs e)

{

}

}

}

public class MainBegin{

public static int mainbeginstart

{

get

{

read_hotspace_file; <------ function

read_garage_file; <------function

display_screen2; <------function

getchh; <-------function

display_screen_data_from_database; <--function

}

}

}

public class display_screen_data_from_database{

public static char[] get_character = new char[2];

public static int cursor_position_x = 11;

public static int cursor_position_y = 2;

public static int row_of_gds = 0;

public static int main_loop = 1;

public static int ypos;

public static int getcharacterfromsip

{

get

{

display_screen2; <------function call

while (main_loop == 1){

get_character[0] = getchh;

if (get_character[0] == 'a') { get_character[0] = 'A'; goto start_up; }

if (get_character[0] == 'b') { get_character[0] = 'B'; goto start_up; }

if (get_character[0] == 'c') { get_character[0] = 'C'; goto start_up; }

if (get_character[0] == 'd') { get_character[0] = 'D'; goto start_up; }

if (get_character[0] == 'e') { get_character[0] = 'E'; goto start_up; }

if (get_character[0] == 'f') { get_character[0] = 'F'; goto start_up; }

if (get_character[0] == 'g') { get_character[0] = 'G'; goto start_up; }

if (get_character[0] == 'h') { get_character[0] = 'H'; goto start_up; }

if (get_character[0] == 'i') { get_character[0] = 'I'; goto start_up; }

if (get_character[0] == 'j') { get_character[0] = 'J'; goto start_up; }

if (get_character[0] == 'k') { get_character[0] = 'K'; goto start_up; }

if (get_character[0] == 'l') { get_character[0] = 'L'; goto start_up; }

if (get_character[0] == 'm') { get_character[0] = 'M'; goto start_up; }

if (get_character[0] == 'n') { get_character[0] = 'N'; goto start_up; }

if (get_character[0] == 'o') { get_character[0] = 'O'; goto start_up; }

if (get_character[0] == 'p') { get_character[0] = 'P'; goto start_up; }

if (get_character[0] == 'q') { get_character[0] = 'Q'; goto start_up; }

if (get_character[0] == 'r') { get_character[0] = 'R'; goto start_up; }

if (get_character[0] == 's') { get_character[0] = 'S'; goto start_up; }

if (get_character[0] == 't') { get_character[0] = 'T'; goto start_up; }

if (get_character[0] == 'u') { get_character[0] = 'U'; goto start_up; }

if (get_character[0] == 'v') { get_character[0] = 'V'; goto start_up; }

if (get_character[0] == 'w') { get_character[0] = 'W'; goto start_up; }

if (get_character[0] == 'x') { get_character[0] = 'X'; goto start_up; }

if (get_character[0] == 'y') { get_character[0] = 'Y'; goto start_up; }

if (get_character[0] == 'z') { get_character[0] = 'Z'; goto start_up; }

start_up:

if (get_character[0] == 0X00)

{

get_character[0] = getchh;

switch (get_character[0])

{

case 'H': move_cursor_up; break;

case 'P': move_cursor_down; break;

case 'M': move_cursor_right; break;

case 'K': move_cursor_left; break;

default: break;

}

goto end_input;

}

switch (get_character[0])

{

case ';': move_cursor_up(); break;

case '.': move_cursor_down(); break;

case '/': move_cursor_right(); break;

case ',': move_cursor_left(); break;

case '+': search_data(); break;

case '*': download_data(); break;

case : upload_data(); break;

case '<': exit(3); break;

default: display_screen1; break;

}

end_input:

ypos = 0;

}

}

}

}

I have no idea how to call my functions. I think i am going about this the wrong way. Any guidance would be appreciated.

here r my errors:

:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(27,13): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(27,13): error CS0118: 'read_hotspace_file' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(28,13): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(28,13): error CS0103: The name 'read_garage_file' does not exist in the current context

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(29,13): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(29,13): error CS0118: 'display_screen2' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(30,13): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(30,13): error CS0103: The name 'getchh' does not exist in the current context

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(31,13): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(31,13): error CS0118: 'display_screen_data_from_database' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(54,13): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(54,13): error CS0118: 'display_screen2' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(58,36): error CS0103: The name 'getchh' does not exist in the current context

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(91,40): error CS0103: The name 'getchh' does not exist in the current context

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(96,35): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(96,35): error CS0118: 'move_cursor_up' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(97,35): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(97,35): error CS0118: 'move_cursor_down' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(98,35): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(98,35): error CS0118: 'move_cursor_right' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(99,35): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(99,35): error CS0118: 'move_cursor_left' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(107,31): error CS0118: 'move_cursor_up' is a 'type' but is used like a 'variable'

C:\Documents and Settings\Owner\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\Form1.cs(108,31): error CS0118: 'move_cursor_down' is a 'type' but is used like a 'variable'




Visual C#14  
 
 
Sadagopan Rajaram - MSFT





PostPosted: Visual C# General, c# how to call functions Top

I have moved this to the C# forum.

At first glance, the C# syntax is not correct - see http://msdn2.microsoft.com/en-us/vcsharp/aa336793.aspx for more details

Thanks,

Sadagopan Rajaram

(VSD Development Lead)



 
 
ahmedilyas





PostPosted: Visual C# General, c# how to call functions Top

Thanks Sadagopan.

yes he is correct, the syntax is not right. Firstly you shouldnt be calling methods from a property but this is something later to argue with.

you are not calling a method but rather referencing a class. you need to make an instance of that class then call the method in that object instance of that class.

example

get

{

display_screen_data_from_database; //this is a CLASS. you need to make an instance of this class.

display_screen_data_from_database t = new display_screen_data_from_database();

t.MethodName();



 
 
SOAC





PostPosted: Visual C# General, c# how to call functions Top

I removed my functions, and wrote the code with private void. Like This:

private void Form1_Load(object sender, EventArgs e)

{

}

private void textBox1_TextChanged(object sender, EventArgs e)

{

char[] q = new char[210000];

char[] get_character = new char[2];

String headerx = "G_F_R_SSS_LICENSE_WA";

char[,] garage_array_database = new char[21, 10000];

char[,] hotspace = new char[21, 50];

int zep;

int new_position_x;

int cursor_position_x = 0;

int cursor_position_y = 0;

int cursor_position_xx;

int cursor_position_yy;

int row_of_gds = 0;

etc.

thanks.