Announcement

Collapse
No announcement yet.

Need Programming Advice (basic stuff)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need Programming Advice (basic stuff)

    I know this place is teeming with expert coders, so this should be a cinch for most of you.

    I'm working in C('89) and all I want to do is make a program wherein I press a key and a specific (but different) character appears onscreen. For example, if I press the '1' key, I want 'b' to appear rather than '1'; if I press the '1' key twice, I want 'p' to appear (replacing the previous 'b', not following it). Some keys must summon as many as three characters in a row (e.g. pressing 'c' and getting 'ang'). I don't want the onscreen character to be set in stone until a new/different key is pressed (so if I press '1' '1' 's', for example, 'p' 'ai' would be displayed).

    Is C the right language to be doing this in? My ultimate goal is an executable running in Terminal (or whatever). Basically the user types away, and stuff appears on screen.

    Any help would be much appreciated!!




    P.S. If anyone is curious about what this is for, here is a hint:


  • #2
    If you have a definite character set, you could do this in many languages (even web based scripting languages like javascript); what you have to do is have the program wait for input, once input is received it adds a counter to that given character and waits again, if the same keystroke is pressed, it adds another counter to the current queue, however if another key is pressed, it displays the text for the previous key stroke (plus counters) and adds a counter for the current keystroke...

    Here's a mock up flowchart I made to demonstrate what I mean:

    https://www.lucidchart.com/documents...c-2bdf0a00db1e
    Last edited by Project Omega; 10-31-2013, 01:44 PM. Reason: Elaborating the language bit to include web based languages

    Comment


    • #3
      This is excellent and very helpful, thank you! I've since decided that I want to make this IME into an Android/iOS app, so perhaps Objective C would be best. Nevertheless, it is the logic that is important.

      Comment

      Working...
      X