syntax

Buffered Images in java

static BufferedImage img1[]; for(int i=0;i<60;i++) { img1[i] = new BufferedImage((int) (width), (int) (height), BufferedImage.TYPE_INT_RGB); } It shows an error on the line above this code : Syntax error on token ";", { expected after this token and below this code as: Multiple markers at this line - Method breakpoint:V...

In Python 2.6.4, why do I get a syntax error for a function call, of which the function is defined and works perfectly on its own?

This happens in IDLE and Windows 7 RC1 (if that helps). Here is the module: from math import * from TurtleWorld import * world = TurtleWorld() bob = Turtle() bob.delay = 0.1 def polyline(turtle, length, n, angle): for i in range(n): fd(turtle, length) rt(turtle, angle) def polygon(turtle, length, n): """ p...

please tell me why "else" is a syntax error here.

import java.util.Scanner; public class SW { /** * @param args */ public static void main(String[] args) { int length; int width; int number; int perimeter; int area; Scanner input = new Scanner( System.in ); System.out.println("1. Dimensions of the rectangle"); System.out.println("2. Perimeter of the rectangle"); System.out...

Different syntax for method invocation in OO languages

I know: C++, Java, and tons others: object.method() , object.method(arg) Objective-C: [object method] , [object method:arg] Smalltalk: object method , object method: arg PHP, Perl object->method(), object->method(arg) $object->method; $object->method($arg1, $arg2, ...); OCaml object#method , object#method args CLOS...

Is this code Equivalent

I am not a fan of the following construction if (self = [super init]) { //do something with self assuming it has been created } Is the following equivalent? self = [super init]; if (self != nil) { //Do something with Self } ...

Retrieving widget data with MySQL query in WordPress

I've built up multiple dynamic sidebars for front page item manipulation. Each sidebar contains a Text widget, and I want to retrieve each widget's content (according to widget ID) from wp_options. Basically, the structure is dbName -> wp_options -> option_id #92 contains the following: a:9:{i:2;a:0:{}i:3;a:3: {s:5:"title";s:0:"";s:4:...

Ocaml Syntax Error

What's wrong with this code? I can't figure it out: let parent (rules : grammar) (symbol1 : string) (symbol2 : string) : (SymbolSet.t) = try SymbolSet.singleton (getParent [symbol1; symbol2] rules) with Not_found -> SymbolSet.singleton "";; let fundementalRule (set1 : SymbolSet) (set2 : SymbolSet) (rules : grammar) : (S...

Easy Python ASync. Precompiler?

Hi, imagine you have an io heavy function like this: def getMd5Sum(path): with open(path) as f: return md5(f.read()).hexdigest() Do you think Python is flexible enough to allow code like this (notice the $): def someGuiCallback(filebutton): ... path = filebutton.getPath() md5sum = $getMd5Sum() showNotifica...

can php return a boolean? => return $aantal == 0;

hi very short question can php return a boolean like this: return $aantal == 0; like in java you can public boolean test(int i) { return i==0; } or do you Have to use a if contruction? because if i do this. $foutLoos = checkFoutloos($aantal); function checkFoutloos($aantal) { return $aantal == 0; } echo "foutLoos = $foutLoo...

how to bind the dropdown list

Please help I am getting the following error when I am binding the drop down list in the form Unable to cast object of type 'System.Data.Objects.ObjectQuery1[<>f__AnonymousType02[System.String,System.Int32]]' to type 'System.Collections.Generic.List`1 I have written the query in Linq language return (IList )(from p in db.tbl_PRODUCT_C...

Python if else condition error

This is my code snippet, but it not execute the way that I want.The first if statement executes successfully if the input is a non-negative/character value, but if it is a negative value it ignores the elif statement. What's the issue.I'm using Python 2.6 from math import sqrt import cmath y = raw_input("Enter your number:") if y.isd...

incorrect syntax near the keyword 'AS'

Why do i receive a syntax error as such: Incorrect syntax near the keyword 'AS' I am using microsoft visual studio 2005 and sql server 2005 string strSql = "SELECT a.MCode, a.NameOfModule, a.Mod_Abbreviation, dt.ModuleCode, dt.Course, dt.Stage, dt.ModuleGrpFrom, dt.ModuleGrpTo, dt.GrpName, dt.GrpType, dt.StaffID, dt.AcadYear, dt.A...

Does C# 2.0-3.0 have named arguments support for methods ?

Is there a way to have named arguments like in perl/python for example object.method(arg1 => value1, arg2 => value2, arg3 => 0); in C# prior to C# 4.0? ...

Meaning of using commas and underscores with Python assignment operator?

Reading thru Peter Norvig's Solving Every Sudoku Puzzle essay, I've encounted a few Python idioms that I've never seen before. I'm aware that a function can return a tuple/list of values, in which case you can assign multiple variables to the results, such as >>> def f(): ... return 1,2 >>> a, b = f() But what is the meaning of...

What does the asterisk before the variable mean in the named_scope argument list?

I've got a named scope like this: named_scope :by_items, lambda |*items| { :joins => :items, :conditions => ["items.id in (?)", items.map(&::id)] } What's the "*item" mean? When I call it with "Item.find(:first, ...)" it works fine. If I try to call using a collection, "Item.find(:all, ...)" it fails. From a different SO questi...

What is this weird colon-member syntax in the constructor?

Recently I've seen an example like the following: #include <iostream> class Foo { public: int bar; Foo(int num): bar(num) {}; }; int main(void) { std::cout << (new Foo(42))->bar << std::endl; return 0; } What does this strange : bar(num) mean? It somehow seems to initialize the member variable but I've never seen this syntax...

Syntax help! Php and MYSQL

Original: $sql = "SELECT DATE(TimeAdded) AS Date, $column_name FROM Codes ORDER BY TimeAdded ASC"; Altered: $sql = "SELECT DATE("m", TimeAdded ) AS Date, ColumnName FROM TableName ORDER BY TimeAdded ASC"; TimeAdded was added using NOW() and basically, I am trying to make it months. The problem I have here is the quotations is messi...

Usage/availability of import function in Processing.js

The reference page (use "toggle all") for Processing.js says the import command remains unimplemented. It references a page for the Java Processing language that describes a usage pattern like this: import processing.opengl.*; I see at Github that some work on the import command was committed to the root in May. Does anyone know how thi...

Using SELECT TOP from one column, then sorting on a different column

I'm using SQL Server 2005, and I want to query for the vendors generating the most revenue, sorted by the vendor's name. Below is the query I have tried. The inner subquery gets the 15 largest vendors sorted by revenue, and I try to order those results by the vendor name. SELECT Revenue, VendorName FROM ( SELECT TOP 15 SUM(...

Why is this syntax invalid? vectorPointer->[0]

In C++, why is the following element access in a vector invalid? void foo(std::vector<int>* vecPtr) { int n = vecPtr->size(); // ok int a = vecPtr->[0]; // invalid } Instead, we have to write the more cumbersome (*vecPtr)[0] = 1; I think, the operator[] call should just have the same syntax like a method call, and I hate t...