Error of undefined variable in GUI in SCILAB - scilab

I am making GUI in scilab ,my code is :-
///first push button
function file_open_callback(handles)
//Write your callback for file_open here
Image = imread(path);
//handles.Image=Image;
figure();ShowColorImage(Image,'mixer');//show image
I1G=rgb2gray(Image);
ShowImage(I1G,'mixer');
handles.I1G=I1G;
//handles= getcallbackobject(f.figure_id);
endfunction
///second push button
function select_ROI1_callback(handles)
//Write your callback for select_ROI1 here
rect1 = rubberbox();xrect(rect1);///disp(rect1);
handles.rect1=rect1;
endfunction
///Third pushbutton
function Reverse_Yaxis_callback(handles)
//Write your callback for Reverse_Yaxis here
//handles.I1G=findobj('Tag','file_open');
//I1G=handles.I1G;
imheight=size(handles.I1G,'r');//image height
rect1(2)=imheight-rect1(2);//reverse y axis coordinate
endfunction
it shows following error:
!--error 4 Undefined variable: I1G at line 3 of function
Reverse_Yaxis_callback called by : %oldgcbo = gcbo; end;gcbo =
getcallbackobject(312);Reverse_Yaxis_callback(handles);if
exists("%oldgcbo") then gcbo = %oldgcbo; else clear gcbo; end while
executing a callback
How can I solve this?

Related

PeopleCode error while trying to call function on Page PeopleCode event

I am trying to add the below function (populate_details) to a Page PeopleCode Activate event. The top section of code already exists, I am trying to add the section starting at 6/24/20 comments and getting the error "Syntax error: expecting statement. (2,42) ^ HCSC" If I remove the top section of the code then the error does not display and it saves properly, so I must have some sort of syntax error. Thanks for the help!
import HR_DIRECT_REPORTS:EmployeeSelection;
Component HR_DIRECT_REPORTS:EmployeeSelection &MyUI;
&MyUI.PageActivate();
/*GHS KLG - link to Footprints on termination screen*/
If DERIVED_HR_DR.HR_DR_PAGE_TITLE.Value = "Terminate Employee" Then
GHS_MSS_WRK.HTMLAREA.Value = MsgGetExplainText(31000, 27, "Message not found.");
GHS_MSS_WRK.HTMLAREA.Visible = True;
Else
GHS_MSS_WRK.HTMLAREA.Visible = False;
End-If;
/*GHS end*/
/* GHS KDR 6/24/20 BEGIN */
Declare Function populate_details PeopleCode GH_PERS_INF_WRK.FUNCLIB FieldFormula;
GH_PERS_INF_WRK.EFFDT = %Date;
populate_details(%Date, PERSON_NPC_VW.EMPLID.Value, GH_PERS_SRCH_CW.EMPL_RCD.Value);
/* GHS KDR 6/24/20 END */
You must declare your populate_details function at the top of the Page PeopleCode Activate event. Immediately after this line should work:
Component HR_DIRECT_REPORTS:EmployeeSelection &MyUI;
Then you can call your function as you did, the rest of the code looks fine.

recursion in typescript gets undefined

I'm using a canvas object inside my component to generate a chart. In order for it animate i'm calling the method recursively. I keep getting an error saying that the method is not defined. Not sure how I need to structure it.
any assistance appreciated.
// Animate function
protected animate(draw_to) {
// Clear off the canvas
this.ctx.clearRect(0, 0, this.width, this.height);
// Start over
this.ctx.beginPath();
// arc(x, y, radius, startAngle, endAngle, anticlockwise)
// Re-draw from the very beginning each time so there isn't tiny line spaces between each section (the browser paint rendering will probably be smoother too)
this.ctx.arc(this.x, this.y, this.radius, this.start, draw_to, false);
// Draw
this.ctx.stroke();
// Increment percent
this.curr++;
// Animate until end
if (this.curr < this.finish + 1) {
// Recursive repeat this function until the end is reached
requestAnimationFrame(function () {
error happens here >>> this.animate(this.circum * this.curr / 100 + this.start);
});
}
}
You need to use an arrow function to keep the same context in the function you give to requestAnimationFrame.
requestAnimationFrame(() => {
error happens here >>> this.animate(this.circum * this.curr / 100 + this.start);
});
Another option is:
requestAnimationFrame(this.animate.bind(this, this.circum * this.curr / 100 + this.start));
You are passing a reference to this.animate which is already bound to the correct this along with the parameters.

box2d CreateFixture with b2FixtureDef gives pure virtual function call

