March 29, 2024, 04:05:51 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Confusing Error

Started by tbohon, February 05, 2014, 12:41:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tbohon

I have a simple richedit field (#1 on the main form win) to which I'm trying to add lines one at a time using a function.

The call is


case @IDCONTROL
select @CONTROLID
case 3   
gosub AddItem("Item 1","1.00")

case 4
MessageBox win, "Item #2 selected", "Key Pressed"

                                         ...

end select


And the function is

sub AddItem(item$, price$)

item$ = getcontroltext(win,1)
item$ = item$ + space$(28-len(item$)) + price$
SETCONTROLTEXT win,1, item$

return


The error says that there is an undefined label on the second statement (item$ = item$ + space$(...)).  Have checked and all loops, for statements, selects, etc. above are properly closed and I don't know what to look at next.

Suggestions?

TIA.

Tom
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)

Sam

Quote from: tbohon on February 05, 2014, 12:41:09 PM
I have a simple richedit field (#1 on the main form win) to which I'm trying to add lines one at a time using a function.

The call is


case @IDCONTROL
select @CONTROLID
case 3   
gosub AddItem("Item 1","1.00")

case 4
MessageBox win, "Item #2 selected", "Key Pressed"

                                         ...

end select


And the function is

sub AddItem(item$, price$)

item$ = getcontroltext(win,1)
item$ = item$ + space$(28-len(item$)) + price$
SETCONTROLTEXT win,1, item$

return


The error says that there is an undefined label on the second statement (item$ = item$ + space$(...)).  Have checked and all loops, for statements, selects, etc. above are properly closed and I don't know what to look at next.

Suggestions?

TIA.

Tom

Tom, hard to tell without seeing more of the code. Is there an ENDSUB at the end of your AddItem sub? From what you've listed, all I can see is a return statement.


LarryMc

change
sub AddItem(item$, price$)
to
sub Additem(string item$,string price$)
should take care of the error.

But I really don't see what you are trying to do.
You pass two strings to the subroutine then you immediately overwrite the first string with the contents of the richedit..

And you are not adding new lines; you're just extending the first line.

And, it will only work until you reach a length of 255 characters.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

tbohon

Issue went away when I realized that one of my string variables was not a ISTRING.  Once I made that change all proceeded as designed and desired.

Thanks.
"If you lead your life the right way, the karma will take care of itself ... the dreams will come to you."  -- Randy Pausch, PhD (1961-2008)