Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
24 May, 2013, 04:40:18 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Display one character of a string? -  (Read 599 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Topic starter
Total Post Ratings: +43

View Profile
« on: 30 March, 2012, 14:28:15 »
0

I know that I can display every character after a certain position by doing something like Str1+N, but how can I only get the character at N?
Logged
Matrefeytontias
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 17:12:17
Date Registered: 14 October, 2011, 18:48:49
Location: Alone in the Park
Posts: 854


Total Post Ratings: +174

View Profile
« Reply #1 on: 30 March, 2012, 15:40:33 »
0

You can use the brackets : {Str1+N}. It'll display only the Nth character of the string.
Logged

/\   ><   [-   |_|   _\~   [-   /?



Spoiler for Shameful self-advertising:
/image/37571.png[/img]
If at a certain moment you think that I'm awesome, give an internet (>^_^)>
ztrumpet
The Rarely Active One
LV13 Extreme Addict (Next: 9001)
*************
Offline Offline

Gender: Male
Last Login: 22 May, 2013, 03:10:30
Date Registered: 08 November, 2009, 21:10:12
Location: Michigan
Posts: 5687


Total Post Ratings: +360

View Profile
« Reply #2 on: 30 March, 2012, 17:39:21 »
0

Here's how I'd do it:
{Str1+N}->A
Disp oA

This is how it works:
The first line stores the number of the character into the first byte of a two byte variable.  Since the upper 8 bits are all zero, a zero is stored with the number as well.  So the two bytes of variable A look like N, 0.
The second line just displays the character.  To do so, you need the address of a, which is what the degrees symbol gives you.

I hope this helps!
Logged

Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: Today at 03:26:33
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7813


Total Post Ratings: +706

View Profile WWW
« Reply #3 on: 30 March, 2012, 17:48:52 »
+1

You could also do Disp {N+Str1}►Char.

(N+Str1 is much more optimized than Str1+N, by the way.)
Logged




BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Topic starter
Total Post Ratings: +43

View Profile
« Reply #4 on: 30 March, 2012, 20:58:00 »
0

Ahh, okay, thanks guys. Does that also mean that if I wanted to store the quote character to a string, I could do something like E22->{N+Str1}?
Logged
Matrefeytontias
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: Yesterday at 17:12:17
Date Registered: 14 October, 2011, 18:48:49
Location: Alone in the Park
Posts: 854


Total Post Ratings: +174

View Profile
« Reply #5 on: 30 March, 2012, 21:52:51 »
0

Yeah, it works ! If you type it :

1
2
3
:"ABCDE"->Str1
:E22->{Str1+2
:Disp Str1
You'll get AB"DE (tested)
Logged

/\   ><   [-   |_|   _\~   [-   /?



Spoiler for Shameful self-advertising:
/image/37571.png[/img]
If at a certain moment you think that I'm awesome, give an internet (>^_^)>
Deep Thought
So much to do, so much time, so little motivation
Administrator
LV13 Extreme Addict (Next: 9001)
*
Offline Offline

Gender: Male
Last Login: Today at 03:26:33
Date Registered: 19 May, 2009, 08:00:00
Location: The Universe
Posts: 7813


Total Post Ratings: +706

View Profile WWW
« Reply #6 on: 30 March, 2012, 22:47:52 »
0

You could also do
:[]→Str1
:"AB"
:[22]
:"DE"
:[00]
:Disp Str1
That way the quote character is compiled into the string, so you don't have to waste time and RAM to put it in when the program's running.
Logged




Runer112
Project Author
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 01:06:32
Date Registered: 02 July, 2009, 06:38:05
Posts: 1680


Total Post Ratings: +493

View Profile
« Reply #7 on: 30 March, 2012, 22:55:34 »
0

Or, a much simpler and prettier way:

:"AB"[22]"DE"→Str1

 Wink
Logged
BlakPilar
LV8 Addict (Next: 1000)
********
Offline Offline

Gender: Male
Last Login: 20 February, 2013, 02:38:22
Date Registered: 16 July, 2011, 02:50:55
Posts: 735


Topic starter
Total Post Ratings: +43

View Profile
« Reply #8 on: 30 March, 2012, 23:43:27 »
0

Again, thanks guys! I figured it'd be something simple like that. I never really understood the need for pointers, but after the last week or so of testing, I do.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.384 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.