WriteHtmlVariable(fd, AnyValue);? Compiler Error??

Topics for the Eclipse Environment
Post Reply
Kiwinet
Posts: 31
Joined: Wed Jun 24, 2009 4:20 am

WriteHtmlVariable(fd, AnyValue);? Compiler Error??

Post by Kiwinet »

I'm just about almost there posting data from a serial port onto a webpage, but
Eclipse is reporting errors when I try to dynamically display the captured variable on the webpage!

There is no Eclipse compiler error when I run this sample code below, so far so good!

WriteHtmlVariable(fd, TimeTick/TICKS_PER_SECOND);

Embedded on WebPage <!--VARIABLE TimeTick/TICKS_PER_SECOND -->

However if I substitute this bit of simple sample code with my own variable there is a compiler error?
Eclipse doesn't really tell me, where I have gone wrong?

int AnyValue=24; ; // I’ve declared my own value of variable here
WriteHtmlVariable(fd, AnyValue);

Embedded somewhere on my WebPage <!--VARIABLE AnyValue -->

This generates the following from the compiler

In file included from htmldata.cpp:3623:
HtmlVar.h:10:23: warning: no newline at end of file
htmldata.cpp: In function 'int DoHtmlVariable(int, WORD)':
htmldata.cpp:3629: error: 'AnyValue' was not declared in this scope
Build error occurred, build is stopped
Time consumed: 4078 ms.

Grateful for any insight into this puzzle thanks -It may have something to do with mixing extern C++ functions with C generated parameters?

Paul
Last edited by Kiwinet on Fri Dec 11, 2009 3:33 am, edited 1 time in total.
Kiwinet
Posts: 31
Joined: Wed Jun 24, 2009 4:20 am

Re: WriteHtmlVariable(fd, AnyValue);? Compiler Error??

Post by Kiwinet »

On closer inspection, I have previously written code called

<!--FUNCTIONCALL PassMyValue --> [embedded within a HTML page]

, with its corresponding call function

void PassMyValue (int sock, PCSTR url)

which will pass the desired variable to the webpage, and I don't get any more errors from Eclipse.

Morale of the story - there is more than just one way to skin a cat!
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: WriteHtmlVariable(fd, AnyValue);? Compiler Error??

Post by rnixon »

You didn't mention where you declared
int AnyValue=24; ; // I’ve declared my own value of variable here

I think you need to declare it in your code, but also reference it in htmlvars.h. If its not in htmlvars.h, the web services can't see it.
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: WriteHtmlVariable(fd, AnyValue);? Compiler Error??

Post by tod »

In the final solution you came up with you can also write out an entire javascript object in case you want to capture the state of a bunch of variables with a single function callback. You would write out something like

Code: Select all

var  someObjectName = 
{
   VariableName1: ValueForVariable1,
   VariableName2: ValueForVariable2,
                         etc....      
   LastVariableName: ValueForLastVariable                 
}

There is an example of this in my recent post on AJAX, and don't be put off by the fact that the post was primarily about AJAX, the whole section that deals with the above topic ( it's the section about machineState in my code) has nothing to do with AJAX it is just a simple Function callback. Once you start passing back valid JSON objects you'll find it is a lot easier to start using those objects in code.
Kiwinet
Posts: 31
Joined: Wed Jun 24, 2009 4:20 am

Re: WriteHtmlVariable(fd, AnyValue);? Compiler Error??

Post by Kiwinet »

rnixon wrote:You didn't mention where you declared
int AnyValue=24; ; // I’ve declared my own value of variable here

I think you need to declare it in your code, but also reference it in htmlvars.h. If its not in htmlvars.h, the web services can't see it.
Very much appreciated for suggesting editing the htmlvars header file - it definately worked, no more compiler errors!
Coming originally from a Borland C compilier environment, I have had it too easy so far compared to mastering the more complex Eclipse environment :)
Kiwinet
Posts: 31
Joined: Wed Jun 24, 2009 4:20 am

Re: WriteHtmlVariable(fd, AnyValue);? Compiler Error??

Post by Kiwinet »

tod wrote:In the final solution you came up with you can also write out an entire javascript object in case you want to capture the state of a bunch of variables with a single function callback. You would write out something like ..........
.
Yes Tod appeciate your advice, it does sound like an elegant well crafted solution with the Ajax implementation.
I may consider this single function callback option sometime later when building a weather station perhaps, where there is a requirement for lots of external disparate variable sources to display and monitor at once.
For the time being, I'm just getting familiar with the web based FLASH Actionscript where the underlying TCP socket calls can be passed through the NB module. ;)
Post Reply