Spyder IDE problem: Every indented statement throws an indentation error - spyder

I'm getting the "IndentationError: expected an indented block" error in every indented statement, no matter how simple. I've really hit a wall, so any help would be much appreciated.
I've gone through many similar questions on SO and to the best of my ability have taken care that I have the correct indentation in my code (and that I'm not mixing tabs and spaces).
With each of the below statements, I get the same "expected an indented block" error behind the first line's colon. I use tabs in Spyder, but will use 4 spaces to indent here.
if 3 + 5 > 0:
print("8")
Throws the error:
In [6] if 3 + 5 > 0:
File "C:\Users\..\AppData\Local\Temp\ipykernel_12028\2022076979.py", line 1
if 3 + 5 > 0:
^
IndentationError: expected an indented block
Same error for:
for i in range(1,11):
print(i)
And also for:
def iris_data():
print("hello")
All three statements run as given in the PyCharm IDE (as well as IDLE), so this seems to be an issue with Spyder's settings (or maybe installation?).
I like using Spyder as an IDE, so I'm really hoping someone has any idea what is causing these errors. Thanks.

I was running only the line by putting the cursor in/on it and pressing F9.
What I wanted to do was run the cell by pressing ctrl+ return, or alternatively, select the entire piece of code I want to run and press F9.
It's such a stupid mistake that I couldn't find anything on Google or Stack Overflow.
Hope this maybe helps out another absolute beginner.

Related

Pipe character ignored in SPSS syntax

I am trying to use the pipe character "|" in SPSS syntax with strange results:
In the syntax it appears like this:
But when I copy this line from the syntax window to here, this is what I get:
SELECT IF(SEX = 1 SEX = 2).
The pipe just disappears!
If I run this line, this is the output:
SELECT IF(SEX = 1 SEX = 2).
Error # 4007 in column 20. Text: SEX
The expression is incomplete. Check for missing operands, invalid operators,
unmatched parentheses or excessive string length.
Execution of this command stops.
So the pipe is invisible to the program too!
When I save this syntax and reopen it, the pipe is gone...
The only way I found to get SPSS to work with the pipe is when I edited the syntax (adding the pipe) and saved it in an alternative editor (notepad++ in this case). Now, without opening the syntax, I ran it from another syntax using insert command, and it worked.
EDIT: some background info:
I have spss version 23 (+service pack 3) 64 bit.
The same things happens if I use my locale (encoding: windows-1255) or Unicode (Encoding: UTF-8). Suspecting my Hebrew keyboard I tried copying syntax from the web with same results.
Can anyone shed any light on this subject?
Turns out (according to SPSS support) that's a version specific (ver. 21) bug and was fixed in later versions.

Cobol Mainframe - perform varying Index - display

so I am just starting to learn COBOL on Z/OS. I have done quite a bit using visual cobol; however, this is still quite different.
I need to display a table starting at the Index of 1 and displaying until the index is 50
PERFORM VARYING W03-SUBJ-INDX FROM 1 BY 1
UNTIL W03-SUBJ-INDX = 50
DISPLAY W03-SUBJ-TABLE
END-PERFORM
That is what I currently have I also tried
PERFORM VARYING W03-SUBJ-INDX FROM 1 BY 1
UNTIL W03-SUBJ-INDX = 50
DISPLAY W03-SUBJ-TABLE(w03-subj-indx)
END-PERFORM
The top example displays only the first indexed item (To be expected) - The second example gives me an error stating ")" was unexpected.
Any help would be appreciated.. I was told I have to use the index
So regarding your existing code....there was some flakiness in some of the versions of the Enterprise Cobol parsers...
DISPLAY W03-SUBJ-TABLE(w03-subj-indx)
might work as this:
DISPLAY W03-SUBJ-TABLE ( w03-subj-indx )
Some of the versions of the Enterprise Cobol compiler did not parse well without spaces. This was especially important when doing reference modification, but applied to tables as well.
Give it a try, YMMV.
You don't mention which compiler version you are on, but there was once one -- and I can't remember the version -- that was flakey with subscripts verses reference modification.
Try plugging in some spaces:
DISPLAY W03-SUBJ-TABLE ( w03-subj-indx )
Also, make sure that W03-SUBJ-TABLE is the array, not a group item containing the array.

