I want to take in a word such as "NAV" from the command line and use it as a command - console

Im trying to create a text based adventure game. It prompts the user for a command NAV SHLD PHAS LRS SRS EXIT.
I could easily make the commands related to numbers and do it that way, but that is not as cool. I want my code to be able to recognize that one of these phrases has been entered in console and proceed from there.
printf("NAV PHAS LRS SHLD DOCK EXIT \n");
printf("Command ? \n");
scanf("%c", &command);
This is how I tried to get the code to work and needless to say it does not.
The Variable "command" is a declared as a char "char command;"
Thank you for any help you can give me i've hit quite a roadblock here :(

Related

Return Key in Edit Command Mode Shortcuts - Jupyter Notebook

While willing to write ↩a as a new shortcut for the run all cells above command I could not find how to specify the return symbol in Jupyter Notebook.
Writing return-a or ↩-ain the Edit Command Mode does not work and the modifier is not specified in the help dialog.
Any idea?
Return is not a modifier so shortcut like ↩-a make little sens (pressing enter and A at the same time. ↩,a meaning Return key followed by A key make more sens, but Enter is so pervasive for many actions that it is not usable in user shortcuts. I would suggest you to open an issue on jupyter/notebook on GitHub to ask for return to be added as a convenient way to map to ↩ , though even if we do that we can't guaranty that it will work. If you are willing to try to code that yourself, have a look at keyboard.js, the mapping from enter to displaying ↩ is already done in quickhelp.js, for mac at least.

Commands not executing on keybind, but are executing from command pallet

Got an issue with keymapping commands:
https://www.youtube.com/watch?v=d5nrEO_t7Wo
As you can see in the video, when I call the commands by keyboard shortcut:
On the first attempt - the function isn't called.
On the second attempt - the function is called.
Where as, when I call the commands via the command pallet, the commands are called even on the first attempt. Not shown in the video, I can call the commands from the command pallet more than once without fail.
This leeds me to believe there is something wrong with my keymap.coffee:
'.editor:not(.mini)':
'shift-cmd-h': 'hex:view'
'alt-down':'editor:add-selection-below'
'alt-up':'editor:add-selection-above'
'.editor':
'cmd-k':'jxa:compile'
'shift-cmd-k':'jxa:compileApp'
'cmd-u':'jxa:execute'
However I can see nothing clearly wrong here... So perhaps there's something wrong with my init.js?
https://github.com/sancarn/JXA-Compile/blob/master/src/init.js
Any ideas?
This was solved by DamnedScholar here.
Okay, no. It's because cmd-k is bound to so many things. Go into Settings -> Keybindings and search for it and you'll see a lot of different things attached to it that are all bindings with multiple key presses. So when you press cmd-k, Atom waits to see what your next key press will be. You should consider using something different for jxa:compile.

find all _stringbetween occurrences within a webpage

I am working on an AutoIT script to find select messages withing a chatroom type webpage, I have no problem with placing the sent text between two special characters to make them easier to find, also to filter out all of the unwanted stuff. the problem that I am having is once the _stringbetween finds what it is looking for it doesn't continue looking. For testing I have the values returning in a GUI box. If there is a way to return all text between "^","^" it would solve my problem. Here is what i have so far
$html = _StringBetween(_INetGetSource('https://dtss.campfirenow.com/room/595835'), '^','^')
MsgBox(0, "title", $html[0])
also if anyone knows of a better way to pull select messages from campfire that would also solve my problem, maybe using the star feature... If you would like to look at the source code and api's of campfire they are available on GitHub
The _stringbetween return all occurences it will find.
You can make this simple test.
#include <array.au3>
$source="^test1^blabla^test2^blabla^test3^blabla^test4^blabla^test5^blabla"
$aRes=_StringBetween($Source,"^","^")
_ArrayDisplay($aRes)
For your source I don't now what's happening but test like this :
#include <array.au3>
$Source = BinaryToString(InetRead("https://dtss.campfirenow.com/room/595835"))
$aRes=_StringBetween($Source,"^","^")
_ArrayDisplay($aRes)
If the problem persist make a paste of your source code's page and post the link.

identify tabs in QT Qtabwidget

if anyone has a good example of how can I identify that the user have chosen a tab in a window using QT provide it to me. I searched on line and the provided code give me error .. so here what I am trying to do :
I have a main window which has 3 tabs I will mainly show the same video on all of them but in each will run different algorithm, so I don't want them to run all the time because it will consume lots of processing from my cpu, so I would like to only make it work when the user select or open the tab .. here what I tried :
QObject::connect(ui->tabWidget, SIGNAL(ui->tabWidget->currentChanged(int idx)), ui->label, SLOT(setNum(int idx)));
and it gives me this error
Object::connect: No such signal QTabWidget::ui->tabWidget->currentChanged(int idx)
When you write a connect statement, do not include variable names or parameter names in the SIGNAL or SLOT macros. i.e., you should write this:
QObject::connect(ui->tabWidget, SIGNAL(currentChanged(int)), ui->label, SLOT(setNum(int)));

QLabel setText not displaying text immediately before running other method

I have a basic label that is supposed to indicate to the user that the program is searching directories for several seconds. So it goes like...
self.label.setText(QString("Searching..."))
# method to search directories goes here
self.label.setText(QString("Search Complete"))
My problem is that the label never displays "Searching...". The execution always seems to jump straight to run the method to scan directories, and then the label text is set to "Search Complete" after the method which scans directories has finished.
I'd be grateful if someone could please explain why this is happening or suggest a better way to resolve the problem.
many thanks
Your "method to search directories" is blocking the GUI hence QLabel is not able to update the text. You can make your search routine asynchronous or go the easy way and force QLabel to update itself:
self.label.setText(QString("Searching..."))
self.label.repaint()
# method to search directories goes here
self.label.setText(QString("Search Complete"))
Add include:
#include <qapplication.h>
Let Qt process events:
self.label.setText(QString("Searching..."))
qApp->processEvents();
Note: repaint() was not necessarie.
In PyQt5, you don't need to use QString :
self.label.setText("Searching...")
self.label.repaint()
self.label.setText("Search Complete")

Resources