locked
How many lines of code does smallbasic allow you to publish. RRS feed

  • Question

  • Im making a game-> import code vvm159.

    its at 2000 lines of code no spacing between subs and code. when i got to around 2040 lines of code or so it said that i was too long. its there a limit to amount of code you can publish? 

    thanks.

    Wednesday, September 23, 2015 4:04 PM

Answers

  • Yes there is a limit - it has been reported before.  I don't know exactly if it is a file size or line count limit, but you have clearly hit it with 2040 lines.

    The alternative is to upload it maybe in a zip somewhere, perhaps TechNet Gallery.

    Wednesday, September 23, 2015 5:32 PM
  • I'm pretty sure the publishing limit is due to file sizel. I recently exceeded the limit with only 50 loc but some very long (wide) strings. I shortened the strings and got it published.

    To get large files published I'd try to:

    • reduce commenting (perhaps a hosted txt document could help)
    • reduce blocks of spaces
    • optimise long strings where possible
    • refactor by writing a simple parser that shortens some variables

    Also if you have a website that allows it, mine used to but a recent security feature put an end to that, you can try something like:

    path = "http://name/data.txt"
    
    content = Network.GetWebPageContents(path)
    
    TextWindow.WriteLine(content)
    Here's a test of over 3000 loc http://smallbasic.com/program/?FLZ541




    • Edited by Jibba j Thursday, September 24, 2015 6:17 AM refactor
    • Proposed as answer by Liam McSherry Sunday, September 27, 2015 8:36 AM
    • Marked as answer by litdev Tuesday, October 13, 2015 8:39 PM
    Wednesday, September 23, 2015 9:09 PM
  • If your program is only just too big, you can reduce the size before publishing by running the following program. It needs the LitDev extension. This removes all spaces at the start of a line, which reduces the size by typical 15%, and the spaces to the left and right of an equals sign and next to a comma. The gives one extra percent reduction.   

    Your program VMM159 has a size of 72023 bytes. The program gives the new program the name VMM159S with a size of 56629 bytes (- 17.2%)

    ' SHRINK  150926  WhTurner
    ' shrink a file by removing indenting spaces and spaces before and after a "="
    'uses LitDev-extension
    
    CRLF= Text.GetCharacter(13)+Text.GetCharacter(10)
    TextWindow.Write("Give filename (without extension): ")
    FI=TextWindow.Read()
    FO=Program.Directory+"\"+FI+"S.sb"
    FI=Program.Directory+"\"+FI+".sb"
    File.DeleteFile(FO)
    buf=File.ReadContents(FI)
    Len1=Text.GetLength(buf)
    TextWindow.WriteLine("Length of file: "+Len1)
    line=LDText.Split(buf,CRLF)
    TextWindow.WriteLine("Number of lines: "+Array.GetItemCount(line))
    For num=1 To Array.GetItemCount(line)
      parts= LDText.Split(line[num],"=")  ' remove spaces left/right of "="
      newLine=LDText.Trim(parts[1])
      For par=2 To Array.GetItemCount(parts)
        newLine=Text.Append(newLine+"=", LDText.Trim(parts[par]))
      EndFor
      parts= LDText.Split(newLine,",")  ' remove spaces left/right of ","
      newLine=LDText.Trim(parts[1])
      For par=2 To Array.GetItemCount(parts)
        newLine=Text.Append(newLine+",", LDText.Trim(parts[par]))
      EndFor
      File.AppendContents(FO,newLine)
    EndFor
    buf=File.ReadContents(FO)
    Len2=Text.GetLength(buf)
    TextWindow.WriteLine("New Length of file: "+Len2)
    reduct=Math.Round((1-len2/len1)*1000)
    TextWindow.WriteLine("Reduction in size : "+reduct/10+"%")
    


    Jan [ WhTurner ] The Netherlands

    Saturday, September 26, 2015 2:58 PM
    Answerer

