C - Is there a way to remove a mvwprintw from my window? (Ncurses) - c

I want my mvwprintw statement to disappear after a point in the code. I don't know how delete the print statement though. Is there a print function that can do it? I tried by creating another statement full of spaces thinking it would overlap the existing statement and it would look blank. I tried looking online but could not find anything. Please let me know if there is a way.

You can clear the whole line by moving to the beginning of a line
move(3,0);
and then clearing the line
clrtoeol();

I actually found a way, hopefully this helps someone with the same problem in the future. All you need to do is to add \rat the beginning of your statement and it will over wright anything previously in that spot.
mvwprintw(win2,3,16,"Hi.");
mvwprintw(win2,3,16,"\rPlease make your first move."); //overwrites the "Hi"
mvwprintw(win2,3,16,"\rPlease make your second move.");//overwrites the "Please make your first move"
Adding blank spaces into the print statement would erase your previous message.

Related

LogicApp Split and Replace having problems with \n

I have been trying to split a string into an array of each line \n
As this doesn't work I tried replacing replace(outputs('Compose_6'),'\r\n','#') with a view to then splitting on #.
I have searched the internet and tried various things but nothing seems to work.
Can someone explain how to do this?
Thanks in advance
Using split(variables('string var'),'\n') expression, you can split string into array. By default logic app will add an extra black slash to original back slash. So suggesting you to change expression in code view as mentioned above.
I have created logic app as shown below,
In first initialize variable action, taken a string variable with text as shown below
Hello
Test split functionality
Using logic apps
Next initialize variable action, using a array variable and assigning value using expression as split(variables('string var'),'\n'). Make sure you dont have double back slash added in code view. Only one back slash should be there when you see it in code view.
Code view:
The output of logic app can be shown below,
Refer this SO thread.

Why is my Exitbutton in my screen disabled? (ABAP)

I read something about the ok-code but I cant really understand how it works and how I have to implement it.
I tried implementing a MODULE in the PAI for my Buttons but they are not working either.
MODULE test INPUT.
case sy-ucomm.
when 'BTN_01'.
call screen 0.
endcase.
ENDMODULE.
Thanks!
There are not enough details to give a real answer, so my answer is kind of a guess.
In your title you mention a "Exitbutton". Has the button the function type "E"?
If yes, then maybe you better use
MODULE ... AT EXIT-COMMAND.
Another hint:
To see what happens, you may enter /h in the OK-code field (activate debugging, 'Hoppelmodus' :) ). Then push your button and hopefully you can see step by step what happens.
SOLVED
MODULE status_9000 OUTPUT.
SET PF-STATUS 'STATUS9000'.
SET TITLEBAR 'TITLE9000'.
ENDMODULE.
I had to create a PF-STATUS for my screen (i named it 'STATUS9000').
Functionbuttons-> Symbols-> Set Exit-Button FNCT-CODE EXIT
MODULE user_command_9100 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
*now if you click the red exit-button (which we gave a fnct-code[exit]) the ok_code has 'EXIT' as his value.
WHEN 'BACK'.
LEAVE TO SCREEN 9000.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
ok-code = 'EXIT' after we pressed the exit-button, so we are going to leave the program.

In there a convenient way to have multiline input in libedit/editline

Using libedit/editline, and trying to figure out a good way to do multiline input/editing. The target is an SQL client, where queries will often span multiple lines and terminate with ;.
I can call el_gets, and process each line of input, stopping when I see the terminating ;. I can even concatenate those and store them as a single entry in el_history - and it will correctly access them when using the arrows to scroll through history.
However, when entering the command and after starting a new line, I can no longer use the arrows to move up and edit the previous line. E.g.:
prompt> SELECT * FROM table
WHERE 🀫
At that point, I'd like to be able to use the up-arrow, to move up and edit the text already entered on the first line. Is this possible? How would one do so? I assume that using el_gets isn't correct in this case, since it would remove the line from the editline buffering, yet I don't see an alternative API that would work.
Thoughts?

Breakable loop in Scratch?

How do you make a breakable loop in Scratch? I'm using Scratch 2.0 and can't find any good way to make a loop breakable, from inside of the loop itself.
Disclaimer:
There is no perfect way to do it. If you can possibly stand this true fact then feel free to continue.
There are a few different ways you could do it.
With repeat until
The first and most simple one follows this:
But this isn't technically part of the script - it's just repeating until some value returns true.
With a custom block (stop this script)
In order to do it inside of the script, you'll need to use a sneaky little trick with custom blocks.
Create a custom block called whatever you want - but probably along the lines of "breakable loop". Inside of it, create this script:
By using stop script we are breaking out of the script that is currently running - which, according to Scratch, is the custom block.
See the result! (as scratchblocks)
With broadcast and wait
You could also use a broadcast-and-wait method, very similar to above:
Though I highly suggest you don't use this method, as if any other sprites have breakable loops you'll need to rename each one, which can be tedious after using a lot of loops in a lot of sprites!
(Note this bug has been fixed in version 442 of the editor and such the following no longer applies.)
Help! My project is lagging a bunch now!
As #foi has noticed, if your code must be run inside of a frame you probably checked run without screen refresh. Unfortunately, due to a bug in the Scratch player, this causes the program to essentially break after the stop this script block has been activated. How can you handle this?
It follows the same principle you use when you use a run without screen refresh custom block inside of a forever loop - the loop doesn't use screen refresh while the inside does, allowing for instant animations whether or not one is using turbo mode.
Here's an example - the image is really too long to be embedded, so see it here instead.
You can make a variable inside or outside of the repeat and make your script like this:
repeat until [[my variable] = [e.g: 1]]
your code
your code
your code
your code
end of repeat until
For a "repeat until" block the simplest way would be to "or" your normal until condition with the break condition in the until.
By adding an incremeting loop counter variable in the loop you can use a "repeat until" to replicate the function of a "repeat n times" block
By using a "repeat until" block with only your break condition you get the equivalent of a "forever" block
If you need another script/ sprite to trigger the break then a public variable will let you break the loop from anywhere and let a single condition break loops for different sprites.
I'd post an image of the blocks but this is my first reply and the site won't let me!
good luck
You can use these few ways to do it...
conditional loop
stop this script
if then else, in the else section, put nothing
I would prefer to use the first method, as it requires less blocks and for the first method, you can still add in code that will be executed after the loop has stopped executing.
You can make it repeat x times or make it have a certain point where it stops, such as another variable changing.
Otherwise, I don't think there is a wat to do that.
Use the repeat until block. Then put in an equals block or whatever into the boolean part. Then inside that repeat until block, put a stop this script block.
Hope this helps :D

How to select options based on character user input stored in an array in C?

I may have worded that strange, but if you need clarification I can provide it. I'm a complete noob to coding and am learning to use C language.
I have printed out a menu of options for the user to select. The user input is read and stored into a character array. I then printed out the string back to the user. So far everything works to this point.
My issue is selecting an option based on this character input.
I tried using strcmp inside if-else statements but never get the correct output.
Can someone point me into the right direction?

Resources