Compile Error on Final Arrays Project
I'm sure this is an elementary problem, but I'm relatively new to Java. Can someone glance at this code for any apparent errors. I'm pretty sure the fillArrays() method and average() method are correct. I've tried everything, and there's no one I can ask. Any help would be greatly appreciated. This program is the final project of my java programming intro class.
Thanks
import ann.easyio.*;
public class DoubleArrayOps
public static double[] subArray(double data[], int start, int stop)
double newData[] = new double[stop-start+1];
int storeAt = 0;
for (int i = start; i<= stop; i++)
newData[storeAt++] = data;
return newData;
public static void printArray(Screen out, double data[])
for (int i = 0; i< data.length; i++)
out.print(data[i] + " ");
public double average(double [] scoreArr)
int numValues = scoreArr.length;
double sum = 0.0;
for(int i = 0; i < numValues; i++)
sum += scoreArr[i];
if(numValues > 0)
return (sum / numValues);
else
System.err.println();
return 0.0;
public double standardDev(double [] scoreArr)
int numValues = scoreArr.length;
if(numValues > 0)
double avg = average(scoreArr);
double sumSqrTerms = 0.0;
double term;
for(int i = 0; i < numValues; i++)
term = (scoreArr[i] - avg);
Math.pow(term,2) += sumSqrTerms;//Compile error.
return(Math.sqrt(sumSqrTerms / numValues));
else
System.err.println();
return 0.0;
import ann.easyio.*;
import hoj.*;
class Grades extends Object
static Screen theScreen = new Screen();
static Keyboard theKeyboard = new Keyboard();
public static void main(String args[])
String [] nameArr;
double [] scoreArr = new double [1000];
double scores = fillArrays( nameArr, scoreArr);
scoreArr = DoubleArrayOps.subArray(scoreArr, 0, scores-1);
theScreen.print( "\nMean score: "
+ DoubleArrayOps.average(scoreArr)
+ "\n"
+ "Std. Dev: "
+ DoubleArrayOps.standardDev(scoreArr)
+"\n");
char [] gradeArr;
gradeArr = computeLetterGrades(scoreArr);
displayArrays( nameArr, scoreArr, gradeArr);
public static double fillArrays(String [] nameArr, double [] scoreArr)
int n = 0;
String name;
double score;
while(true)
Keyboard theKeyboard = new Keyboard();
theScreen.print("\nPlease enter students name: ");
name = theKeyboard.readWord();
if (name.equals("done"))
break;
nameArr[n]=name;
score = theKeyboard.readDouble();
scoreArr[n]=score;
n += 1;
return n;
public static char computeLetterGrades(double [] scoreArr)
int numValues = scoreArr.length;
char [] gradeArr = scoreArr.length;
if(numValues > 0)
double avg = average(scoreArr);
double sDev = standardDeviation(scoreArr);
double F_CUT_OFF = (avg - 1.5 * standardDev);
double D_CUT_OFF = (avg - 0.5 * standardDev);
double C_CUT_OFF = (avg + 0.5 * standardDev);
double B_CUT_OFF = (avg + 1.5 * standardDev);
for(int i = 0; i < numValues; i++)
if(scoreArr < F_CUT_OFF)
return gradeArr['F'];
else if(scoreArr < D_CUT_OFF)
return gradeArr['D'];
else if(scoreArr < C_CUT_OFF)
return gradeArr['C'];
else if(scoreArr < B_CUT_OFF)
return gradeArr['B'];
else
return gradeArr['A'];
return gradeArr[];
public static double displayArrays(String [] nameArr, double [] scoreArr, char [] gradeArr)
Screen theScreen = new Screen();
theScreen.print(+ Grades.fillArrays(nameArr,scoreArr)
+ Grades.computeLetterGrades(gradeArr);
All my errors are compile errors. Here are the errors I get, and I've tried everything I know with null results. :) Thanks for the responses!
Grades.java:115: 'class' or 'interface' expected
public static char computeLetterGrades(double [] scoreArr)
^
Grades.java:31: subArray(double[],int,int) in DoubleArrayOps cannot be applied to (double[],int,double)
scoreArr = DoubleArrayOps.subArray(scoreArr, 0, scores-1);
^
Grades.java:34: non-static method average(double[]) cannot be referenced from a static context
+ DoubleArrayOps.average(scoreArr)
^
Grades.java:37: non-static method standardDev(double[]) cannot be referenced from a static context
+ DoubleArrayOps.standardDev(scoreArr)
^
Grades.java:42: cannot resolve symbol
symbol : method computeLetterGrades (double[])
location: class Grades
gradeArr = computeLetterGrades(scoreArr);
^
Grades.java:44: cannot resolve symbol
symbol : method displayArrays (java.lang.String[],double[],char[])
location: class Grades
displayArrays( nameArr, scoreArr, gradeArr);
^
DoubleArrayOps.java:69: unexpected type
required: variable
found : value
Math.pow(term,2) += sumSqrTerms;//Compile error.
Similar Messages
-
TRIM() not found? Compile error: Can't find project or library in Excel 2007
I am preparing to make a few alterations to a spreadsheet that another person built. I have NOT made any changes to it yet.
They put in a button that allows portions of the worksheet to print. I am now using Excel 2007. Their code ran fine in 2003.
The button had worked in Excel 2003- but now (without any changes) throws an error "Compile Error: Cant find project or library."
TRIM is highlighted in the following code: (See below for the whole sub)
If Trim(Worksheets("Measurements").Cells(RowCounter, ColumnCounter).Value) <> "" Then
If RowCounter > PrintRowMarker Then
PrintRowMarker = RowCounter
End If
If ColumnCounter > PrintColumnMarker Then
PrintColumnMarker = ColumnCounter + 1
End If
End If
I have added in the following references into Excel via the big button in the upper left and the "Excel Options" screens:
Analysis Toolpak and Analysis Toolpak-VBA. The sheet "Measurements" is present.
1) Are these the right packages for the TRIM function?
2) Is there a different Add-in that is needed?
3) Is there an additional step I must use to actually add in these packages?
4) Is there something else I should do?
Thanks-
Loralee
P.S. Access 2003 finds (it's version of) TRIM fine- so a version is on the machine. This spreadsheet if failing in the same way on 2 machines- both with Office 2007 installed.
Private Sub BtnPrint_Click()
Dim RowStarter As Integer 'Where to start checking rows for content
Dim RowCounter As Integer 'The current row being checked
Dim ColumnCounter As Integer 'The current column being checked
Dim PrintRowMarker As Long 'The last row with data
Dim PrintColumnMarker As Long 'The last column with data
Dim NoMoreData As Boolean 'Look for a blank record
Dim RangeValue As String 'Define the range string value
Dim EndRangeValue As String
PrintColumnMarker = 0
PrintRowMarker = 0 'Initialize the row printing marker
RowStarter = 5 'Print Starting Point
For RowCounter = 2005 To RowStarter Step -1
For ColumnCounter = 50 To 2 Step -1
If Trim(Worksheets("Measurements").Cells(RowCounter, ColumnCounter).Value) <> "" Then
If RowCounter > PrintRowMarker Then
PrintRowMarker = RowCounter
End If
If ColumnCounter > PrintColumnMarker Then
PrintColumnMarker = ColumnCounter + 1
End If
End If
Next ColumnCounter
If PrintRowMarker > 0 Then
End If
Next RowCounter
EndRangeValue = IndexToString(PrintRowMarker, PrintColumnMarker)
RangeValue = "$A$1:" & EndRangeValue
Worksheets("Measurements").PageSetup.PrintArea = RangeValue
Worksheets("Measurements").PageSetup.PrintGridlines = True 'Turn on gridlines
Worksheets("Measurements").PrintPreview 'PRINT THAT PUPPY!
End SubAppears OK to me but the error message " Cant find project or library." suggests it could possibly be the references in VBA.
In VBA select menu item Tools - References.
Ensure that the following are checked:-
Visual Basic for Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library
It there are any references displayed as Missing then scroll down to find the equivalent reference and check it and then uncheck the Missing one/s.
Regards, OssieMac -
CRVS2010 Beta - Compiler Error Message: BC32206:
Compiler Error Message: BC32206: The project currently contains references to more than one version of CrystalDecisions.Web, a direct reference to version 12.0.2000.0 and an indirect reference (through 'StarPDM2.PDMSpecCrystal.CrystalReportViewer1') to version 14.0.2000.0. Change the direct reference to use version 14.0.2000.0 (or higher) of CrystalDecisions.Web
I put the lines in the web.config as stated in the notes.
thanks
KenMandeep,
Have you got any solution for this as I am also facing the same issue.
Server Error in '/applicationnameqa' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1705: Assembly 'applicationname.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'CrystalDecisions.CrystalReports.Engine, Version=14.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' which has a higher version than referenced assembly 'CrystalDecisions.CrystalReports.Engine, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'
Source Error:
[No relevant source lines]
Source File: Line: 0
Show Detailed Compiler Output:
c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\assembly\dl3\7d95d4c9\041adbd0_2e72ca01\applicationname.Splitter.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.InfoStore\12.0.1100.0__692fbea5521e1304\CrystalDecisions.Enterprise.InfoStore.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.Build.Framework\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.WebForms\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.WebForms.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.ReportSource\12.0.2000.0__692fbea5521e1304\CrystalDecisions.ReportSource.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\Microsoft.ReportViewer.Common\10.0.0.0__b03f5f7f11d50a3a\Microsoft.ReportViewer.Common.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC\CrystalDecisions.ReportAppServer.DataDefModel\12.0.1100.0__692fbea5521e1304\CrystalDecisions.ReportAppServer.DataDefModel.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\App_Code.whwoj_l1.dll" /R:"C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Framework\12.0.1100.0__692fbea5521e1304\CrystalDecisions.Enterprise.Framework.dll" /R:"C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Viewing.ReportSource\12.0.1100.0__692fbea5521e1304\CrystalDecisions.Enterprise.Viewing.ReportSource.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Desktop.Report\12.0.1100.0__692fbea5521e1304\CrystalDecisions.Enterprise.Desktop.Report.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Web.Entity.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.Shared\12.0.2000.0__692fbea5521e1304\CrystalDecisions.Shared.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\WINDOWS\assembly\GAC\CrystalDecisions.ReportAppServer.Controllers\12.0.1100.0__692fbea5521e1304\CrystalDecisions.ReportAppServer.Controllers.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\WINDOWS\assembly\GAC\CrystalDecisions.ReportAppServer.ClientDoc\12.0.1100.0__692fbea5521e1304\CrystalDecisions.ReportAppServer.ClientDoc.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Management\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Management.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\assembly\dl3\c350966a\d484edb6_cf17cb01\applicationname.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.Web\12.0.2000.0__692fbea5521e1304\CrystalDecisions.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Entity.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\12.0.2000.0__692fbea5521e1304\CrystalDecisions.CrystalReports.Engine.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\App_Web_reportviewertest.aspx.cdcab7d2.rqat3bqm.dll" /D:DEBUG /debug+ /optimize- /win32res:"C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\wrr15z3d.res" /w:4 /nowarn:1659;1699;1701 /warnaserror- "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\App_Web_reportviewertest.aspx.cdcab7d2.rqat3bqm.0.cs" "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\App_Web_reportviewertest.aspx.cdcab7d2.rqat3bqm.1.cs"
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\applicationnameqa\ce84c14c\a620f1ad\assembly\dl3\c350966a\d484edb6_cf17cb01\applicationname.Web.DLL: error CS1705: Assembly 'applicationname.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'CrystalDecisions.CrystalReports.Engine, Version=14.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' which has a higher version than referenced assembly 'CrystalDecisions.CrystalReports.Engine, Version=12.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304'
c:\WINDOWS\assembly\GAC_MSIL\CrystalDecisions.CrystalReports.Engine\12.0.2000.0__692fbea5521e1304\CrystalDecisions.CrystalReports.Engine.dll: (Location of symbol related to previous error)
Thank you
Hrushikesh Patel
Edited by: Hrushikesh Patel on Jun 30, 2010 8:43 AM -
Upgrade from 6.40 - 7.10, Analyzer giving compile errors
We are testing out an upgrade to SAP GUI 7.10 (SP 9, V7100.2.9.1039), BEx (SP7 P1 R1352).
When running queries in the Analyzer, we get the following error "Compile Error: Can't find project or library" and the VB editor pops up to the following VB code:
Public Function BEx() As BExApplication
Set BEx = Application.Run("BExAnalyzer.xla!GetBEx")
End Function
I can shut down the debugger and the results are available but the VB windows continually pops up when any modifications are made to the report.
The following shows up in the trace although I'm not sure if it is related:
* Trace Started as: 10/10/2008 10:11:17 AM*
ListSeparator: ,
ExcelVersion: 11.0
AddinVersion: 7100.3.701.1352
BExCheckFrontend.CheckFrontend: No Check performed (20081003) 0
Errors while executing the 7.0 exit : SAPBEXonRefresh
-2146788248
Exception from HRESULT: 0x800A9C68
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at com.sap.bi.et.analyzer.addin.BExItemGrid.CallExitSAPBEXonrefresh()
-------------------10/10/2008 10:20:39 AM-------------------
System.Runtime.InteropServices.COMException (0x800A9C68): Exception from HRESULT: 0x800A9C68
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at com.sap.bi.et.analyzer.addin.BExConnect.FindLF(Object& iRange, Object& eRange)
Exception from HRESULT: 0x800A9C68
at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at com.sap.bi.et.analyzer.addin.BExConnect.FindLF(Object& iRange, Object& eRange)
Any debug ideas or suggestions would be appreciated.
ThanksHi Adam,
Can you please check that the following settings are correct in Excel.
1. Make the following setting in Excel:
o Tools
o Macros
o Security
o Trusted Sources
o [x] Trust Access to Visual Basic Visual Basic Projects (CheckBox))
Also ensure that the default macro security setting is set to "Low".
Let me know how you go.
Cheers
Shaun -
Compile error on .class for an array.
How do I write the code below correctly?
final ArgumentCaptor<MessageToken[]> tokenArg = ArgumentCaptor.forClass(MessageToken[].class);How do I write the code below correctly?
final ArgumentCaptor<MessageToken[]> tokenArg = ArgumentCaptor.forClass(MessageToken[].class);
What is the exact compilation error?
Note that since ArgumentCaptor is probably a custom class that only you or your team knows about, we will maybe not be able to help a lot, we will probably need that you give us the signature of its method forClass
Note that the problem is not that the syntaxfor the array class MessageToken[].class is illegal in itself; the following compiles perfectly:
public class TestClassLitteral {
Class stringClass = String.class;
Class stringArrayClass = String[].class;
} -
Hello experts,
I'm totally new to C#. I'm trying to modify existing code to automatically rename a file if exists. I found a solution online as follows:
string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
string tempFileName = fileName;
int count = 1;
while (allFiles.Contains(tempFileName ))
tempFileName = String.Format("{0} ({1})", fileName, count++);
output = Path.Combine(folderPath, tempFileName );
string fullPath=output + ".xml";
However, it gives the following compilation errors
for the Select and Contain methods respectively.:
'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found
(are you missing a using directive or an assembly reference?)
'System.Array' does not contain a definition for 'Contains' and no extension method 'Contains' accepting a first argument of type 'System.Array' could be
found (are you missing a using directive or an assembly reference?)
I googled on these errors, and people suggested to add using System.Linq;
I did, but the errors persist.
Any help and information is greatly appreciated.
P. S. Here are the using clauses I have:
using System;
using System.Data;
using System.Windows.Forms;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Linq;Besides your issue with System.Core, you also have a problem with the logic of our code, particularly your variables. It is confusing what your variables represent. You have an infinite loop, so the last section of code is never reached. Take a look
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace consAppFileManipulation
class Program
static void Main(string[] args)
string fullPath = @"c:\temp\trace.log";
string folderPath = @"c:\temp\";
string fileName = "trace.log";
string output = "";
string fileNameOnly = Path.GetFileNameWithoutExtension(fullPath);
string extension = Path.GetExtension(fullPath);
string path = Path.GetDirectoryName(fullPath);
string newFullPath = fullPath;
string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
string tempFileName = fileName;
int count = 1;
//THIS IS AN INFINITE LOOP
while (allFiles.Contains(fileNameOnly))
tempFileName = String.Format("{0} ({1})", fileName, count++);
//THIS CODE IS NEVER REACHED
output = Path.Combine(folderPath, tempFileName);
fullPath = output + ".xml";
//string fullPath = output + ".xml";
UML, then code -
How do I add an included jsp to my project and not get a compile error?
Hi,
I have a project with some included jsp's however if I add them to the project, when I build I get a compile error as the jsp uses variables from the calling jsp.
Any ideas on how to get round this.
Thanks
DMThere are two main ways that I deal with this problem (yeah, it sucks, but it sort of makes sense that it happens...) (I presume you're talking static include here...)
#1 - name the included file with an extension that JDev will not try to compile (.jspf - for JSP Fragment - is common) Then it will be compiled in with the including page, but won't gag the project compilation. Advantage - it works, and you find out at compile time if you hosed up the variable reference. Disadvantage: JDev tries really, really, really hard to keep you from naming a JSP file with an extension of .jspf I normally create the .jsp file in JDev, remove it from the project, rename the file outside of JDeveloper, then add it back to the project - pain in the butt, but it works (and you probably aren't building scads of these included files...)
#2 - add the variable to be referenced to the pageContext implicit object as an attribute in your including page (ex, <% pageContext.setAttribute("myVar", myVar); %>), then reference that attribute in your included JSP (ex, <%= pageContext.getAttribute("myVar") %>) . It will compile fine (as the compiler has no way of knowing if the pageContext attribute actually exists, it just sees that the syntax is good and motors along merrily. Advantage: don't have to have differently named JSP files (which isn't actually a big deal). Disadvantage: You hvae to add the variable to the pageContext (and you have to always add Object derivatives, as primitives won't go into a hash) and you don't find out if you screwed the variable up until runtime (when it tries the getAttribute, which could return null if you didn't properly set it to start with) vs at compile-time w/ the direct reference.
HTH!
Jim -
I have imported a project to Encore and while it worked the first time, this time I get an error in the check project winder of can't execute chapter 2 end action because of final end marker? I have two different sections that have buttons on the menu. When you get to the end of the first sequence I need it to go back to the menu and it is saying that it can't because of the end action on the final marker.
The 'unable to locate' message means that you don't have those music files on that computer, or that they are not where iTunes is expecting them to be. How did you get the entries for those tracks in your new computer's iTunes ?
If you still have your old computer then you can try copying them over again : http://support.apple.com/kb/HT4527
You may also be able to re-download them from the store (checking for available downloads only checks for items that have not yet been downloaded, not for past purchases) via the Purchased link under Quick Links on the right-hand side of the iTunes store home page (re-downloading music isn't possible in all countries). You may need to delete them form your library first (where you are getting the 'unable to locate' message), otherwise iTunes will assume that you still have them somewhere and won't let you re-download them.
Re-downloading : http://support.apple.com/kb/HT2519 -
Revision: 5915<br />Author: [email protected]<br />Date: 2009-04-03 14:17:15 -0700 (Fri, 03 Apr 2009)<br /><br />Log Message:<br />-----------<br />Fixed compilation errors in the flex4test dev project by changing <mx:String> to <fx:String>.<br /><br />QE Notes: None<br />Doc Notes: None<br />Bugs: None<br />Reviewer: N/A<br /><br />Modified Paths:<br />--------------<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/NewEffects.mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/RemoveItemsTest.mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/SkinTest.mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/components/AnimationPropertiesForm. mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/flex4test.mxml
Revision: 5915<br />Author: [email protected]<br />Date: 2009-04-03 14:17:15 -0700 (Fri, 03 Apr 2009)<br /><br />Log Message:<br />-----------<br />Fixed compilation errors in the flex4test dev project by changing <mx:String> to <fx:String>.<br /><br />QE Notes: None<br />Doc Notes: None<br />Bugs: None<br />Reviewer: N/A<br /><br />Modified Paths:<br />--------------<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/NewEffects.mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/RemoveItemsTest.mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/SkinTest.mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/components/AnimationPropertiesForm. mxml<br /> flex/sdk/trunk/development/eclipse/flex/flex4test/src/flex4test.mxml
-
I am having some problems finalizing the project, it says error code -108. I read some tips but i couldn't figure out what AppleMan1958 suggested ,can anyone help me with this problem? thank you
Oh ok, well that was what the test said prior to reformatting the hard drive. Now, it doesn't find any trouble no matter how many times I run it. That's what has me so confused, everything seems to check out and yet...I can't do anything, not even install the software!
-
I tried to compile large project (~4,000 classes) using extenal "javac" compiler and 1.4.2 JDK. When I "clean the project" and then run "make" the follwoing error frequently ocures. Once it fails it's true both for entire project and if I try to compile a single class not depending on anything else. This makes me to beleive that the problem is not related to any particular class (also see notes below, looks like "javac" process doesn't even start).
Compiling...
Internal compilation error, terminated with a fatal exception
It doesn't happen if I use "rebuild" function instead of "make". It doesn't happen always but most of the times. I tried different versions of 1.4.2 (02,03,04) and don't see any specific pattern.
Also looks like once I "rebuild" the project, "make" runs ok.
I run Task Monitor and here is what I found out:
- CPU maxs out at 100% for about 10 - 15 % and then the error is reported;
- Error is reported before "javac" process is started;
- There is plenty of memory available. I have 1 G with 640 set as max for JDeveloper, but it doesn't exceed 400 MB.
I compiled a smaller project (~1,000 files) and didn't have this problem.
I wont' be able to send the sorce code but I can send project files if it helps.
Is there any logging I could enable to get more information? Did anybody reported anything similar? Is there any configuration parameters I can play with?
Thanks in advance,
Noel.I run JDev using jdev.exe and here is a stack I got in console window. Any ideas?
java.lang.IndexOutOfBoundsException
at oracle.jdeveloper.compiler.InputReadTextBuffer.getString(InputReadTex
tBuffer.java:109)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer1b.set_com
ment_value(ParserLayer1b.java:324)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer1b.handleO
neComment(ParserLayer1b.java:422)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer1b.skipTok
en(ParserLayer1b.java:486)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer1a.nextTok
en(ParserLayer1a.java:241)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer5.ty_body_
rhs(ParserLayer5.java:825)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer5.ty_body(
ParserLayer5.java:774)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer5.ty_d(Par
serLayer5.java:998)
at oracle.javatools.parser.java.v2.internal.parser.ParserLayer5.compilat
ion_unit(ParserLayer5.java:1097)
at oracle.javatools.parser.java.v2.internal.parser.ParserDriver.parse(Pa
rserDriver.java:37)
at oracle.javatools.parser.java.v2.JavaParser.parse(JavaParser.java:85)
at oracle.javatools.parser.java.v2.JavaParser.parse(JavaParser.java:71)
at oracle.jdeveloper.compiler.DependencyProvider.updateData(DependencyPr
ovider.java:440)
at oracle.jdeveloper.compiler.Ojc.checkDependencies(Ojc.java:1147)
at oracle.jdeveloper.compiler.Ojc.translate(Ojc.java:1197)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildGrap
h(UnifiedBuildSystem.java:299)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildProj
ectFiles(UnifiedBuildSystem.java:514)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.buildAll(
UnifiedBuildSystem.java:714)
at oracle.jdeveloper.compiler.UnifiedBuildSystem$CompileThread.run(Unifi
edBuildSystem.java:884) -
Revision: 14107
Revision: 14107
Author: [email protected]
Date: 2010-02-10 11:36:11 -0800 (Wed, 10 Feb 2010)
Log Message:
Fixing compile error in NetMocker, Metrics provider changed in the OSMF project.
Modified Paths:
osmf/trunk/libs/adobe/NetMocker/org/osmf/netmocker/MockMetricsProvider.asHi,
You are the first person I have read so far on this forum who does not use Flex or Flash builder. I will check out FlashDevelop. It is good information to know. Thanks a lot!
-Wei Zhang
Senior Computer Scientist
Adobe Systems, Inc.
[email protected] -
Hi, a "General error"appears on my Final Cut Project when I try to save it. I read in this Community that the solution could be save on the desktop. It works, but how could I solve it in my External HD?
Is the external formatted to Mac OS Extended?
Right click the external icon on the Desktop and select Get Info.
This will tell you the current format.
Al -
Hello,
I am getting error messages when I compile a Visual C++ 2010 project that includes the Atlcomcli.h file.
The error messages are:
Error 1 error C2338: CVarTypeInfo< char > cannot be compiled with /J or _CHAR_UNSIGNED flag enabled c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\atlcomcli.h
Search and found link to download hotfix KB982517. But no download available.
https://connect.microsoft.com/VisualStudio/feedback/details/613888/i-would-like-to-receive-hotfix-kb982517-or-make-this-available-in-the-downloads-section
Please help me to resolve this issue.
Thanks,
GaganI would have to ask: why are you using _CHAR_UNSIGNED? Is this really necessary? I have to admit that the fact that by default char in C++ is signed is an annoying fact, but most of us have just gotten used to it.
Have you tried the workaround
#pragma push_macro("ATLSTATIC_ASSERT")
#undef ATLSTATIC_ASSERT
#define ATLSTATIC_ASSERT(x,y)
#include <atlcomcli.h>
#undef ATLSTATIC_ASSERT
#pragma pop_macro("ATLSTATIC_ASSERT")
that is described in the link
https://support.microsoft.com/kb/982517?wa=wsignin1.0
David Wilkinson | Visual C++ MVP -
Why dont we get a compilation error for converting a collection into array?
Why don't we get a compilation error but get a runtime error while explicit casting of Object[] into a String[]?
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class SampleMap {
public static void main(String[] args) {
Map<Integer, String> temp = new HashMap<Integer, String>();
temp.put(new Integer(1), "cat");
temp.put(new Integer(2), "rat");
Collection coll = temp.values();
String[] arr = (String[]) coll.toArray();
System.out.println(arr.length);
} Thanks,
Harish SrinivasanInfiniti wrote:
Why don't we get a compilation error but get a runtime error while explicit casting of Object[] into a String[]?
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
public class SampleMap {
public static void main(String[] args) {
Map<Integer, String> temp = new HashMap<Integer, String>();
temp.put(new Integer(1), "cat");
temp.put(new Integer(2), "rat");
Collection coll = temp.values();
String[] arr = (String[]) coll.toArray();
System.out.println(arr.length);
} Thanks,
Harish SrinivasanAn explicit cast's job is to tell the compiler that even though it cannot guarantee that the conversion will work, allow the code anyway and let the runtime handle an error if it occurs.
Maybe you are looking for
-
I got Windows 7 (64 bit) and Microsoft Outlook 2010. I've downloaded the newest iTunes a few times and yet when I try and sync my Outlook Contact to my iPhone 4 the option to use Outlook is not availabe - only Google Contacts, Windows Contacts and Ya
-
I created a slice and a simple behavior that onrollover to add a pop-up menu. How do you next add another behavior that indicates onroll off to make the menu disappear? Thanks.
-
Hi, Are there any problems with shutting down a virtual machine using a script? (example of shutdown script here). In this case, I want to start VM's in a particular sequence and timing, and then reverse the sequence and timing for shutdown. The b
-
FreeHand quits every time I print.
Every single time I print, Freehand MX quits. This happened with FH 10 and beyond, on multiple macs with multiple operating systems (maybe even OS9!). Since everyone is not up in arms over this, it must not be happening to everyone, so does anyone kn
-
I've installed and uninstalled my itunes about like 30 times, I've restarted my ipod and everything. It keeps saying it wont be detected. I tried plugging it into my friends computer and it worked but it wont work on mine. And I know I need the 64 bi