IonicWind Software

Creative Basic => General Questions => Topic started by: tbohon on February 05, 2014, 12:41:09 PM

Title: Confusing Error
Post by: 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
Title: Re: Confusing Error
Post by: Sam on February 05, 2014, 01:22:20 PM
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.

Title: Re: Confusing Error
Post by: LarryMc on February 05, 2014, 03:35:59 PM
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.
Title: Re: Confusing Error
Post by: tbohon on February 14, 2014, 12:47:41 PM
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.