All replies

  • Yes there is a limit - it has been reported before.  I don't know exactly if it is a file size or line count limit, but you have clearly hit it with 2040 lines.

    The alternative is to upload it maybe in a zip somewhere, perhaps TechNet Gallery.

    Wednesday, September 23, 2015 5:32 PM
  • oh ok. i actually decided that instead of it in a huge format (here is teh weird part) my code has multiple parts to it. so the characters have different proteries. so i will just make an import for each property. If you want me to elaberate on it, i will be glad to.
    Wednesday, September 23, 2015 6:43 PM
  • Yes, if you want to it would be great to see how you solve this issue.  There may be some ways to shorten the code a bit, for examle:

        If actionr = 1 then
          enemy_health = enemy_health
        elseIf actionr = 2 then
          enemy_health = enemy_health - player_magic_strength
        elseIf actionr = 3 then
          enemy_health = enemy_health - player_magic_strength*2
        endif

    could be

    enemy_health = enemy_health - (actionr-1)*player_magic_strength


    • Edited by litdev Wednesday, September 23, 2015 7:37 PM
    Wednesday, September 23, 2015 7:37 PM
  • so this is a game where players use magic. what im thinking of doing is making a separate file for each magic. one fore fire, one for water so on and so forth. your code would make total sense except that i have cancelations in the game. water beats fire so fire magic will have no effect.  I think this way would be better so people dont have to download the program. they just have to open smallbasic and import it. i have a forum on g+ called Fairytail and kindgom hearts smallbasic where i post code and imports and things like that on there. but thats basically what im gonna do people request a magic and give them a import code of a magic randomly selected. 

    Do you think thats a good idea. thats the best i could come up with right now.

    Wednesday, September 23, 2015 7:41 PM
  • Yes that sounds great.  You could write some instructions, screen shots etc and advertise the program on this forum, I'm sure we could also write a blog post on it when its ready.

    Good work.

    Wednesday, September 23, 2015 7:46 PM
  • Thank you for the help. I am actually going to make a "commercial". make alike a story plot of the game using that code that i already have. knda like a game intro when the viewers see a sneak peek of the plot and the actions and environment. Im making using smallbasic. no video editing. just using shapes to change scenes and stuff. im actually looking for devs to help me. make the story line.
    Wednesday, September 23, 2015 7:50 PM
  • I'm pretty sure the publishing limit is due to file sizel. I recently exceeded the limit with only 50 loc but some very long (wide) strings. I shortened the strings and got it published.

    To get large files published I'd try to:

    • reduce commenting (perhaps a hosted txt document could help)
    • reduce blocks of spaces
    • optimise long strings where possible
    • refactor by writing a simple parser that shortens some variables

    Also if you have a website that allows it, mine used to but a recent security feature put an end to that, you can try something like:

    path = "http://name/data.txt"
    
    content = Network.GetWebPageContents(path)
    
    TextWindow.WriteLine(content)
    Here's a test of over 3000 loc http://smallbasic.com/program/?FLZ541




    • Edited by Jibba j Thursday, September 24, 2015 6:17 AM refactor
    • Proposed as answer by Liam McSherry Sunday, September 27, 2015 8:36 AM
    • Marked as answer by litdev Tuesday, October 13, 2015 8:39 PM
    Wednesday, September 23, 2015 9:09 PM
  • sorry but whats loc?

    i did all three of what u said. i dont really use websites and i use textwindow to say specific things. 

    Thursday, September 24, 2015 1:32 AM
  • Lines of code.
    Thursday, September 24, 2015 2:43 AM
  • If your program is only just too big, you can reduce the size before publishing by running the following program. It needs the LitDev extension. This removes all spaces at the start of a line, which reduces the size by typical 15%, and the spaces to the left and right of an equals sign and next to a comma. The gives one extra percent reduction.   

    Your program VMM159 has a size of 72023 bytes. The program gives the new program the name VMM159S with a size of 56629 bytes (- 17.2%)

    ' SHRINK  150926  WhTurner
    ' shrink a file by removing indenting spaces and spaces before and after a "="
    'uses LitDev-extension
    
    CRLF= Text.GetCharacter(13)+Text.GetCharacter(10)
    TextWindow.Write("Give filename (without extension): ")
    FI=TextWindow.Read()
    FO=Program.Directory+"\"+FI+"S.sb"
    FI=Program.Directory+"\"+FI+".sb"
    File.DeleteFile(FO)
    buf=File.ReadContents(FI)
    Len1=Text.GetLength(buf)
    TextWindow.WriteLine("Length of file: "+Len1)
    line=LDText.Split(buf,CRLF)
    TextWindow.WriteLine("Number of lines: "+Array.GetItemCount(line))
    For num=1 To Array.GetItemCount(line)
      parts= LDText.Split(line[num],"=")  ' remove spaces left/right of "="
      newLine=LDText.Trim(parts[1])
      For par=2 To Array.GetItemCount(parts)
        newLine=Text.Append(newLine+"=", LDText.Trim(parts[par]))
      EndFor
      parts= LDText.Split(newLine,",")  ' remove spaces left/right of ","
      newLine=LDText.Trim(parts[1])
      For par=2 To Array.GetItemCount(parts)
        newLine=Text.Append(newLine+",", LDText.Trim(parts[par]))
      EndFor
      File.AppendContents(FO,newLine)
    EndFor
    buf=File.ReadContents(FO)
    Len2=Text.GetLength(buf)
    TextWindow.WriteLine("New Length of file: "+Len2)
    reduct=Math.Round((1-len2/len1)*1000)
    TextWindow.WriteLine("Reduction in size : "+reduct/10+"%")
    


    Jan [ WhTurner ] The Netherlands

    Saturday, September 26, 2015 2:58 PM
    Answerer
  • Is there a way to do that without litdev. i do not have that extension.
    Saturday, October 10, 2015 5:01 PM
  • Btw, Thank you. I decided to make the game simple but not simpler, i took off some lines of code and implemented the code that litdev offered for the health loss. i also am implementing better graphics and a ui system before the game for customization.
    Saturday, October 10, 2015 5:04 PM
  • ok, litdev, this game is pretty much completed in character creation and basic fight scenes. how would i advertise?
    Saturday, October 17, 2015 7:27 PM
  • First is start a discussion post for it on this forum with download instructions, a description and a couple screen shots.

    Get a bit of feed-back, make sure downloads etc work.

    Then post a request to get it blogged about on the Small Basic blog which also posts it to Small Basic on Twitter by making a post on this thread.  This should get around 1000 views or so, so make sure it is in a fairly finished state before requesting a blog about it.

    You can also upload it on Technet Gallery, or write a Wiki article about it on Technet Wiki.


    • Edited by litdev Saturday, October 17, 2015 8:30 PM
    Saturday, October 17, 2015 7:53 PM
  • ok, well im sure this game will finish in about 1-5 year or so because im doing a story mode and im the only dev soo...
    Saturday, October 17, 2015 8:38 PM
  • aaand how do you make a discussion post?
    Saturday, October 17, 2015 8:40 PM
  • Click "Ask a Question" on this forum and Click "Start a Discussion" give its suitable title and add content - basically a discussion is just a thread that has no specific question, but in your case advertises your program.
    Saturday, October 17, 2015 8:42 PM
  • ok i have made the discussion. 
    Saturday, October 17, 2015 9:17 PM
  • https://social.msdn.microsoft.com/Forums/en-US/8ebb311c-ff69-4185-b445-dc44e162b72b/fairytail-smallbasic-game-by-jetfire3201-and-russianbrain?forum=smallbasic
    Saturday, October 17, 2015 9:24 PM