%ver 2.0
%decimale
srt=0;
miss=0;
srtvl=0;
if ncase

	h_1  = WndCreat ([], "Gentab Multiple Disrete Values", [NaN,NaN,320,448], 2);
	h_2  = CtrCreat (h_1, 110, [249,393,59,23], "Paste","paste");
	h_3  = CtrCreat (h_1, 110, [183,393,59,23], "Cancel","WndClose(h_1)");
	h_4  = CtrCreat (h_1, 110, [117,393,59,23], "OK","ok");
	
	CtrCreat (h_1, 510, [11,11,144,13], "All varaibles in file:");
	h_5  = CtrCreat (h_1, 320, [8,25,113,199], lcase(GetVarName(1:nvar)));
	CtrCreat (h_1, 510, [196,11,100,13], "Varaible(s):");
	h_6  = CtrCreat (h_1, 320, [193,25,113,69], "");
	CtrCreat (h_1, 510, [196,102,100,13], "Columns:");
	h_7  = CtrCreat (h_1, 320, [193,116,113,69], "");
	CtrCreat (h_1, 510, [196,193,100,13], "Base:");
	h_16  = CtrCreat (h_1, 310, [193,207,113,17], "");
	CtrMaxList(h_16,1);
	
	h_8 = CtrCreat (h_1, 150, [136,53,41,15], "","");
	h_9 = CtrCreat (h_1, 150, [136,145,41,15], "","");
	h_17 = CtrCreat (h_1, 150, [136,209,41,15], "","");
	
	CtrConect(h_8,h_5,h_6);
	CtrConect(h_9,h_5,h_7);
	CtrConect(h_17,h_5,h_16);
	
	CtrCreat (h_1, 140, [187,233,121,69], "Number of decimals","");
	CtrCreat (h_1, 510, [195,252, 80,13], "First column:");
	h_19 = CtrCreat (h_1, 410, [275,249,21,19], "1");
	CtrCreat (h_1, 510, [195,276, 80,13], "Other columns:");
	h_20 = CtrCreat (h_1, 410, [275,273,21,19], "0");
	
	
	CtrCreat (h_1, 140, [9,233,169,69], "Target answer","f()");
	CtrCreat (h_1, 510, [30,255,140,13], "Code value for 'Yes' answer");
	h_14 = CtrCreat (h_1, 410, [69,273,49,19], "1");
	
	CtrCreat (h_1, 140, [9,304,300,85], "Parameters","");
	h_11 = CtrCreat (h_1, 130, [21,322,169,17], "Sort descending","srt=~srt;");
	CtrCreat (h_1, 510, [ 21,367,40,13], "Label:");
	h_12 = CtrCreat (h_1, 410, [63,364,239,19], "GenTabMD");
	
	
	CtrCreat (h_1, 510, [21,343,240,13], "Number of significant levels for coloring (1, 2 or 3):");
	h_15 = CtrCreat (h_1, 410, [265,340,37,19], "2");
else
	MsgBox([],"Morate prvo ucitati SPSS podatke");
end

macro paste
	vars=CtrGet(h_6);
	if size(vars,1)==0
		MsgBox(h_1,"Fale varijable za obradu!",1);
		return;
	end
	str = "\n\n!gentabmd vars=";
	for i=1:max(size(vars))
		str = str+" "+vars(i);
	end
	kol1=CtrGet(h_7);
	if size(kol1,1)
		str = str+"/\n          kol1=";
		for i=1:max(size(kol1))
			str = str+" "+kol1(i);
		end
	end
	base=CtrGet(h_16);
	if size(base,1)
		str = str+"/\n          base= "+base(1);
	end
	if srt
		str = str+"/\n          sort= yes";
	end
	value = CtrGet(h_14);
	if size(value,1)
		str = str + "/\n          value= " + value(1);
	else
		MsgBox("Morate specificirati vrednost 'Da' odgovora");
		return; 
	end
	labela = CtrGet(h_12);
	if size(labela,1)
		str = str + "/\n          labela= "+labela(1);
	end
	color = CtrGet(h_15);
	if size(color,1)
		if strcmp("3",color)
			str = str+"/\n          color= "+color;
		end
	else
		str = str+"/\n          color= 3";
	end
	str = str + "/\n          decimal= " + CtrGet(h_19) + " " + CtrGet(h_20);
	str = str+" .";
	syntax(str);
	WndClose(h_1);
end

macro ok
	vars=CtrGet(h_6)';
	if size(vars,1)==0
		MsgBox(h_1,"Fale varijable za obradu!",1);
		return;
	end
	kol1=CtrGet(h_7)';
	base=CtrGet(h_16);
	value = CtrGet(h_14);
	if ~size(value,1)
		MsgBox("Morate specificirati vrednost 'Da' odgovora");
		return; 
	end
	labela = CtrGet(h_12);
	if srt
		srt = "YES";
	else
		srt="NO";
	end
	color = CtrGet(h_15);
	decimal= [CtrGet(h_19),CtrGet(h_20)];
	WndClose(h_1);
	gentabmd(vars,kol1,[],[],srt,color,decimal,base,value,labela);
end