[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference clt::smg

Title:Screen ManaGement Discussions
Moderator:SSPADE::HIDER
Created:Fri Jan 24 1986
Last Modified:Mon Jun 02 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1567
Total number of notes:4697

1567.0. "SMG$PUT_CHARS problem on AXP." by AUBER::COSTEUX (France: pays d'assist�s...) Mon Jun 02 1997 05:13

    Can somebody help finding what is wrong in the example below (problem
    when run on Axp but the same program works fine on Vax):
    
    - main program:
    

/* paye *****************************************************************
 *         menu general de la paye					*
 ************************************************************************/

/*
# include "appli.h"
# include "fenetre.h"
exec sql include sqlca.h;
*/
#define S_NORMAL 0

main()

{

/**
	exec sql begin declare section;
		varchar	admin[51], passwd[51];
	exec sql end declare section;
**/

	char	ch[81];
	short	fen, ish;
	long	lsh;
	double	mt2, mt;

/**
	strcpy(admin.arr, "EXA35");	admin.len = strlen(admin.arr);
	strcpy(passwd.arr, "EXA35");	passwd.len = strlen(passwd.arr);

	exec sql connect :admin identified by :passwd;
	s_init("ESSAI");

	fen = s_ouvre_fenetre(40,20,S_OUI);
	s_aff_fenetre(fen, 2, 15);
**/
	mt = 13456.45;
	mt2 = 22222.55;
	ish = 345;
	lsh = 123456L;
	s_pr( fen, 4, 5, S_NORMAL, "Montant    : %9.02lf  mt2:%8.02lf", 
						mt, mt2);
	s_pr( fen, 10, 5, S_NORMAL, "Chaine: %s _ %s", 
		"chaine1", "chaine2");
	s_pr( fen, 12, 5, S_NORMAL, "Short: %d _ %d",  23, 44);
	s_pr( fen, 14, 5, S_NORMAL, "Long : %ld _ %ld",  123456L, 4567890L);

/*	s_pr( fen, 5, 5, S_NORMAL, "SHORT      : %4d", ish);
	s_pr( fen, 6, 5, S_NORMAL, "LONG       : %7ld", lsh);
	sprintf(ch, "%9.02lf", mt);
*/	getchar();
}

    
    - function called:
    
/*s_pr************************************************************************
 * affichage dans une fenetre d'un ecran virtuel                             *
 *****************************************************************************/
# include "fenetre.h"

s_pr(num,lig,col,type,cmd,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)

char	*cmd;
int	num, lig, col, type;

{           

	char	ch1[80], data[80];
	int	i, j;
	$DESCRIPTOR (dat,data);

/*printf("\nDEBUT S_PR");
printf("\nS_PR _ DATA:%s", data);getchar();
*/
	sprintf(data,cmd,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);

/*printf("\nS_PR _ CMD :%s", cmd);getchar();
printf("\nS_PR _ DATA:%s", data);getchar();
*/
	dat.dsc$w_length = strlen(data);

	i = SMG$PUT_CHARS(&fenetre[num].num_fenetre,&dat,&lig,&col,0,&type);
	
	if ( i == SMG$_INVROW )
	{
		sprintf(ch1,"'s_pr':d�bordemment de ligne %d",lig);
/*		j = s_message(ch1,S_OUI); */
	}
	else if ( i == SMG$_INVCOL )
	{
		sprintf(ch1,"'s_pr':d�bordemment de colonne %d",col);
/*		j = s_message(ch1,S_OUI); */
	}
/*	else sys_erreur_msg( i ); */
	/*else s_erreur(i);*/
}


    
    ... whereas the values in the variables mt and mt2 are non null values
    (as stated under the Debugger), each time SMG$PUT_CHARS is called the
    value 00.00 is displayed as the value for mt. The value mt2 is however
    correctly displayed. This behavior only occurs while trying to display
    the value of the variable mt. All others variables are correctly
    displayed.
    
    Thanks in advance for help.
    
    Jean-Pierre
    
T.RTitleUserPersonal
Name
DateLines
1567.1exitSSPADE::GRECOMon Jun 02 1997 09:323
    Can you supply the include file fenetre.h?
    
    Frank
1567.2Here are the included files. Thanks.PADKOA::COSTEUXFrance: pays d'assist�s...Mon Jun 02 1997 09:47211
    Thanks for help.
    
    Here are the files:
    
    - fenetre.h <******************************
    

/*fenetre*********************************************************************
 * header du gestionnaire d'ecran C-VMS (SMG$)                               *
 *****************************************************************************/

# include <stdio.h>

/*
# include <car.h>
*/

# include descrip
# include smgdef

# define S_MAX_FENETRE	300

# define NETWORK	1
# define BATCH		2
# define INTERACTIF	3

# define OK		1
# define NOK		0

# define S_OUI		1
# define S_NON		2

# define S_VISIBLE	1
# define S_INVISIBLE	2

# define S_HORI		1
# define S_VERT		2

# define S_NORMAL 	0
# define S_INVERSE	SMG$M_REVERSE
# define S_SOULIGNE 	SMG$M_UNDERLINE
# define S_INTENSE 	SMG$M_BOLD
# define S_CLIGNOTE	SMG$M_BLINK

# define S_DOWN		SMG$M_DOWN
# define S_UP  		SMG$M_UP
# define S_RIGHT	SMG$M_RIGHT
# define S_LEFT		SMG$M_LEFT

# define S_LIGNE	1
# define S_PAGE		2
# define S_DEMIPAGE     3
# define S_PAGE_1	4


# define REMPLACEMENT	1
# define INSERTION	2

# define SAI_STR	1
# define SAI_NBR	2
# define SAI_DEC	3
# define SAI_HR		4
# define SAI_JMA	5
# define SAI_JMAA	6

char	s_user[30];
char	s_application[30];
int	s_num_pid;
int	s_num_clavier;
int	s_num_ecran_physique;

struct fenetre {
	short	etat;
	int	num_fenetre;
	short	lig;
	short	col;
} fenetre[S_MAX_FENETRE];

# define	MAX_NIVEAU	5
# define	MAX_CHOIX	20

struct menu0 {
	char	lib_sup[30];
	char	lib_inf[30];
	short	col;
	short	lg;
	short	action;
} menu0[9];	    

struct ss_menu {
	short	max_menu;
	struct menu {    
		int    	num_fenetre;
		short	max_lib;
		short	max_lg;
		char   	lib[MAX_CHOIX+1][70];
		short  	type[MAX_CHOIX+1];
		short  	action[MAX_CHOIX+1];
	} menu[100];
} ss_menu[MAX_NIVEAU+1];

struct param_menu {
	short	premier_passage;
	short	nb_menu0;
	int	num_menu0;
	int	num_pied;
	short	menu0_val;
	short	menu_val[MAX_NIVEAU+1];
	short	menu_lig[MAX_NIVEAU+1];
	short	niveau;
};

struct param_menu param_menu = {S_OUI,0,0,0,0};

struct	def_sai_code {
	char	choix[300][60];
	short	nb;
} def_sai_code;


struct	param_saisie {
	short	mode;
        short	num_pied;
	short	lg;
	char	ch_initiale[256];
	double	bmin;
	double	bmax;
} param_saisie;

    
    
    	- appli.h  <***********************************
    
    
# define	OUI		1
# define	NON		2

# define	OK		1
# define	NOK		0

# define	AUTRE		0
# define	RESEAU		1
# define	BATCH		2
# define	INTERACTIF	3

# define	DIRECTE		1
# define	DIFFERE		2

# define	NORMAL		1
# define	NOR_VIDEO	1
# define	INVERSE	 	2
# define	INV_VIDEO       2
# define	CLIGNOTE	3
# define	SOULIGNE	4
# define	INTENSE		5
# define	SLSH		6
# define	DLSH		7
# define	DLDH		8

# define	PHYSIQUE	1
# define	VIRTUEL		2

# define	J     		0 /* JOUR pour stdrt */
# define	M     		1 /* MOIS pour strdt */
# define	A     		2 /* AN   pour strdt */

# define	JJMMAA		1
# define	JJMM		2
# define	MMAA		3
# define	SRT		4
# define	SHORT		5
# define	LONG		6
# define	CODE		7
# define	JJMMAAAA	8

# define	BS		127
# define	VALIDER		270
# define	RETN		13
# define	HOME		7
# define	KEY_RIGHT	277
# define	KEY_LEFT	276
# define	KEY_UP		274
# define	KEY_DOWN	275
# define	NEXT_PAGE	316
# define	PREV_PAGE	315
# define	INSRT_CHAR	11
# define	DEL_CHAR	12
# define	INSRT_LINE	13
# define	DEL_LINE	14
# define	RECH		311
# define	SELECTION	314
# define	DEL		127
# define	BELL		'\007'

# define	F1		291
# define	F2		292
# define	F3		293
# define	F4		294
# define	F5		295
# define	F6		296
# define	F7		297
# define	F8		298
# define	F9		299
# define	F10		300
# define	PF1		256
# define	PF2		257
# define	PF3		258
# define	PF4		259


    
1567.3Crossposted in the VAXC conference (note #5611)PADKOA::COSTEUXFrance: pays d&#039;assist�s...Mon Jun 02 1997 11:564
    I crossposted a similar note in the VAXC conference as the problem
    seams more a DECC problem than anything else ...
    
    Jean-Pierre
1567.4SPECXN::DERAMODan D&#039;EramoMon Jun 02 1997 12:2236
	You just can't do this...it isn't legal C.  It doesn't work.
        
>	s_pr( fen, 4, 5, S_NORMAL, "Montant    : %9.02lf  mt2:%8.02lf", 
>						mt, mt2);
        
>s_pr(num,lig,col,type,cmd,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
>
>char	*cmd;
>int	num, lig, col, type;
>
>{           
[...]
>	sprintf(data,cmd,arg0,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
        
        The only way to write s_pr is to prototype it with the "..."
        before calling it and then define it using <stdarg.h>.
        
        Dan
        
#include <stdarg.h>
void s_pr(int num, int lig, int col, int type, const char *cmd, ...);
        
/* Now that the above prototype has been seen it is okay to call s_pr. */
        
/* Here's how the definition calls sprintf... */
void s_pr(int num, int lig, int col, int type, const char *cmd, ...)
{
    va_list ap;
    char data[80];
        
    va_start(ap, cmd);
    vsprintf(data, cmd, ap);
    va_end(ap);
        
    /* ... */
}