A simple question 
Author Message
 A simple question

Hello.
I`ve just tried REAL-basic for windows (xp) and I tried to create a simple
program to reverse a text-string from a text-field(box?). Anyway, here is
the code for the action-event for a button:
// Code
  dim t As string
  dim tn as string
  dim cnt as integer

  t = ""
  tn = ""
  cnt = 0

  t = txt1.text

  for cnt = len(t) to 1 step -1
    tn = tn + mid(t, cnt, 1)
  next

  txt1.text = tn

// End Code

Why does my program freeze when I try to run this?
What have I possible done wrong?

Thanks for all replies.

Runar



Thu, 27 Oct 2005 01:35:05 GMT  
 A simple question

Quote:

>   for cnt = len(t) to 1 step -1
>     tn = tn + mid(t, cnt, 1)
>   next

I think you need to change this to:

  for cnt = len(t) downto 1

--
-Thomas

e-mail me at thomasareed at <insert home planet> + link.net



Thu, 27 Oct 2005 02:14:52 GMT  
 A simple question

Quote:
> I think you need to change this to:

>   for cnt = len(t) downto 1

Yes, that was exactly it. Thank you! I`m used to program in Visual Basic, so
i didn`t know that.

Runar



Thu, 27 Oct 2005 02:42:02 GMT  
 A simple question


Quote:
>   for cnt = len(t) to 1 step -1
>     tn = tn + mid(t, cnt, 1)
>   next

> Why does my program freeze when I try to run this?
> What have I possible done wrong?

You already got the answer, but let me tell you how you could have found
the answer yourself.  Put the cursor on any of the lines I've quoted
above, then go to the Debug menu and choose "Set Breakpoint".  Now run.  
When the program hits that line, it'll stop and show you a debug window
where you can see your variables (such as cnt).  Now Run (i.e. Resume)
again, and it'll stop when it hits that line again.  Keep doing this,
and you'll see exactly what your program is doing...  i.e., it's not
really frozen, it just never gets out of this loop.

Of course you might still wonder why it doesn't stop when it gets to 1,
and the reasons for that are very arcane.  But at least you'd know that
this is where it's freezing!

Cheers,
- Joe

,------------------------------------------------------------------.
|    Joseph J. Strout         Check out the Mac Web Directory:     |

`------------------------------------------------------------------'



Fri, 28 Oct 2005 12:23:13 GMT  
 A simple question
Well, thank you, Joe :-)
Quote:
> You already got the answer, but let me tell you how you could have found
> the answer yourself.  Put the cursor on any of the lines I've quoted
> above, then go to the Debug menu and choose "Set Breakpoint".  Now run.
> When the program hits that line, it'll stop and show you a debug window
> where you can see your variables (such as cnt).  Now Run (i.e. Resume)
> again, and it'll stop when it hits that line again.  Keep doing this,
> and you'll see exactly what your program is doing...  i.e., it's not
> really frozen, it just never gets out of this loop.

> Of course you might still wonder why it doesn't stop when it gets to 1,
> and the reasons for that are very arcane.  But at least you'd know that
> this is where it's freezing!

> Cheers,
> - Joe



Fri, 28 Oct 2005 12:47:44 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Question in french (a simple question, very simple)

2. Simple Question seeks simple answer

3. Stumper Question for me: simple question for this group -exponential and logs

4. HTML simple question ?

5. J (simple) questions

6. simple question

7. simple question

8. Concatenating strings..simple question.

9. What is APL\11 (A Simple Question)

10. A simple question.

11. A Simple Question

12. Fw: What is APL\11 (A Simple Question)

 

 
Powered by phpBB® Forum Software