I need help using AND logic to combine two strings. My code includes two for loops and this makes it very slow. If anyone knows of a better way the combine strings that would be fantastic. I am trying to make spaces override other characters btw.
Can you provide more details about what ANDing of strings means? I assume character-wise rather than bitwise, but what is 'A' AND 'B'? I gather that you mean 'A' AND '<space>' = '<space>'.
The main concept I am going off of is...

Code:
For(W,1,128
If sub(Str1,W,1) or sub(Str2,W,1):Then
Ans+" "
Else
Ans+"O"
End
End

P.S. I actually meant OR logic not AND logic.
The sub( command you are using in this example returns a single character from a string. It is important to note that a character/string cannot be used as a boolean value, and thus would make the If statement return an error. Maybe you are trying to check if the two substrings are equal? I'm not really sure though, I would need more clarification.
I forgot to type out the Equals sign after the sub commands, and that is my bad. But the main point is that it is taking one character at a time to use the logic, but it is too slow for the program I am creating as it is already slow. So I need a way to calculate this easier and faster.
But what is the logic you are trying to do? The boolean OR of two strings (or characters) just doesn't make sense on its own. If there is some hidden function you are not including that operates on characters, then there is no a priori way to apply this function to the entirety of the string at once, so your method is as fast as it can be generically.
This is the code I am trying to make work.
128 is the length a string would need to fill the monochrome homescreen with Output(
Str2 has the different parts of the Map I want to combine such as directional halls.
Str1 is a base map area to combine other sections.

Code:
"O->Str3
For(W,1,128
   sub(Str1,W,1)=" "->U
   For(V,0,(length(Str2)/128)-1
      sub("O ",(U or sub(Str2,V128+U,1)),1)
   End
End
Str3->Str1
End

I found a bug with this I need to fix but you get the point.
I am making a rougelike game and I want to make map generation, but speed is the main problem.
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement