Marty McFlaY Posted May 2, 2020 Share Posted May 2, 2020 Here is the code: :cheat wait 0 if 0ADC: "test" jf @cheat 06D2: [email protected] = "" // @v = string 06D2: [email protected] = "" // @v = string 0AD1: "Enter any number" 10000 jump @0 :0 wait 0 if 0AB0: 48 jf @1 wait 500 06D2: [email protected] = "0" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @0 :1 wait 0 if 0AB0: 49 jf @2 wait 500 06D2: [email protected] = "1" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @1 :2 wait 0 if 0AB0: 50 jf @3 wait 500 06D2: [email protected] = "2" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @2 :3 wait 0 if 0AB0: 51 jf @4 wait 500 06D2: [email protected] = "3" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @3 :4 wait 0 if 0AB0: 52 jf @5 wait 500 06D2: [email protected] = "4" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @4 :5 wait 0 if 0AB0: 53 jf @6 wait 500 06D2: [email protected] = "5" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @5 :6 wait 0 if 0AB0: 54 jf @7 wait 500 06D2: [email protected] = "6" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @6 :7 wait 0 if 0AB0: 55 jf @8 wait 500 06D2: [email protected] = "7" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @7 :8 wait 0 if 0AB0: 56 jf @9 wait 500 06D2: [email protected] = "8" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @8 :9 wait 0 if 0AB0: 57 jf @0 wait 500 06D2: [email protected] = "9" // @v = string 098C: [email protected] = [email protected] + [email protected] // all string variables 0AD1: "%s" 3000 [email protected] jump @9 The problem is when I type any five numbers, the script automatically add two more same. I don't want to add two more same numbers so please inspect it and see what is the problem here as I cannot figure it out: Here, take a look at it: Also, If anyone knows how to remove the last string like if there is any method to do so? Link to comment Share on other sites More sharing options...
OrionSR Posted May 2, 2020 Share Posted May 2, 2020 (edited) It looks like your variables are getting mixed together. [email protected] starts 4 bytes after [email protected] Change all references of [email protected] [email protected] and you should be safe with this size of variable length string. Edited May 2, 2020 by OrionSR Link to comment Share on other sites More sharing options...
Marty McFlaY Posted May 2, 2020 Author Share Posted May 2, 2020 3 hours ago, OrionSR said: It looks like your variables are getting mixed together. [email protected] starts 4 bytes after [email protected] Change all references of [email protected] [email protected] and you should be safe with this size of variable length string. Thank you, it is working. Also, how to remove the last character of string? Is there any method to do so? Link to comment Share on other sites More sharing options...
OrionSR Posted May 2, 2020 Share Posted May 2, 2020 (edited) Um... not sure. Maybe something like... 0ADF: add_text_label "_TEST" text [email protected] 09FD: get_string_width '_TEST' store_to [email protected] 0AE0: remove_text_label "_TEST" 0AC7: get_var_pointer [email protected] store_to [email protected] 005A: [email protected] += [email protected] //variable address + character offset 000C: [email protected] -= 1 // number of characters to delete 0A8C: write_memory [email protected] size 1 val 0 vp 0 Note: These codes are using an SCR style opcode format. You may need to convert them to the Sanny parameter order. Edited May 2, 2020 by OrionSR Link to comment Share on other sites More sharing options...
Marty McFlaY Posted May 2, 2020 Author Share Posted May 2, 2020 28 minutes ago, OrionSR said: Um... not sure. Maybe something like... 0ADF: add_text_label "_TEST" text [email protected] 09FD: get_string_width '_TEST' store_to [email protected] 0AE0: remove_text_label "_TEST" 0AC7: get_var_pointer [email protected] store_to [email protected] 005A: [email protected] += [email protected] //variable address + character offset 000C: [email protected] -= 1 // number of characters to delete 0A8C: write_memory [email protected] size 1 val 0 vp 0 Note: These codes are using an SCR style opcode format. You may need to convert them to the Sanny parameter order. It is crashing, don't know why Also, try to attach it with my full code so I can understand it more easily. I am waiting for your reply Link to comment Share on other sites More sharing options...
OrionSR Posted May 2, 2020 Share Posted May 2, 2020 (edited) This snippet might be more compatible with your current script. Otherwise, I don't know why it would crash, and I'm not sure if it will work either. This isn't the question I was intending to answer. 0ADF: add_text_label "_TEST" text [email protected] 09FD: get_string_width '_TEST' store_to [email protected] 0AE0: remove_text_label "_TEST" //0AC7: get_var_pointer [email protected] store_to [email protected] 0AC7: [email protected] = var [email protected] offset 005A: [email protected] += [email protected] // variable address + character offset 000C: [email protected] -= 1 // number of characters to delete 0A8C: write_memory [email protected] size 1 val 0 vp 0 And the lack of command names makes your code difficult to read. I'll leave the script integration to you as I don't want to figure out what you've done. Added: It would be a good idea to verify that the number of characters to delete is not greater than the string length. Edited May 3, 2020 by OrionSR Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now