Building Latex/Tex arguments in lua

I use lua to make some complex job to prepare arguments for macros in Tex/LaTex.
Part I
Here is a stupid minimal example :
\newcommand{\test}{\luaexec{tex.print("11,12")}}% aim to create 11,12
\def\compare#1,#2.{\ifthenelse{#1<#2}{less}{more}}
\string\compare11,12. : \compare11,12.\\ %answer is less
\string\test : \test\\ % answer is 11,12
\string\compare : \compare\test. % generate an error
The last line creates an error. Obviously, Tex did not detect the "," included in \test.
How can I do so that \test is understood as 11 followed by , followed by 12 and not the string 11,12 and finally used as a correctly formed argument for \compare ?
There are several misunderstandings of how TeX works.
Your \compare macro wants to find something followed by a comma, then something followed by a period. However when you call
\compare\test
no comma is found, so TeX keeps looking for it until finding either the end of file or a \par (or a blank line as well). Note that TeX never expands macros when looking for the arguments to a macro.
You might do
\expandafter\compare\test.
provided that \test immediately expands to tokens in the required format, which however don't, because the expansion of \test is
\luaexec{tex.print("11,12")}
and the comma is hidden by the braces, so it doesn't count. But it wouldn't help nonetheless.
The problem is the same: when you do
\newcommand{\test}{\luaexec{tex.print("11,12")}}
the argument is not expanded. You might use “expanded definition” with \edef, but the problem is that \luaexec is not fully expandable.
If you do
\edef\test{\directlua{tex.sprint("11,12")}}
then
\expandafter\compare\test.
would work.

ESC/P programming!

