SetText to the value of a string variable.

Support forum for MegunoLink
Post Reply
bradleywoods
Posts: 2
Joined: Mon May 30, 2016 1:22 am

Mon May 30, 2016 1:30 am

OK, this seems like it should be a no-brainer, what am I missing?

Why does this work:

Code: Select all

  UserControl1.SetText("TextBox1", "foo");
But this fails:

Code: Select all

  testing = "foo";
  UserControl1.SetText("TextBox1", testing);
I've spent hours on these 2 lines of code. My head is about to pop. What am I missing?

Example 2 absolutely will not compile. Complete error dump below.

Thanks,
-Brad



Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Uno"

Auto_Caliper_Serial2.ino: In function 'void loop()':
Auto_Caliper_Serial2:77: error: no matching function for call to 'InterfacePanel::SetText(const __FlashStringHelper*, String&)'
Auto_Caliper_Serial2.ino:77:46: note: candidates are:
In file included from C:\Program Files (x86)\Arduino\libraries\MegunoLinkPro/MegunoLink.h:2:0,
from Auto_Caliper_Serial2.ino:8:
C:\Program Files (x86)\Arduino\libraries\MegunoLinkPro/utility/InterfacePanel.h:12:8: note: void InterfacePanel::SetText(const char*, const char*)
void SetText(const char * ControlName, const char * Value);
^
C:\Program Files (x86)\Arduino\libraries\MegunoLinkPro/utility/InterfacePanel.h:12:8: note: no known conversion for argument 1 from 'const __FlashStringHelper*' to 'const char*'
C:\Program Files (x86)\Arduino\libraries\MegunoLinkPro/utility/InterfacePanel.h:13:8: note: void InterfacePanel::SetText(const __FlashStringHelper*, const char*)
void SetText(const __FlashStringHelper * ControlName, const char * Value);
^
C:\Program Files (x86)\Arduino\libraries\MegunoLinkPro/utility/InterfacePanel.h:13:8: note: no known conversion for argument 2 from 'String' to 'const char*'
C:\Program Files (x86)\Arduino\libraries\MegunoLinkPro/utility/InterfacePanel.h:14:8: note: void InterfacePanel::SetText(const __FlashStringHelper*, const __FlashStringHelper*)
void SetText(const __FlashStringHelper * ControlName, const __FlashStringHelper * Value);
^
C:\Program Files (x86)\Arduino\libraries\MegunoLinkPro/utility/InterfacePanel.h:14:8: note: no known conversion for argument 2 from 'String' to 'const __FlashStringHelper*'
no matching function for call to 'InterfacePanel::SetText(const __FlashStringHelper*, String&)'

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
bradleywoods
Posts: 2
Joined: Mon May 30, 2016 1:22 am

Mon May 30, 2016 1:56 am

Well, right after posting this it occurred to me that I can just hack my way around the problem like this:

Code: Select all

  Serial.print("{UI|SET|TextBox1.Text=");
  Serial.print(abs(finalValue_mm * 2 / 100));
  Serial.println("}");
Certainly not ideal, but at least I'm moving forward again. Any input would sure be appreciated.

Thanks, loving your app-btw,
-Brad
philr
Posts: 463
Joined: Mon May 26, 2014 10:58 am

Sat Jun 11, 2016 9:56 am

Hi Brad, I think it means there isn't a function in the library that supports a string type. You would need to add a function to the library to handle strings or whatever type finalValue is (essentially turning the fix you found into a generic function in the interfacepanel library).

Cheers
Phil
Post Reply