Reversing an Integer or String

16 views
Skip to first unread message

Alex

unread,
Jun 14, 2017, 11:04:05 AM6/14/17
to E-Prime
Hi all,

I am working on a memory task, where we are interested in looking at forward and reverse recall.  I was hoping to write some basic InLine to reverse the CorrectResponse, but after a few failed attempts, I'm at a loss.  EBasic doesn't have a "StrReverse" equivalent like Visual Basic, and an attempt at a loop (see below) didn't seem to work out either.  Has anyone worked with anything like this before?  Thanks for your help!

Dim s1 As String
Dim s2 As String

s1 = c.GatAttrib("CorrectResponse")
s2 = ""

For i = Len(s1) To 1 Step -1
  s2 = s2 & Mid(s1, i, 1)
Next i

David McFarlane

unread,
Jun 14, 2017, 12:01:22 PM6/14/17
to e-p...@googlegroups.com
Hmm, in what way did your code not work? It worked for me. Here is
my exact example code:

Dim i as Integer
Dim s1 As String, s2 as String
s1 = "Hello"
For i = Len(s1) To 1 Step -1
s2 = s2 & Mid(s1, i, 1)
Next i
msgbox s1 & ebCR & s2

Best,
-- David McFarlane
> --
> You received this message because you are subscribed to the Google Groups
> "E-Prime" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to e-prime+u...@googlegroups.com.
> To post to this group, send email to e-p...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/e-prime/263df62a-9d21-4383-bddf-40906dafe570%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Alex

unread,
Jun 14, 2017, 2:13:13 PM6/14/17
to E-Prime
Hi David,

Thank you for taking a look!  Perhaps there was a typo that wasn't throwing an error, or perhaps the missing ingredient was having you confirm it -- at any rate, it works now.  Using the code you pasted worked perfectly. Thanks for the help!

Best,
Alex
Reply all
Reply to author
Forward
0 new messages