if then and select case statement not working VB.Net

Apr 28, 2011 at 8:58 AM

Hi All

 

I've been trying to get either an If then or a Select Case statement working to check what the user has entered with a console.readline , I can echo back what has been entered but I cannot implement anything to check if a particular word has been enetered ,and i keep getting this error when compiling the shell

 

Error    1    Plug needed. System.Int32  System.Globalization.CompareInfo.InternalCompareString(System.IntPtr, System.String, System.String, System.Int32, System.Int32, System.String, System.Int32, System.Int32, System.Int32)
   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 663
   at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 779
   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 284
   at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Data\Sources\Cosmos\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 239    C:\Program Files\MSBuild\Cosmos\Cosmos.targets    32    10    SDOS

 

This worked in VS2008 but moving over to VS2010 this now does not work with the latest Cosmos User Kit, any idea's people

Coordinator
Apr 28, 2011 at 9:03 AM
It's because string comparison is not completely functional in cosmos.. Are you able to use multiple if statements for now?



On Thu, Apr 28, 2011 at 10:58 AM, steveoneill <notifications@codeplex.com> wrote:

From: steveoneill

Hi All

I've been trying to get either an If then or a Select Case statement working to check what the user has entered with a console.readline , I can echo back what has been entered but I cannot implement anything to check if a particular word has been enetered ,and i keep getting this error when compiling the shell

Error 1 Plug needed. System.Int32 System.Globalization.CompareInfo.InternalCompareString(System.IntPtr, System.String, System.String, System.Int32, System.Int32, System.String, System.Int32, System.Int32, System.Int32)
at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 663
at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 779
at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 284
at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Data\Sources\Cosmos\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 239 C:\Program Files\MSBuild\Cosmos\Cosmos.targets 32 10 SDOS

This worked in VS2008 but moving over to VS2010 this now does not work with the latest Cosmos User Kit, any idea's people

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 28, 2011 at 9:11 AM
Edited Apr 28, 2011 at 9:12 AM

Hi Mterwood

 

I've tried the following in VB.Net

 

Dim strcommand As String = Console.ReadLine

If strcommand = "mem" Then Console.WriteLine("Hello")

 

and

 

            Dim strcommand As String = Console.ReadLine

            Select Case strcommand

                Case "mem"

                    Console.WriteLine("Hello")



            End Select

 

both produce the same error

 

Funny thing is both of these worked in VS2008 with CosmosUserKit5 (Milestone 5), but my friend is doing more or less the same in C# and he has no problems, is this a problem with the compiler for VB.Net code??

Coordinator
Apr 28, 2011 at 9:16 AM
the c# compiler converts a small number of case statements to a series of if value == value2 like statements, and then switches to List<T> (which then doesn't work). Have a look using a tool like reflector or ILSpy and see what c# code gets generated for your vb.net code.. (and also look at the il, which is what we compile)


On Thu, Apr 28, 2011 at 11:11 AM, steveoneill <notifications@codeplex.com> wrote:

From: steveoneill

Hi Mterwood

I've tried the following in VB.Net

Dim strcommand As String = Console.ReadLine

If strcommand = "mem" Then Console.WriteLine("Hello")

and

Dim strcommand As String = Console.ReadLine

Select Case strcommand

Case "mem"

Console.WriteLine("Hello")



End Select

Funny thing is both of these worked in VS2008 with CosmosUserKit5 (Milestone 5), but my friend is doing more or less the same in C# and he has no problems, is this a problem with the compiler for VB.Net code??

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 28, 2011 at 9:30 AM

ok, used ILSpy and found this for the case statement

 

{
    string text = Console.ReadLine();
    string left = text;
    if (Operators.CompareString(left, "mem", false) == 0)
    {
        Console.WriteLine("Hello");
    }
}

 


Coordinator
Apr 28, 2011 at 9:34 AM
ok, so vb.net translates it differently than c#....

Can't you just learn c#? </just-kidding>

Please replace with if then else if statements for now...


On Thu, Apr 28, 2011 at 11:30 AM, steveoneill <notifications@codeplex.com> wrote:

From: steveoneill

ok, used ILSpy and found this for the case statement

{
string text = Console.ReadLine();
string left = text;
if (Operators.CompareString(left, "mem", false) == 0)
{
Console.WriteLine("Hello");
}
}


Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 28, 2011 at 9:44 AM

nope, if else statements produce the same issue.

Coordinator
Apr 28, 2011 at 9:46 AM
Lets try some alternatives:

If yourvalue.Equals("value") Then

.....
End If

On Thu, Apr 28, 2011 at 11:44 AM, steveoneill <notifications@codeplex.com> wrote:

From: steveoneill

nope, if else statements produce the same issue.

Read the full discussion online.

To add a post to this discussion, reply to this email (Cosmos@discussions.codeplex.com)

To start a new discussion for this project, email Cosmos@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Apr 28, 2011 at 9:51 AM

i've found a workaround, simple but effective

 

 Dim strcommand As String = Console.ReadLine
            If strcommand.Contains("mem") And strcommand.Length = 3 Then

                Console.WriteLine("hello")


            End If

 

this seems to work with no problems and compiles with no errors, so i'll try a few more and see how I go.

 

Thanks for your help, much appreciated