Hi All,
I have written a code block to do database transaction in SQL Server database. I am using TransactionScope class to rollback all the changes if any failures during the execution.
If I run the application in a system which running SQL SERVER, I have no problem.
If I run the application in a system and the SQL SERVER is running i...
Say that I have many blogs, and each blog has_many posts. These are stored in 2 tables ("blogs" and "posts"). Is it possible to add an additional column (e.g. scoped_id) to the blog table which stores an ID, scoped by the blog.
Example
Blog: 1
- Posts
- id: 1, scoped_id: 1
- id: 2, scoped_id: 2
- id: 3, scoped_id: 3
B...
I'm trying to calculate the number of success cases within a recursive function in C#, but I'm astonished by the fact that my variable is shared between all the function calls!
[update 2]
More than strange this time. doing so
i = i + validTreesFun(tree.Nodes, newWords.ToList()) ;
resets i to 0
doing this
i = validTreesFun(tree.Nod...
Hi Guys,
I have the following code:
public List<IWFResourceInstance> FindStepsByType(IWFResource res)
{
List<IWFResourceInstance> retval = new List<IWFResourceInstance>();
this.FoundStep += delegate(object sender, WalkerStepEventArgs e)
{
if (e.Step.ResourceType =...
I have a function with a big hierarchy:
function func(){
$a= 0; // Here the variable is 0
while(...){
echo $a; // gives me always 0
for(...){
if(...){
if(...){
$num = func3();
$a = $num; // this $a does not corrospond to $a in the beginning
...
Hey all,
I'm working with the jQuery ColorPicker widget - specifically exercising the ColorPickerSetColor function (just 'setColor' internally). Code excerpt:
setColor: function(col) {
if (typeof col == 'string') {
col = HexToHSB(col);
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
col = R...
I have this situation:
{
float foo[10];
for (int i = 0; i < 10; i++) {
foo[i] = 1.0f;
}
object.function1(foo); // stores the float pointer to a const void* member of object
}
object.function2(); // uses the stored void pointer
Are the contents of the float pointer unknown in the second function call? It seems ...
Anyone have any clean patterns for getting php vars into the js scope?
Two ways I have done it before is either injecting it with an actual call from the base template inside a document ready wrapper.
(jQuery/Smarty Template)
{literal}
$(document).ready(function() {
TargetClass.targetVar = {/literal}{$phpVar}{literal};
});
{/liter...
I have a generic question about scope and encapsulation. Take two scenarios:
Scenario 1:
// a global application level constant
public static const IS_DEMO_MODE:Boolean = false;
... // somewhere deep in the codebase
private function _myFunction():void
{
if (IS_DEMO_MODE == true) {
// If Demo Mode do not allow this functi...
Well this kind of n00b question but I still can't figure it out. I have unit main with procedure Discard() in it. Now I have another unit engine and I want to run from it procedure Discard() of unit main. I have main in uses section of engine.pas. I tried to call procedure with main.Discard() but no good. What am I doing wrong?
...
I'm using mootools-1.2.3 at the moment and I'm having trouble getting a variable to be accessible outside of a function.
I need to define the variable in the domready function, because otherwise the DOM hasn't been loaded and selector functions will not work (I can't place the script at the end of the HTML I don't have control of when t...
I've seen and written many javascript methods like this lately:
var myObj = {
dialogOptions: {...},
init: function() {
var $this = this;
var something = $("<div/>").load("...", null, function() {
$(this).dialog($this.dialogOptions);
});
}
}
Now, this works due to the nature of closures, but the named variable r...
In my code I'm creating a number of lookup tables.
var Dict1 = data1.ToDictionary(dim => new { dim.Val1,dim.Val2,.. } );
var Dict2 = data2.ToDictionary(dim => new { dim.Val1,dim.Val2,.. } );
sometime there are duplicate key values, so I tried to use a catch block
try
{
var Dict1 = data1.ToDictionary(dim => new { dim.Val1,dim.Val...
Here is a particular scenario that I have been unclear about (in terms of scope) for a long time.
consider the code
#include <stdio.h>
typedef struct _t_t{
int x;
int y;
} t_t;
typedef struct _s_t{
int a;
int b;
t_t t;
}s_t;
void test(s_t & s){
t_t x = {502, 100};
s.t = x;
}
int main(){
s_t s;
test(s);
printf("value i...
I'm still used to the AS2 style of all code on 1 frame, I'm trying to code AS3 in class files and I'm having a problem with a basic package setup. Scope issues are killing me with trying to learn AS3. Below is my package code, I don't have any other class files, just trying to return a simple trace.
The error I'm getting after I run the...
I'm using an MVC setup and I'm trying to inject javascript into my views (.php), yet allow the javascript access to all the variables that the view has access to. My end goal is to be able to access PHP variables from my javascript (for example so I could alert() a product's name).
Here's my application flow:
start output buffer
call ...
I figured I would ask... but is there a way to have the Get part of a property available as public, but keep the set as private?
Otherwise I am thinking I need two properties or a property and a method, just figured this would be cleaner.
...
I recently broke up my query into 4 named scopes to make it easier to re-sort and will paginate which otherwise always worked fine now has problems calculating the number of pages.
named_scope :loc, lambda { |id| { :conditions => ['location_id = ?', id ] } }
named_scope :datem, lambda { |*args| { :joins => :scannables, :conditions =...
Recently started on python, wondered what the equivalent object was for storing session & application scope data?
I'm using Google App Engine too so if it has any extra features (can't seem to find any immediate references myself) that would be useful
...
If I want to narrow scope of a variable in C#, I can introduce additional braces - i.e.:
class Program
{
static void Main(string[] args)
{
myClass x = new myClass();
x.MyProperty = 1000;
Console.WriteLine("x = " + x.MyProperty);
{
myClass y = new myClass();
y.MyProperty = ...