Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 89 users online: 0 members, 63 guests and 26 bots. Members: None. Bots: VoilaBot (3), Spinn3r (1), MSN/Bing (1), VoilaBot (2), Yahoo! Slurp (1), Googlebot (18).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
|
| Author |
Message |
|
GenericUser1
Advanced Member

Joined: 03 May 2007 Posts: 288
|
Posted: 04 Oct 2007 02:55:16 pm Post subject: String problem [Solved (to an extent)] |
|
|
OK, I have this code:
Code: :¦ If θ=22
:¦ Then
:¦ Output(5,7,"< >
:¦ Repeat Z=22
:¦ ¦ Output(5,8,sub(Str1,G,1
:¦ ¦ getKey→Z
:¦ ¦ Repeat Z
:¦ ¦ ¦ getKey→Z
:¦ ¦ End
:¦ ¦ G-(Z=24 and G≠1)+(Z=26 and G+1≤length(Str1))→G
:¦ ¦ If Z=21
:¦ ¦ sub(Str2,1,F-(5-D)∟EDIT(2)-E-5)+sub(Str1,G,1)+sub(Str2,F-(5-D)∟EDIT(2)-E-3,length(Str2)-length(sub(Str2,1,F-(5-D)∟EDIT(2)-E-3)))→Str2
:¦ End
:End
And I need it corrected. More specifically the 3rd to last line, teh one with all the sub(s WHat it is suppoesed to do is take the cursor's position (D = UP and Down, E= Left and right), along with the centerpoint (F, should be (5,8) on the screen if you were to plot it, 72 on an 16*8 map), the width of the map (∟EDIT(2)) and the Str2 as the map itself. G is the point in Str1 of which I am trying to move to the point of the cursor. Any one have an idea?
[Edit]
Solved. Figured it out (to an extent).
Last edited by GenericUser1 on 04 Oct 2007 05:07:53 pm; edited 2 times in total |
|
| Back to top |
|
|
JoostinOnline

Advanced Newbie

Joined: 22 Sep 2007 Posts: 48 Location: Behind You
|
Posted: 04 Oct 2007 04:12:35 pm Post subject: Re: String problem |
|
|
I don't know about fixing your problem, but I did optimize your code a bit
Code: :¦ If θ=22
:¦ Then
:¦ Output(5,7,"< >
:¦ Repeat Z=22
:¦ ¦ Output(5,8,sub(Str1,G,1
:¦ ¦ Repeat Ans
:¦ ¦ ¦ getKey
:¦ ¦ End
:¦ ¦Ans→Z
:¦ ¦ G-(Z=24 and G≠1)+(Z=26 and G+1≤length(Str1→G
:¦ ¦ If Z=21
:¦ ¦ sub(Str2,1,F-(5-D)∟EDIT(2)-E-5)+sub(Str1,G,1)+sub(Str2,F-(5-D)∟EDIT(2)-E-3,length(Str2)-length(sub(Str2,1,F-(5-D)∟EDIT(2)-E-3→Str2
:¦ End
:End
_________________ "Macs are the Perfect Computer", said the Perfect Idiot.
Testing for:
Vera |
|
| Back to top |
|
|
GenericUser1
Advanced Member

Joined: 03 May 2007 Posts: 288
|
Posted: 04 Oct 2007 04:22:00 pm Post subject: |
|
|
I'm not worried about the optimization, I'll do that later when it is complete. I just need to figure out the 3rd line... and how I would change the symbol in the first and last spaces...
And I'm a little against using Ans atm...
I sorta solved it... For some reason, it shows the symbol i just put in on the second line on the first to the right by about 6... I wonder why?
[Edit] Solved completely! Screwed up a + and a - in the output. I'll upload ASAP. Should some sort of open-a-preexisting-map be allowed? |
|
| Back to top |
|
|
Super Speler

Advanced Member

Joined: 12 Dec 2006 Posts: 248
|
Posted: 04 Oct 2007 09:56:10 pm Post subject: |
|
|
| Why would you be against the use of Ans? Do you not like good code or something? |
|
| Back to top |
|
|
Kllrnohj

PH34R |\/|3

Joined: 24 May 2005 Posts: 8189
|
Posted: 04 Oct 2007 11:16:18 pm Post subject: |
|
|
| Super Speler wrote: | | Why would you be against the use of Ans? Do you not like good code or something? |
He said "atm" (at the moment) - you never ever optimize something until it works. Also, he may add to it and use what is in ans later, so storing it for now is a good idea. He can always go back and optimize later. _________________ There are only two kinds of programming languages: those people always bitch about and those nobody uses. (Bjarne Stroustrup) |
|
| Back to top |
|
|
Super Speler

Advanced Member

Joined: 12 Dec 2006 Posts: 248
|
Posted: 05 Oct 2007 02:17:54 pm Post subject: |
|
|
| I got the impression of him being against using Ans in general, not just for this. Maybe (probably) I was wrong though. |
|
| Back to top |
|
|
GenericUser1
Advanced Member

Joined: 03 May 2007 Posts: 288
|
Posted: 05 Oct 2007 02:24:29 pm Post subject: |
|
|
Kllrnohj is right, write he code out first and then optomize. I mean, if you optomize while you do it, a) it takes to long and b) if you mess up just a little, it could be problematic.
And for some reason the archives aren't working... My thing won't download. A blank page shows up. |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55733 Location: Earth, Sol, Milky Way
|
Posted: 05 Oct 2007 03:36:23 pm Post subject: |
|
|
| Angel14995 wrote: | Kllrnohj is right, write he code out first and then optomize. I mean, if you optomize while you do it, a) it takes to long and b) if you mess up just a little, it could be problematic.
And for some reason the archives aren't working... My thing won't download. A blank page shows up. | There's already a separate topic about it. I'll try to get to it later if I have a chance. _________________
 |
|
| Back to top |
|
|
GenericUser1
Advanced Member

Joined: 03 May 2007 Posts: 288
|
Posted: 06 Oct 2007 12:40:38 pm Post subject: |
|
|
| Okay. I didn't see the topic when I wrote my post, so sorry. |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55733 Location: Earth, Sol, Milky Way
|
Posted: 06 Oct 2007 05:51:47 pm Post subject: |
|
|
| Angel14995 wrote: | | Okay. I didn't see the topic when I wrote my post, so sorry. | No worries. Feel free to keep bumping that other thread if I forget about this. _________________
 |
|
| Back to top |
|
|
|
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.028652 seconds.
|