Does Rev have counterparts to VB's left$,mid$,right$
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Does Rev have counterparts to VB's left$,mid$,right$
Visual Basic has left$, mid$ and right$ functions when dealing with text. Does rev have similar text functions? If so, where would I find examples of them? Can't find a reference to this when searching the forum.
urbaud
Re: Does Rev have counterparts to VB's left$,mid$,right$
Left$ would be the easiest :urbaud wrote:Visual Basic has left$, mid$ and right$ functions when dealing with text. Does rev have similar text functions? If so, where would I find examples of them? Can't find a reference to this when searching the forum.
put char 1 to 2 of theString
=left$(theString,2)
Re: Does Rev have counterparts to VB's left$,mid$,right$
Dan,
You can also use
put char -2 to -1 of myVar into Field "myField"
For the last two chars, etc
Or
Put middle char of myVar into Field "myField"
Regards
Bernd
You can also use
put char -2 to -1 of myVar into Field "myField"
For the last two chars, etc
Or
Put middle char of myVar into Field "myField"
Regards
Bernd
Re: Does Rev have counterparts to VB's left$,mid$,right$
Hi Bernd and Bangkok,
Thanks to you both for responding to my post. The reason for my initial question about counterparts in Rev for the VB left$, mid$ and right$ functions was because a friend asked me if I knew Rev well enough to translate the following VB code into Rev.
text1.text = 12345
dim i as integer
dim ctr as string
for i = len(text1.text) to 1 step -1
ctr = ctr + mid(text1.text,i,1)
next i
text2.text = ctr
print text1.texta
print ctr
I don’t know if you know what this does, so I’ll show the display:
12345
54321
Here’s my rendition of the above VB code in Rev:
Display:
Bill Gates
setaG lliB
It’s been awhile since I dabbled in VB so I had to look up what the VB functions do:
Left$() Returns the left n characters of a string; temp = left$ ( teststring$, 4 )
Right - Returns the right n characters of a string; temp = right$ ( teststring$, 4 )
Mid - Returns n characters from a string, starting a any position; temp = mid$ ( teststring$, 1, 4 )
So, below are my translations of the VB functions, with thanks to both of you for your suggestions:
Display:
Bill Gates
Bill
Bill Ga
Bi
--
Display:
Bill Gates
l Gates
Es
ates
--
Display:
Bill Gates
Bill
Ga
G
Oh, and by the way, since I have your attention, I have a question. As you know, when using a slider, you can set the values to be shown at the bottom of the slider in the properties of the slider. Is there a way to show those values in a text or label field? So, as the slider is moved, is it possible to show the changing values in a field, label or text?
Again, thanks to both of you for your help.
Dan
Thanks to you both for responding to my post. The reason for my initial question about counterparts in Rev for the VB left$, mid$ and right$ functions was because a friend asked me if I knew Rev well enough to translate the following VB code into Rev.
text1.text = 12345
dim i as integer
dim ctr as string
for i = len(text1.text) to 1 step -1
ctr = ctr + mid(text1.text,i,1)
next i
text2.text = ctr
print text1.texta
print ctr
I don’t know if you know what this does, so I’ll show the display:
12345
54321
Here’s my rendition of the above VB code in Rev:
Code: Select all
on mouseUp --displays text backwards
put "Bill Gates" into name1
put name1 into fld "l1"
repeat with i =1 to len(name1)
wait 200 milliseconds
get the char(i) of name1
put it before fld "l2"
end repeat
end mouseUp
Bill Gates
setaG lliB
It’s been awhile since I dabbled in VB so I had to look up what the VB functions do:
Left$() Returns the left n characters of a string; temp = left$ ( teststring$, 4 )
Right - Returns the right n characters of a string; temp = right$ ( teststring$, 4 )
Mid - Returns n characters from a string, starting a any position; temp = mid$ ( teststring$, 1, 4 )
So, below are my translations of the VB functions, with thanks to both of you for your suggestions:
Code: Select all
on mouseUp --like VB left$ function
put "Bill Gates" into name1
put name1 into fld "l1"
put char 1 to 4 name1 into fld "l2"
put char 1 to 7 name1 into fld "l3"
put char 1 to 2 name1 into fld “l4”
End mouseUp
Bill Gates
Bill
Bill Ga
Bi
--
Code: Select all
on mouseUp --like VB right$ function
put "Bill Gates" into name1
put name1 into fld "l1"
put char 4 to -1 of name1 into fld "l2"
put char -2 to -1 of name1 into fld "l3"
put char 7 to -1 of name1 into Field "l4"
end mouseUp
Bill Gates
l Gates
Es
ates
--
Code: Select all
on mouseUp --like VB mid$ function
put "Bill Gates" into name1
put name1 into fld "l1"
put char 1 to 4 of name1 into fld "l2"
put char 6 to 7 of name1 into fld "l3"
put middle char of name1 into Field "l4"
end mouseUp
Bill Gates
Bill
Ga
G
Oh, and by the way, since I have your attention, I have a question. As you know, when using a slider, you can set the values to be shown at the bottom of the slider in the properties of the slider. Is there a way to show those values in a text or label field? So, as the slider is moved, is it possible to show the changing values in a field, label or text?
Again, thanks to both of you for your help.
Dan
urbaud
Re: Does Rev have counterparts to VB's left$,mid$,right$
The VB code looks like a simple reversed-text algorithm. Try something like
Code: Select all
on mouseUp
put empty into field "text2"
repeat for each char tChar in field "text1"
put tChar before field "text2"
end repeat
end mouseUp
Re: Does Rev have counterparts to VB's left$,mid$,right$
The message you're looking for there is "scrollbarDrag". I realize it's not really intuitive: you have to know beforehand that a slider is a scrollbar and then pick the appropriate message from the available ones. But putting the following into the slider (scrollbar) scriptOh, and by the way, since I have your attention, I have a question. As you know, when using a slider, you can set the values to be shown at the bottom of the slider in the properties of the slider. Is there a way to show those values in a text or label field? So, as the slider is moved, is it possible to show the changing values in a field, label or text?
Code: Select all
on scrollbardrag pValue
put pValue into field "fldScrollValue"
end scrollbardrag