i have this code that gives me run time error in the line :
body->CreateFixture(&boxDef)
im using cocos2d-x 2.1.5 with box2d 2.2.1 in windows
CCSprite *sprite = CCSprite::create(imageName.c_str());
this->addChild(sprite,1);
b2BodyDef bodyDef;
bodyDef.type = isStatic?b2_staticBody:b2_dynamicBody;
bodyDef.position.Set((position.x+sprite->getContentSize().width/2.0f)/PTM_RATIO,
(position.y+sprite->getContentSize().height/2.0f)/PTM_RATIO);
bodyDef.angle = CC_DEGREES_TO_RADIANS(rotation);
bodyDef.userData = sprite;
b2Body *body = world->CreateBody(&bodyDef);
b2FixtureDef boxDef;
if (isCircle)
{
b2CircleShape circle;
circle.m_radius = sprite->getContentSize().width/2.0f/PTM_RATIO;
boxDef.shape = &circle;
}
else
{
b2PolygonShape box;
box.SetAsBox(sprite->getContentSize().width/2.0f/PTM_RATIO, sprite->getContentSize().height/2.0f/PTM_RATIO);
boxDef.shape = &box;
}
if (isEnemy)
{
boxDef.userData = (void*)1;
enemies->insert(body);
}
boxDef.density = 0.5f;
body->CreateFixture(&boxDef) //<-- HERE IS THE RUN TIME ERROR
;
when i debug the box2d code im getting to b2Fixture.cpp
in the method :
void b2Fixture::Create(b2BlockAllocator* allocator, b2Body* body, const b2FixtureDef* def)
in the line :
m_shape = def->shape->Clone(allocator);
getting the runtime error :
R6025 pure virtual function call
Tricky one. I ran into this myself a couple times. It has to do with variable scope.
The boxDef.shape is the problem. You create the shapes as local variables in the if/else blocks and then assign them to boxDef. As soon as execution leaves the if/else block scope those local variables will be garbage. The boxDef.shape now points to freed memory.
The solution is to keep the shape variables in scope by moving the circle and box shape declarations before the if/else block.

Redraw NSTableView with new data from file when NSViewController re-loaded?

I have a Mac OS X Document based app that has multiple NSViewControllers that I switch between and each view displays data from plist files in NSTableViews based on the user selections in the previous NSViewController's NSTableView. The problem I have is that I can't figure out what function can be called, every time a NSViewController gets loaded, to read the correct data from a file to display in the NSTableView. For UIViewControllers I used the function family of viewDidLoad, viewWillAppear, but I haven't been able to find the corresponding functions for NSViewController.
Currently I am using awakeFromNib, which works fine, but only the first time the NSViewController gets loaded. I've tried loadView, but that collapses the NSView. I assume that I need to do more setup to use loadView.
I'm using the View Swapping code from Hillegass's book Cocoa Programming for MAC OS X which switches ViewControllers with the following code:
- (void)displayViewController:(ManagingViewController *)vc
curBox: (NSBox *)windowBox
{
// End editing
NSWindow *w = [windowBox window];
BOOL ended = [w makeFirstResponder:w];
if (!ended) {
NSBeep();
return;
}
NSView *v = [vc view];
NSSize currentSize = [[windowBox contentView] frame].size;
NSSize newSize = [v frame].size;
float deltaWidth = newSize.width - currentSize.width;
float deltaHeight = newSize.height - currentSize.height;
NSRect windowFrame = [w frame];
windowFrame.size.height += deltaHeight;
windowFrame.origin.y -= deltaHeight;
windowFrame.size.width += deltaWidth;
[windowBox setContentView:nil];
[w setFrame:windowFrame
display:YES
animate:YES];
[windowBox setContentView:v];
// Put the view controller in the responder chain
[v setNextResponder:vc];
[vc setNextResponder:windowBox];
}
and puts the NSView Controller in the responder chain.
Is there some function I can call to setup the view every time I swap NSViewControllers? Can I check that a NSViewController has become the firstResponder?
This post provided the answer.
I added the following code:
- (void)viewWillLoad {
}
- (void)viewDidLoad {
}
- (void)loadView {
[self viewWillLoad];
[super loadView];
[self viewDidLoad];
}
and at the beginning of displayViewController I added
[vc loadView]

Console Error with CCParallaxNode and crash

I'm getting an error in the console that reads
Assertion failure in -[CCParallaxNode addChild:z:tag:]
This is for the code
CGSize winSize = [[CCDirector sharedDirector] winSize];
node = info;
voidNode = [CCParallaxNode node];
[voidNode addChild:node z:2 parallaxRatio:ccp(0.0f, 1.0f) positionOffset:ccp(info.contentSize.width/2, info.contentSize.height/2 - winSize.height)];
[self addChild:voidNode z:2 tag:kTagNode];
Not very familiar with debugging with the console
Why don't you simply put there a breakpoint and see what is happening ? Every time i had such error the problem was trying to add a nil child to the parent (there is an assertation of it in a addChild method

Resources