Pygame exit code 139 - pygame

PIXAR = pygame.PixelArray(SCREEN)
PIXAR[110][0] = WHITE
When I add this to my code, I get:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
followed by a OS message that python quit unexpectedly. If I remove it:
Process finished with exit code 0
I can't seem to find a solution; the 1.9.2 manual does not explain this. If I'm missing it in the reading, can someone please point me in the right direction?

I think PIXAR is a two dimensional array. It should be accessed with PIXAR[110,0] instead of PIXAR[110][0].

Related

Octave error filename undefined near line 1 column 1

I tried to run a function with octave-GUI.
I first write a function in 'testFunc.rtf'(in WordPad).
function y = testFunc(x)
y = x^2 + x^3
The path to this file is 'C:\Users\username\Desktop'.
Then on octave-GUI, I wrote such code:
cd 'C:\C:\Users\username\Desktop';
testFunc(4);
The result of this was just an error below:
error: 'testFunc' undefined near line 1, column 1
How can I solve this problem?
Just in case someone like me finds this page, and the above suggestion still doesn't help, some advice. This is running on a Win10 machine:
The error text itself means nothing. It's very poor. It just means "oops, something went wrong and we can't tell you why".
In my case, the file existed, and had the correct name. And was in the "current directory". Using the octave command "what" showed it was there.
But try as I might, it always gave me the error above. I tried so many things I saw suggested in other search results, like making sure the function def was at the first line of the file, etc. Even tried changing DOS -> unix line endings (cr/lf to lf). Nothing.
Then it occurred to me that I was trying to run off of a "samba share" from a linux drive. Even though it had read/write/execute privileges, it just would not actually run.
Moved the file(s) to a windows drive and it started working!
Sheesh. Good luck, all.
Avner

How do I get want anything to work with xlswrite in octave?

I want anything to work with xlswrite in octave. Eventually I want to be able to put a cell array containing but really anything working at all would be a start.
I've put in the following lines as this is the simplest case I could think of:
array1 = [0 9 10]
cellarray1 = num2cell(array1)
xlswrite ('/home/willubuntu/acpimrepo/bob.xlsx', cellarray1)
Then I get this error:
error: `xlswrite' undefined near line 9 column 1
I've tried this:
xlswrite ('/home/willubuntu/acpimrepo/bob.xlsx','cellarray1')
And get the same error:
error: `xlswrite' undefined near line 9 column 1
I've tried removing the space between xlswrite and the opening parenthesis - same error.
I've tried using array1 and not cellarray1 and got the same error (with both parenthesis options).
I've tried removing the directory from the file name and get a very slightly different error:
error: `xlswrite' undefined near line 10 column 1
What is going on? Why doesn't xlswrite work? What piece of pedantry am I missing?
Please remember that if you say anything too sophisticated, it will go over my head. Remember I am clueless and at the end of my tether.
If you would use a recent Octave version you would see
octave:1> xlswrite
warning: Functions for spreadsheet style I/O
(.xls .xlsx .sxc .ods .dbf .wk1 etc.)
are provided in the io package. See <http://octave.sf.net/io/>.
which guides you to the right direction.
Even a quick search on http://wiki.octave.org/Main_Page would solve this. Perhaps you should spend some minutes with a search machine or the manual and the wiki instead of moaning how annoying and boring GNU Octave is.

why octave step response doesnt get to the step?

Got my code here.
#! /bin/octave -qf
nn=[0.13785];
dd=[1 14 60 200];
t=0:0.005:5;
[y,t,x]=step(tf(nn,dd), t);
plot(t,y)
pause()
Why does octave makes a step of 0.007, instead a step of 1? I think its not octave problem but my understanding of the process

IF and ! = ns2 error

I have a problem with path in a tcl file. I tried to use
source " /tmp/mob.tcl "
and this path in bash file :
/opt/ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest/setdest -v 1 -n $n -p 10 -M 64 -t 100 -x 250 -y 250 >> /tmp/mob.tcl
The terminal give me this output:
..."
(procedure "source" line 8)
invoked from within
"source "/tmp/mob.tcl" "
(file "mobilita_source.tcl" line 125)
How I can do this?
Firstly, this:
source " /tmp/mob.tcl "
is very unlikely to be correct. The spaces around the filename inside the quotes will confuse the source command. (It could be correct, but only if you have a directory in your current directory whose name is a single space. That's really unlikely, unless you're a great deal more evil than I am.)
It really helps a lot if you stop making this error.
Secondly, the error message is both
Incomplete, with just an ellipsis instead of a full error on the first line
Really worrying, with source claimed to be a procedure (second line of that short trace).
It's legal to make a procedure called source, and sometimes the right thing to do, but if you're doing it then you have to be ever so careful to duplicate the semantics of the standard Tcl command or odd things will happen.
Thirdly, you've got a file of what is apparently generated code, and you're hitting a problem in it, and you're not telling us what is on/around line 125 of the file (the error trace is pretty clear on that front) or in the contents of the source procedure (which is non-standard; the standard source is implemented in C) and you're expecting us to guess what's going wrong for you??? Seriously?
Tcl error traces are usually quite clear enough for you to figure out what went wrong and where. If there's an unclear error, and it didn't come from user code (by calling error or return -code error) then let us know; we'll help (or possibly even change Tcl to make things clearer in the future). But right now, there's a complete shortage of information.
Here's an example of what a normal source error looks like:
% source /tmp/foo/bar/boo
couldn't read file "/tmp/foo/bar/boo": no such file or directory
% puts $errorInfo
couldn't read file "/tmp/foo/bar/boo": no such file or directory
while executing
"source /tmp/foo/bar/boo"
If a script generates an error directly, it's encouraged to be as clear as that, but we cannot enforce it. Sometimes you have to be a bit of a detective yourself…

Creating Function in Octave

I'm beginning with octave. I've created a file called squareThisNumber.m in My Documents with the following code:
function y = squareThisNumber(x)
y = x^2;
I set the directory to look at My Documents with
cd 'C:\Users\XXXX\My Documents'
I type "squareThisNumber(3)" into octave, and all I'm getting is "Error: 'squareThisNumber' undefined near line 3 column 1." What am I doing wrong?
EDIT:
When I type ls into octave, I get "error: ls: command exited abnormally with status 127". Did I not install Octave correctly?
This behavior sure does seem like there's a problem with octave's current working directory. Does the command dir or pwd also have the same problem?
But you might be able to ignore all of that by
addpath("C:\Users\XXXX\My Documents");
Did you place the end keyword at the end? Code example below works perfectly for me
https://saturnapi.com/fullstack/function-example
% Welcome to Saturn's MATLAB-Octave API.
% Delete the sample code below these comments and write your own!
function y = squareThisNumber(x)
y = x^2;
end
squareThisNumber(9)