Hello everyone I am working on a secruity program Demo. The program should allow the user to enter a message, one character at a time. The program should then display the corresponding digit or punctuation according to the ASCII character set. For example, if the user enters the letter a, the program would display the character ! (exclamation point). The program should run until the user enters a character that is not one of the corresponding digits or punctuations.

Here is what I got so Far and its a little off

program SecurityCode;
#include( "stdlib.hhf" )
static

c:char;

begin SecurityCode;

stdout.put( "Enter in a short line of text ");


stdin.flushInput();

//This will repeat until it goes through all of the text entered
repeat

stdin.getc();

//Checks to see if the char is uppercase,
// changes them, then converts to ASCII
if( al >= 'A' && al <= 'Z' ) then

or( $20, al );
and( $BF, al );
stdout.putc( al );

//converts lowercase letters to ASCII
elseif( al >= 'a' && al <= 'z' ) then

and( $BF, al );
stdout.putc( al );


//everything else gets printed out
else

stdout.putc( al );


endif;

until( stdin.eoln() );

end SecurityCode;

It isnt accepting one character at a time and I am confused on how to do this. any help would be appreciated.

thanks

I don't know about the input, but are you sure you need to use and and or?

I see... So I should I use the "and" or the "or" which one works better I am not at home and cannot try it right now.. but I will tonight. Thanks Ill let you know

May I ask, what assembler accepts that syntax?

May I ask, what assembler accepts that syntax?

We use MASM32 with HLA and I figured out what was wrong I had to rewrite the program here it is

program security;

#include("stdlib.hhf")

static
	running:		boolean := true;
	c: char;
	
begin security;
 

  while(running) do

    stdout.put("Please enter a character: ");
    stdin.flushInput();
    stdin.getc(); // al stores the char
    
    if (al in {'A'..'Z'}) then
      // to lowercase
      or($20, al);      // same with add(32, al);
    endif;
		if (al in {'a'..'z'}) then
		  and($bf, al);     // same with add(-64, al);
		  mov(al, c);
		  stdout.put("The corresponding digit or punctuation is ", c, nl);

		else// if false will stop the program.
		  mov(false, running); // end loop
//stdout.put(al); it's work with it or without it. This code will give the user a message that tell YOU entered
// a wroge character. Like "Sorry, Please try angain" what ever you put. 
		endif;  
  endwhile;

end security;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.