when I show a sfl window help, the main screen disappear, in power7 v7r1m0 rpg ile program - rpgle

I'm showing a sfl screen in my rpg program, in one field WPROV, I'm using F4=Help, if the user type F4, the program shows a sfl window help, but the program erase the old and main screen and I only can see the help sfl screen. How can I put in the screen the main screen and the sfl window help screen?
another thing I'm checking the fields in the screen in my rpg program, if there is an error I turn on *IN71, *IN72, but I can't see the message error on my screen, why?
Here is the main screen:
A*%%EC
A DSPSIZ(24 80 *DS3)
A R W1
A*%%TS SD 20130821 124511 ALCRUZ REL-V7R1M0 5770-WDS
A TEXT('ventana para ver detalles')
A CF03(03 'salir')
A CF05(05 'ACTUALIZAR')
A CF04(04 'AYUDA')
A CF06(06 'PROCEDER')
A CF12(12 'CANCELAR')
A KEEP
A BLINK
A ALARM
A OVERLAY
A WINDOW(2 2 18 75 *NORSTCSR)
A WDWBORDER((*DSPATR HI RI) (*CHAR '.-
A ..:::.:'))
A RMVWDW
A USRRSTDSP
A 1 22'ACME, S.A. de C.V.'
A DSPATR(HI)
A DSPATR(RI)
A 16 2'F3=Salir'
A DSPATR(HI)
A 1 63DATE
A EDTCDE(Y)
A 2 63TIME
A 1 2USER
A PGMA 10A O 2 2
A 16 39'F5=Actualizar'
A COLOR(WHT)
A 16 57'F12=Cancelar'
A COLOR(WHT)
A 2 19'Generación de Ventas Proveedores F-
A .F.S.'
A 7 26'No. de proveedor (F4).:'
A 10 26'Fecha Inicial(AAAAMMDD)'
A 13 26'Fecha Final..(AAAAMMDD)'
A WFI 8Y 0B 10 51EDTWRD(' / / ')
A COLOR(YLW)
A 72 ERRMSG('** Error en Fecha Inicial *-
A *' 72)
A WFF 8Y 0B 13 51EDTWRD(' / / ')
A COLOR(YLW)
A 73 ERRMSG('** Error en Fecha Final **'-
A 73)
A WNOMBP 30A O 8 26
A 16 13'F4=Ayuda'
A COLOR(WHT)
A WPROV 4A B 7 51COLOR(YLW)
A 71 ERRMSG('ERROR ESTE PROVEEDOR NO EXI-
A STE' 71)
A 16 24'F6=Proceder'
A COLOR(WHT)
And the sfl window screen is:
A*%%EC
A DSPSIZ(24 80 *DS3)
A R SWCCHK03 SFL
A*%%TS SD 20130819 102201 ALCRUZ REL-V7R1M0 5770-WDS
A S0AVAL 1Y 0H SFLCHCCTL
A S0OPTN 20A O 6 1
A R SWCCHK04 SFLCTL(SWCCHK03)
A*%%TS SD 20130819 104010 ALCRUZ REL-V7R1M0 5770-WDS
A SFLSIZ(0006)
A SFLPAG(0005)
A WINDOW(*DFT 13 32)
A OVERLAY
A 27 SFLDSP
A N28 SFLDSPCTL
A 28 SFLCLR
A 29 SFLEND
A CF12(12)
A SFLSNGCHC(*RSTCSR *AUTOSLT)
A*
A SFLRRN 4S 0H SFLRCDNBR(CURSOR)
A 1 10'PANTALLA DE AYUDA'
A COLOR(YLW)
A 4 1'Selecciona rengón,oprimiendo la'
A COLOR(WHT)
A CHOICE 20A O 3 1COLOR(BLU)
A 5 1'Barra espaciadora, F12= Salir'
A COLOR(WHT)

In the second display file, add a record format with the ASSUME keyword. You don't need to do anything with it in your RPG program, just define it.
A R DUMMY
A ASSUME
A 1 2' '
As for ERRMSG not working, it's because of RMVWDW. See the DDS Reference for ERRMSG - Restrictions and notes.
When the RMVWDW keyword is active, error messages are not displayed.

Related

Console Screen Buffer Info shows incorrect X position

I recently found a great short code Why the irrelevant code made a difference? for obtaining console screen buffer info (which I include below) that replaces the huge code accompanying the standard 'CONSOLE_SCREEN_BUFFER_INFO()' method (which I won't include here!)
import ctypes
import struct
print("xxx",end="") # I added this to show what the problem is
hstd = ctypes.windll.kernel32.GetStdHandle(-11) # STD_OUTPUT_HANDLE = -11
csbi = ctypes.create_string_buffer(22)
res = ctypes.windll.kernel32.GetConsoleScreenBufferInfo(hstd, csbi)
width, height, curx, cury, wattr, left, top, right, bottom, maxx, maxy = struct.unpack("hhhhHhhhhhh", csbi.raw)
# The following two lines are also added
print() # To bring the cursor to next line for displaying infp
print(width, height, curx, cury, wattr, left, top, right, bottom, maxx, maxy) # Display what we got
Output:
80 250 0 7 7 0 0 79 24 80 43
This output is for Windows 10 MSDOS, with clearing the screen before running the code. However. 'curx' = 0 although it should be 3 (after printing "xxx"). The same phenomenon happens also with the 'CONSOLE_SCREEN_BUFFER_INFO()' method. Any idea what is the problem?
Also, any suggestion for a method of obtaining current cursor position -- besides 'curses' library -- will be welcome!
You need to flush the print buffer if you don't output a linefeed:
print("xxx",end="",flush=True)
Then I get the correct curx=3 with your code:
xxx
130 9999 3 0 14 0 0 129 75 130 76
BTW the original answer in the posted question is the "great" code. The "bitness" of HANDLE can break your code, and not defining .argtypes as a "shortcut" is usually the cause of most ctypes problems.

Parsing error when reading a specific Pajek (NET) file with Networkx into Jupyter

I am trying to reading this pajek file in Google Colab's version of Jupyter and I get an error when executing the following very simple code:
J = nx.MultiDiGraph()
J=nx.read_pajek("/content/data/graphdatasets/jazz.net")
print(nx.info(J))
The error is the following:
/usr/local/lib/python3.6/dist-packages/networkx/readwrite/pajek.py in parse_pajek(lines)
211 except AttributeError:
212 splitline = shlex.split(str(l))
--> 213 id, label = splitline[0:2]
214 labels.append(label)
215 G.add_node(label)
ValueError: not enough values to unpack (expected 2, got 1)
With pip show networkx, I see that I'm running Networkx version: 2.3. Am I doing something wrong in the code?
Update: Pasting below the file's first few lines:
*Vertices 198
*Arcs
*Edges
1 8 1
1 24 1
1 35 1
1 42 1
1 46 1
1 60 1
1 74 1
1 78 1
According to the Pajek definition the first two lines of your file are not according to the standard. After *vertices n, n lines with details about the vertices are expected. In addition, *edges and *arcs is a duplicate. NetworkX assumes use for an edge list, which started with *arcs a MultiDiGraph and for *edges a MultiGraph (see current code). To resolve your problem, you only need to delete the first two lines of your .net-file.

How to handle such errors?

companies = pd.read_csv("http://www.richard-muir.com/data/public/csv/CompaniesRevenueEmployees.csv", index_col = 0)
companies.head()
I'm getting this error please suggest what approaches should be tried.
"utf-8' codec can't decode byte 0xb7 in position 7"
Try encoding as 'latin1' on macOS.
companies = pd.read_csv("http://www.richardmuir.com/data/public/csv/CompaniesRevenueEmployees.csv",
index_col=0,
encoding='latin1')
Downloading the file and opening it in notepad++ shows it is ansi-encoded. If you are on a windows system this should fix it:
import pandas as pd
url = "http://www.richard-muir.com/data/public/csv/CompaniesRevenueEmployees.csv"
companies = pd.read_csv(url, index_col = 0, encoding='ansi')
print(companies)
If not (on windows), you need to research how to convert ansi-encoded text to something you can read.
See: https://docs.python.org/3/library/codecs.html#standard-encodings
Output:
Name Industry \
0 Walmart Retail
1 Sinopec Group Oil and gas
2 China National Petroleum Corporation Oil and gas
... ... ...
47 Hewlett Packard Enterprise Electronics
48 Tata Group Conglomerate
Revenue (USD billions) Employees
0 482 2200000
1 455 358571
2 428 1636532
... ... ...
47 111 302000
48 108 600000

Open wish without stealing focus

I want to open a Tcl/Tk dialog on linux (kde,vnc) and put some information in:
package require Tk
toplevel .my
pack [label .my.l -text "hallo"]
Doing this, the dialog opens and the new dialog takes the focus.
How can I prevent this?
package require Tk
toplevel .my
<something with> .my
pack [label .my.l -text "hallo"]
I saw several question regarding the similar topic, but none for Tcl/Tk.
This is highly dependent on the window manager.
For metacity and marco, there is a setting called 'focus-new-windows' that can be changed to 'strict'.
Mate with marco window manager:
gsettings set org.mate.Marco.general focus-new-windows strict
I don't use KDE, but you can try:
System Settings -> Window Behaviour -> Focus
and see if there's a setting there that will help.
Compiz has a focus prevention setting in General Options -> Focus.
Here is my solution:
1 package require Tk
2 proc leave {w e} {
3 puts "gui left $w $e ..."
4 if {$e != $w} return
5 focusHandler::restore
6 }
7 proc press {w} {
8 puts "press $w"
9 focusHandler::save
10 bind $w <Leave> focusHandler::restore
11 wm overrideredirect [winfo toplevel $w] 0
12 raise $w
13 focus -force $w
14 wm overrideredirect [winfo toplevel $w] 1
15 }
16 namespace eval focusHandler {
17 variable helper
18 }
19 proc focusHandler::save {} {
20 variable helper
21 if ![info exists helper] {
22 puts "create helper"
23 set helper .xxx[clock clicks]
24 # create a new toplevel window
25 # this is controlled by the window manager
26 toplevel $helper
27 wm geometry $helper 0x0-1-1
28 }
29 puts "set focus of helper $helper"
30 raise $helper
31 update
32 after 100
33 }
34 proc focusHandler::restore {} {
35 variable helper
36 if ![info exists helper] return
37 # destroy this toplevel and windows manager focus on the last know window
38 # which is not this gui, because of overrideredirect
39 destroy $helper
40 unset helper
41 }
42 wm withdraw .
43 toplevel .my
44 wm overrideredirect .my 1
45 text .my.text -height 10 -width 40
46 button .my.exit -command exit -text exit
47 bind .my.text <ButtonPress-1> [list press %W]
48 pack .my.text
49 pack .my.exit

How to grep all the data in a specified col from standard output?

Now i have a standard output which is printed by my program and displayed on the screen. The outputs looks like the following part:
Parsing command line string 'InputFile = foreman.qcif'.
Parsing command line string 'NumberReferenceFrames = 1'.
Parsing command line string 'QPISlice = 24'.
Parsing command line string 'QPPSlice = 24'.
------------------------------- JM 11.0 (FRExt) --------------------------------
Input YUV file : foreman.qcif
Output H.264 bitstream : test.264
Output YUV file : test_rec.yuv
YUV Format : YUV 4:2:0
Frames to be encoded I-P/B : 150/0
PicInterlace / MbInterlace : 0/0
Transform8x8Mode : 1
-------------------------------------------------------------------------------
Frame Bit/pic QP SnrY SnrU SnrV Time(ms) MET(ms) Frm/Fld Ref
-------------------------------------------------------------------------------
0000(NVB) 168
0000(IDR) 34280 24 39.724 41.720 43.998 286 0 FRM 1
0002(P) 7432 24 38.857 41.565 43.829 402 99 FRM 1
0004(P) 8976 24 38.642 41.275 43.698 409 97 FRM 1
0006(P) 8344 24 38.427 41.266 43.515 407 99 FRM 1
0008(P) 8224 24 38.609 41.082 43.524 413 94 FRM 1
0010(P) 7784 24 38.655 40.991 43.235 406 95 FRM 1
0012(P) 7136 24 38.534 40.687 43.273 411 95 FRM 1
0014(P) 6688 24 38.464 40.756 43.146 410 92 FRM 1
0016(P) 7720 24 38.516 40.585 42.851 410 91 FRM 1
0018(P) 6864 24 38.474 40.631 42.958 411 101 FRM 1
0020(P) 8392 24 38.433 40.607 42.646 415 99 FRM 1
0022(P) 9744 24 38.371 40.554 42.498 416 94 FRM 1
0024(P) 8368 24 38.362 40.531 42.380 417 93 FRM 1
0026(P) 7904 24 38.414 40.586 42.415 418 95 FRM 1
0028(P) 8688 24 38.403 40.523 42.366 418 96 FRM 1
0030(P) 9128 24 38.545 40.390 42.661 416 89 FRM 1
0032(P) 9664 24 38.399 40.538 42.740 413 88 FRM 1
0034(P) 8928 24 38.394 40.590 42.852 414 95 FRM 1
0036(P) 10024 24 38.423 40.562 42.697 415 92 FRM 1
0038(P) 9320 24 38.442 40.389 42.689 414 94 FRM 1
0040(P) 7304 24 38.404 40.487 42.884 410 90 FRM 1
0042(P) 8560 24 38.447 40.590 42.673 411 95 FRM 1
.......
Now I only need to process the 4th col of SnrY.
So, my question is how to grep this rol and to store them in a data.txt file?
Then I can use plot tool or Matlab to plot the data trends with these data..
Any advices? Many thanks for your kind help!
Addition:
Since it needs to pick those data from standard output, do I need to use(add) the command provided by you in the command line to make it works during outputs those data
?
$ awk '/FRM/ { print $4 }' < in.txt > data.txt
Note: I'm just guessing that the interesting lines contain FRM. If this is not the case, you must come up with a different way to identify them.
tail -n+17 in.txt | cut -c 23-31
./cmd_that_generates_results | awk '/^[0-9]/{print $4}' > data.txt
Quick breakdown of awk statement:
/^[0-9]/ : match lines that start with a number
{print $4} : print out fourth column
(Updated): to address question "Since it needs to pick those data from standard output, do I need to use(add) the command provided by you in the command line to make it works during outputs those data ?"
You can use the commands given in answers by piping to them the standard output of your program using the pipe (|) command. The results can then be store into "data.txt" using >.
see example above. Similar techniques can be used for other solutions in this page.
$ ./command | awk 'BEGIN{RS="--+";FS="\n"} END{ for(i=1;i<=NF;i++){if($i ~ /^[0-9]/){m=split($i,a," ");if(a[4]) print a[4]}}}'
39.724
38.857
38.642
38.427
38.609
38.655
38.534
38.464
38.516
38.474
38.433
38.371
38.362
38.414
38.403
38.545
38.399
38.394
38.423
38.442
38.404
38.447
I am anticipating that the data you want to get
need not be after the 16th line, may be after the 17th , or 18th ,etc
or that FRM/Fld field may have different indicators,
or the 4th field may not be at the exact character position every time.
So the above just say: set record separator as the line with dashes "-" , so the last record is the whole data you need. then using the newline as field separator (FS="\n") , each field will be each line of data. Split them up with spaces and get element 4 of the splitted line. that will be your desired column.
This will match numbers like 38.4* in the fourth column:
grep -E '^([^ ]+[ ]+){3}38.4'

Resources