Why i need to use it is because for some printers using TPrinter prints some weird hieroglyph at the beginning of the printable area.
My problem is that if i send some commands, nothing happens.
ESC E (#27 #69) - Sending this escape sequence didn't work as i expected. It removed first letter and rest of the string made bold. eg. Hello -> ello. After i changed it to ESC E ESC (#27 #69 #27), it worked fine. This example i managed to figure out, but...
trying to select character table "ESC t n" (#27 #116 n), to make "õäöü" work. This command just doesn't work. Nothing happens! And this command is supported by esc/p, esc/p 2 and 9-pin esc/p, so it should work just fine.
Manual can be found here.
If anyone has ever needed to use esc/p commands then maybe one can shed some light how to work with them!
Thanks in advance!
EDIT:
In my previous post i asked more or less the same question though answers were about how did i send commands to the printer. (I'll change my question there according to what was the answers!)
I accepted Ken's answer, because he claimed that the way i transferred the commands wasn't the best and i got it to work with Escape command.
The problem was that after trying to use my program with another printer, it didn't work as expected, because it uses TPrinter.Begindoc and EndDoc.
So actually i must use the other solution that Rob Kennedy helped me with!
EDIT 2:
As it turned out, i used wrong manual, where commands are little different (though still supporting esc/p as it proclaims). Thank you all for your help!
PS!
I still have a question: I need a character table where
245 = õ
228 = ä
246 = ö
252 = ü
which is iso 8859. But in manual there is no such character table or any similar to it. Should i do some string manipulation and replace eg 228 to 132 or does anyone know any better approuch?
I keep it unanswered for a while, and then accept stukelly's answer.
Based on your previous question, I think you are using the wrong commands to control the EPSON TM-T70 receipt printer. After some research I found the product brochure and POSMicro both mention ESC/POS.
The ESC/POS command for turning bold on and off requires has a third value, as follows.
ASCII ESC E n
Hex 1B 45 n
Decimal 27 69 n
Where n is 0 or 1, turning bold off or on.
Here is a detailed ESC/POS reference.

Fujitsu COBOL 3.0

I'm new to Fujitsu COBOL 3.0 software. I tried executing a simple program. The code and errors are as follows. Everything in program appears to be correct. Can anyone help me out? Any prestandards are to be followed in this software?
The sample cobol program is:
IDENTIFICATION DIVISION.
PROGRAM-ID. ShortestProgram.
PROCEDURE DIVISION.
DisplayPrompt.
DISPLAY "I did it".
STOP RUN.
--------------------------------------------------------------------------------------
** DIAGNOSTIC MESSAGE ** (NOPRGMID)
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 0: JMN1102I-S IDENTIFICATION DIVISION HEADER IS MISSING. HEADER ASSUMED TO BE CODED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 1: JMN1019I-W INDICATOR AREA MUST CONTAIN '-','*','/','D',OR BLANK. A BLANK IS ASSUMED TO BE SPECIFIED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 1: JMN1005I-W CHARACTER STRING 'DENTIFICATION' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 1: JMN1356I-W INVALID WORD 'DENTIFICATION' IS SPECIFIED IN IDENTIFICATION DIVISION. IGNORED UNTIL NEXT PARAGRAPH OR DIVISION.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 2: JMN1019I-W INDICATOR AREA MUST CONTAIN '-','*','/','D',OR BLANK. A BLANK IS ASSUMED TO BE SPECIFIED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 2: JMN1005I-W CHARACTER STRING 'ROGRAM-ID' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 4: JMN1019I-W INDICATOR AREA MUST CONTAIN '-','*','/','D',OR BLANK. A BLANK IS ASSUMED TO BE SPECIFIED.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 4: JMN1005I-W CHARACTER STRING 'ROCEDURE' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 6: JMN1004I-W RESERVED WORD 'DISPLAY' MUST START IN AREA B. ASSUMED TO START IN AREA B.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 7: JMN1104I-S PROGRAM-ID PARAGRAPH IS MISSING. PROGRAM-NAME GENERATED BY SYSTEM.
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB 7: JMN1004I-W RESERVED WORD 'STOP' MUST START IN AREA B. ASSUMED TO START IN AREA B.
STATISTICS: HIGHEST SEVERITY CODE=S, PROGRAM UNIT=1
The warnings (referring to area B) seem to suggest your code should by starting in the second column of each line. Which is why it's finding e.g. "DENTIFICATION" instead of "IDENTIFICATION".
I've never developed in COBOL but I vaguely remember that the first column has to be blank, or * for a comment: the warning messages seem to indicate that / - and D are valid values too.
UPDATE: Google suggests that COBOL compiler ignores the first 6 columns and that column 7 has a special significance (D for debugging, * for comment, ...). Though maybe the behaviour is compiler-specific. So I suspect your problem is that your code is starting in col 7 where it should be col 8.
Shift everything over 7 columns so that IDENTIFICATION DIVISION starts in column 8 and all subsequent lines began in column 8 or greater.
There's also a compiler switch (can't remember off the top of my head) that allows you to start in col 1
Taking a WAG (wild-ass guess) here. Haven't cobol'd since my last year of college.
Your error message says, at the bottom,
STATISTICS: HIGHEST SEVERITY CODE=S, PROGRAM UNIT=1
Okay, so I figure you have some warnings (possibly CODE=W), and one or more errors that are actually causing your program to fail.
So, scanning the error message, I see lots of W-s, and one line with an S:
C:\FSC\PCOBOL32\samples\SAMPLE6\SAMPLE7.COB
7: JMN1104I-S PROGRAM-ID PARAGRAPH IS
MISSING. PROGRAM-NAME GENERATED BY
SYSTEM.
So it seems you're missing your Program-ID paragraph. Looking at your program, I do see a n identification division, which has a program-id.
I can conclude four things from this:
1) Your identification division paragraph is malformed
2) As Neil said, you aren't running your snippet, but a sample that does not have an ID paragraph. Open sample7.cob and see
3) Some other issue is causing the error, but it is being hidden or misinterpreted as an ID paragraph error

Resources