| 07-18-2007, 07:10 PM | #1 |
JASS://_______// // Init // //_______// function ASLinit takes nothing returns nothing set udg_SL_Base = 64 set udg_SL_BinSet = "111110111001000101001101011000001111" set udg_SL_CharSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz%$" set udg_SL_CharSpec = "@?&!# _" set udg_SL_Powers[1] = 2 set udg_SL_Powers[2] = 4 set udg_SL_Powers[3] = 8 set udg_SL_Powers[4] = 16 set udg_SL_Powers[5] = 32 set udg_SL_Powers[6] = 64 set udg_SL_Powers[7] = 128 set udg_SL_Powers[8] = 256 set udg_SL_Powers[9] = 512 set udg_SL_Powers[10] = 1024 set udg_SL_Powers[11] = 2048 set udg_SL_Powers[12] = 4096 set udg_SL_Powers[13] = 8196 set udg_SL_Powers[14] = 16384 set udg_SL_Powers[15] = 32768 set udg_SL_Powers[16] = 65536 set udg_SL_Powers[17] = 131072 set udg_SL_Powers[18] = 262144 set udg_SL_Powers[19] = 524288 set udg_SL_Powers[20] = 1048576 set udg_SL_Powers[21] = 2097152 set udg_SL_Powers[22] = 4194304 set udg_SL_Powers[23] = 8388608 set udg_SL_Powers[24] = 16777216 set udg_SL_Powers[25] = 33554432 set udg_SL_Powers[26] = 67108864 set udg_SL_Powers[27] = 134217728 set udg_SL_Powers[28] = 268435456 set udg_SL_Powers[29] = 536870912 set udg_SL_Powers[30] = 1000000000 // set udg_SL_Powers[30] = 1073741824 endfunction //______________// // Core // //______________// function SaveCode takes integer code returns string local integer xi = 0 local integer xi2 = 0 local integer xi3 = 0 local integer a = 1 local integer a2 = udg_Code_Saves[code] local integer b = 0 local integer b2 = 0 local string result = null local string xs = null local string xs2 = null if ( a2 <= 0 ) then set result = "codeerror" return result endif loop set xi3 = ( a + ( 1000 * (code - 1))) set xi = udg_Save_Val[xi3] set xi2 = udg_Save_Max[xi3] set b = 1 loop if ( xi2 < udg_SL_Powers[b] ) then exitwhen true endif set b = ( b + 1) endloop if ( xi2 <= ( udg_SL_Powers[b] - xi2 ) ) then if ( xs != null ) then if ( SubString( xs, 1, 1 ) == "1" ) then set xi = ( xi + xi2 ) endif set xs = SubString( xs, 2, StringLength(xs) ) endif endif set b = ( b - 1 ) loop if ( xi >= udg_SL_Powers[b] ) then set xi = ( xi - udg_SL_Powers[b] ) set xs = ( "1" + xs ) else set xs = ( "0" + xs ) endif set b = ( b - 1 ) if ( b == 0 ) then exitwhen true endif endloop loop if ( ModuloInteger( StringLength(xs), 6 ) != 0 ) then set xs = ( xs + "0" ) else exitwhen false endif endloop set xi = StringLength(xs) set a = 1 set a2 = 6 set b = 1 set b2 = 5 loop set xs2 = SubString( xs, a, a2) if ( udg_SL_Base == 32 ) then loop if ( xs2 == SubString( udg_SL_BinSet, b, b2 ) ) then set result = result + SubString( udg_SL_CharSet, b, b ) exitwhen true endif set b = ( b + 1 ) set b2 = ( b2 + 1 ) endloop else loop if ( b <= 32 ) then if ( xs2 == ( SubString( udg_SL_BinSet, b, b2 ) + "0" ) ) then set result = result + SubString( udg_SL_CharSet, b, b ) exitwhen true endif else if ( xs2 == ( SubString( udg_SL_BinSet, b, b2 ) + "1" ) ) then set result = result + SubString( udg_SL_CharSet, b, b ) exitwhen true endif endif set b = ( b + 1 ) set b2 = ( b2 + 1 ) endloop endif if ( a2 == xi ) then exitwhen true endif set a = ( a + 6 ) set a2 = ( a2 + 6 ) endloop endloop return result endfunction I'm getting a huge amount of parse errors on this code and none seem to make sense. The locals are supposedly declared after a statement, and the function start is out of function. Its a part of my Save Load system if your curious. |
| 07-18-2007, 07:12 PM | #2 |
try checking it in JASSCraft. It always give reliable results... erm.. most of the time. |
| 07-18-2007, 07:14 PM | #3 |
I'm using Jass NewGen pack, JASSCraft doesn't work at all for me. |
| 07-18-2007, 07:44 PM | #4 |
you forgot to declare or mispelles global variables JASS:function SaveCode takes integer ___code___ returns string |
| 07-18-2007, 07:49 PM | #5 |
Thanks, it was code. |
| 07-19-2007, 12:56 AM | #6 |
Couldnt you use a loop and make that first function alot smaller? JASS:function Loop takes nothing returns nothing local integer i = 0 loop set i = i + 1 Set udg_Number[i] = i * 2 exitwhen i >= 40 endloop endfunction |
| 07-19-2007, 02:37 AM | #7 |
You should clean up this code. Clean stuff usually works better, because it's easier to understand and fix. - One of the lines is "exitwhen false". That line does absolutely nothing (exitwhen breaks out of the loop when its argument evaluates to true). - You have a lot of "If (condition) then; exitwhen true; endif", which can be cut down to just "exitwhen (condition)". - All of your locals have non-descriptive names. This is ok for short functions that fit on your screen, and for iterators, but is very confusing here. eg: What the heck is "a2"? It seems to change roles a lot. - I can see a few infinite loops. Mainly the one with "exitwhen false". Don't take this as insulting, because it's not meant to be. These are just habits you want to get into now to avoid pain in the future. |
| 07-19-2007, 02:55 AM | #8 |
Its more efficient to actually set the variables instead of using a loop, I already wrote it out so whats the point of making a loop. xi - xi3 are temp integers, their need changes throughout the function. a and b's are for loops, like For Loop for Integer A. So will exitwhen true work for "Else"? Is there any infinite loops aside from that one? |
| 07-19-2007, 03:21 AM | #9 | |||
without reading your actual code, as im a lazy bugger: Quote:
Quote:
Quote:
Edit: "exitwhen expression" "if expression then" same thing. expression must evaluate to a boolean value, and if it is true, exit or "then". otherwise, don't exit or "else(if)". |
| 07-19-2007, 03:40 AM | #10 | |
Quote:
I think you're misunderstanding how exitwhen works. It takes an argument, and jumps out of a loop if that argument evaluates to true. Examples: Code:
exitwhen (i == 0) //exits the loop when i is 0 exitwhen (i > 10) //exists when i is larger than 10 exitwhen true //always exits the loop exitwhen false //never exits the loop |
| 07-19-2007, 03:47 AM | #11 |
another example: JASS:exitwhen GetUnitOrderId(U) != OrderId("starfall") //exits when the unit's orderId is no longer starfall. That's how exitwhen works. Plus, your code was impossible for me to read, that insane indenting was annoying. Idk if it was from CnP'ing, but... yikes. This is gonna sound really stupid but... Try removing the comment // from the line above "endfunction" on the trigger that sets your global. For some reason, an error kinda like that happened to me once, and that fixed it... somehow O.o Also, you can't use "code" as a variable/argument name, it thinks you're asking for it. change it to some variation, like Code_function. |
| 07-19-2007, 04:36 PM | #12 |
usually when you get lots of weird parse errors (like it says local variables not defined but its clearly defined at the begining) then you have a simple error somewhere, such as a missing parenthesis, or a missing then after the IF statement (happens to me all the time) etc. |
