Similar Threads:
1.Build your own Forth for Microchip PIC (Episode 837)
2.ANSI escape control codes for the Forth console
I was expecting that it would be a simple matter to send control
sequences (ANSI escape sequences for example) to the console which
would allow code to be written that can control the console in a
system independent way. But I don't seem to be able to find any Forth
code for this. When an app needs to put information on the screen in
other than a scrolling display, isn't there a simple, system
independent way to do that?
To be more clear, I am thinking that I can use
ESC emit [char] [ emit [char] 4 emit [char] ; emit [char] 6 emit
[char] H emit
to position the cursor at line 4 and column 6 on the screen.
The application will define fields on the screen for values and
labels. The user will be able to move the cursor using the arrow keys
and update some of the fields. Then pressing the Enter key the data
will be sent to the target. Results will be collected from the target
and displayed in the various fields. This will be a bit like the
register and memory display of a software debugger.
The idea was to be that the app would be written in a system
independent way, but it is looking like this is not going to be
practical.
Rick
3.Harbour ANSI C sprintf() for ANSI SQL.
This is a multi-part message in MIME format.
IMHO.-
I need to implement a sprintf () compatible ANSI C and ANSI SQL to generate HTML, mount SQL sentences of an effective way in
critical processes or simply mount messages of the application and debugging of a easy way.
Attach spd.c file, please check if it is Harbour compatible.
For my part is no objection to incorporate in the project if you consider it opportune.
----------------------------------
Tengo necesidad de implementar un sprintf() compatible ANSI C y ANSI SQL para poder generar HTML, montar sentencias SQL de una
forma efectiva en procesos cricos o sencillamente, montar mensajes de la aplicaci y de depuraci de una forma m simple.
Adjunto el fichero spd.c, por favor, chequear si es Harbour compatible.
Por mi parte no hay ning inconveniente en que se incorpore al proyecto si lo considers oportuno.
----------------------------------
Procedure Test()
Local i, n, k, nCount := 0, nMaxCount := 100000
Local cRes, cSQL, dFecha1 := Date() - 1, dFecha2 := Date() + 1
nCount := 17/13
cRes := _SPD( "%%%-3.2f%%%n SQL DATE %s%n SQL %s SQL %d SQL %s%n", ;
nCount, @i, dFecha1, @n, TRUE, FALSE, nil, @k )
? cRes // "%1.31% SQL DATE 2008-05-18 SQL TRUE SQL 0 SQL NULL"
? i, n, k // 6 26 50
cSQL := "SELECT * FROM Tabla WHERE Fecha >= '%s' AND Fecha < '%s'"
nCount := Seconds()
for i := 1 to nMaxCount
cRes := _SPD( cSQL, dFecha1, dFecha2 )
next
? _SPD( "%-3.2fs %s", Seconds() - nCount, cRes )
return
best regards
Xavi
4.help-Need Source code or example,control LCD using vhdl
The LCD controllor is ks0108b.just give me a example,to show me how to
control LCD use a state machine.
Thanks.
cehon
5.Need help understanding program control/flow.
Hi all! Newbie here.
Below is an example from Teach Yourself C in 21 Days. My apologies
if it is a bit long.
What I don't understand is how the "get_data" function can call the
"continue_function", and if NO is returned to "get_data", display_report
executes and the program ends? Basically I am having trouble understanding
the program flow within the "if" loop in the "main" function.
The "if" loops only initiates if cont=YES, so what happens if a function
in the loop(in this case get_data) gets cont=NO? Does this really mean
that if "something" within an "if" loop doesn't meet the condition of the
loop,
the result is that the next statement below the "something" gets executed
and the the "if" loop is exited?
Hope I made myself clear.
Thanks in advance!
===============================================================================
#include <stdio.h>
#define MAX 100
#define YES 1
#define NO 0
/*--------------------*/
/* variables */
/*--------------------*/
long income[MAX]; /* to hold incomes */
int month[MAX], day[MAX], year[MAX]; /* to hold birthdays */
int x, y, ctr; /* For counters */
int cont; /* For program control */
long month_total, grand_total; /* For totals */
/*--------------------*/
/* function prototypes*/
/*--------------------*/
int main(void);
int display_instructions(void);
void get_data(void);
void display_report(void);
int continue_function(void);
/*--------------------*/
/* start of program */
/*--------------------*/
int main(void)
{
cont = display_instructions();
if ( cont == YES ) /* <================================ LOOK HERE!
*/
{
get_data();
display_report();
}
else
printf( "\nProgram Aborted by User!\n\n");
return 0;
}
/*-----------------------------------------------------------*
* Function: display_instructions() *
* Purpose: This function displays information on how to *
* use this program and asks the user to enter 0 *
* to quit, or 1 to continue. *
* Returns: NO - if user enters 0 *
* YES - if user enters any number other than 0 *
*-----------------------------------------------------------*/
int display_instructions( void )
{
printf("\n\n");
printf("\nThis program enables you to enter up to 99 people\'s ");
printf("\nincomes and birthdays. It then prints the incomes by");
printf("\nmonth along with the overall income and overall average.");
printf("\n");
cont = continue_function();
return( cont );
}
/*-------------------------------------------------------------*
* Function: get_data() *
* Purpose: This function gets the data from the user. It *
* continues to get data until either 100 people are *
* entered, or until the user enters 0 for the month.*
* Returns: nothing *
* Notes: This allows 0/0/0 to be entered for birthdays in *
* case the user is unsure. It also allows for 31 *
* days in each month. *
*-------------------------------------------------------------*/
void get_data(void)
{
for ( cont = YES, ctr = 0; ctr < MAX && cont == YES; ctr++ )
{
printf("\nEnter information for Person %d.", ctr+1 );
printf("\n\tEnter Birthday:");
do
{
printf("\n\tMonth (0 - 12): ");
scanf("%d", &month[ctr]);
}while (month[ctr] < 0 || month[ctr] > 12 );
do
{
printf("\n\tDay (0 - 31): ");
scanf("%d", &day[ctr]);
}while ( day[ctr] < 0 || day[ctr] > 31 );
do
{
printf("\n\tYear (0 - 2002): ");
scanf("%d", &year[ctr]);
}while ( year[ctr] < 0 || year[ctr] > 2002 );
printf("\nEnter Yearly Income (whole dollars): ");
scanf("%ld", &income[ctr]);
cont = continue_function(); /*
<===================================== LOOK HERE! */
}
/* ctr equals the number of people that were entered. */
}
/*----------------------------------------------------------*
* Function: display_report() *
* Purpose: This function displays a report to the screen *
* Returns: nothing *
* Notes: More information could be printed. *
*----------------------------------------------------------*/
void display_report()
{
grand_total = 0;
printf("\n\n\n"); /* skip a few lines */
printf("\n SALARY SUMMARY");
printf("\n ==============");
for( x = 0; x <= 12; x++ ) /* for each month, including 0*/
{
month_total = 0;
for( y = 0; y < ctr; y++ )
{
if( month[y] == x )
month_total += income[y];
}
printf("\nTotal for month %d is %ld", x, month_total);
grand_total += month_total;
}
printf("\n\nReport totals:");
printf("\nTotal Income is %ld", grand_total);
printf("\nAverage Income is %ld", grand_total/ctr );
printf("\n\n* * * End of Report * * *\n");
}
/*----------------------------------------------------------------*
* Function: continue_function() *
* Purpose: This function asks the user if they wish to continue.*
* Returns: YES - if user wishes to continue *
* NO - if user wishes to quit *
*----------------------------------------------------------------*/
int continue_function( void )
{
printf("\n\nDo you wish to continue? (0=NO/1=YES): ");
scanf( "%d", &x );
while( x < 0 || x > 1 )
{
printf("\n%d is invalid!", x);
printf("\nPlease enter 0 to Quit or 1 to Continue: ");
scanf("%d", &x);
}
if(x == 0)
return(NO);
else
return(YES);
}
==================================================================================
6. Need more control over keyboard input
7. F90 coder needs help with F77-style control flow
8. need fast table-based control flow