Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Samples

Console input/output

A community discussion post from the original code:zIRON forum.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Console input/output

A sample compilable with 1.1.34.7+

program WIN32CUI 'test';

#include 'ch.zir';

char buf[32];

repeat {
	print('Enter command: ');
	edx = gets(@buf, 32);
	al = [edx];
	
	case (al) {
		
		state "q":
			if (strCmp(edx, 'quit') == true) {
				print('Goodbye!\r\n');
				break 1;
			} else {
				goto @casedef;
			}
			break;
			
		state "h":
			if (strCmp(edx, 'help') == true) {
				print('  ********** HELP **********  \r\nhelp\t-\tDisplay this help\r\nquit\t-\tQuit application\r\nspam\t-\tPrint 1000 spam messages\r\n/ ************************** /\r\n');
			} else {
				goto @casedef;
			}
			break;		
			
		state "s":
			if (strCmp(edx, 'spam') == true) {
				for (ecx = 1 to 1000) {
					print('spam ', ecx:int, '\r\n');
				}
			} else {
				goto @casedef;
			}
			break;
			
		default:
			@casedef:
			print('Unknown command: ', edx:string, '\r\n');
			break;
		
	}
	
};

wait_key();
ExitProcess(0);