? Text-Only Loading Bar ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Creep into the Halloween / Horror Programming Contest (Deadline Extended)

Text-Only Loading Bar

A progress/loading bar, made from only text. It's accurate to the nearest pixel DEF TEXTBAR LENGTH% PRINT ""*(LENGTH% DIV 8); IF LENGTH% MOD 8 THEN PRINT " "[LENGTH% MOD 8]; END Draws a LENGTH% * 8(pixel) rectangle with text For loading on the top screen LENGTH% should be PROGRESS/MAXIMUM * 400
Author
12Me21
Updated
Rating
4 votes
Categories
Keywords
12 Comment(s) chicken chicken OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Avatar Embargo I didn't change my avatar for 90 days Website Good Page Hidden Achievements woah, you can do string picking using array syntax? what is this wizardry? 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS It's called not being terrible at programming Yeah, strings are kind of like arrays of characters, so you can use most array commands on them, like PUSH, POP, COPY, etc. chicken chicken OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Avatar Embargo I didn't change my avatar for 90 days Website Good Page Hidden Achievements D: SquareFingers SquareFingers Code gives syntax error. Use + for string concatenation. It would also be more useful if there wasn't a space character at the end of lengths that are multiples of 8. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS yeah, that was a typo as for the space at the end, I'll add *!!(LENGTH MOD 8) or something SquareFingers SquareFingers The second string now appears to have only 7 characters: for the indexing to work, you need 8 characters in the string, including one for the condition L MOD 8 == 0, even though that character will be removed from the resulting string by *0. - I hope I do not annoy, I just want to see this code be the best it can be. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS Yeah, another typo. thanks SquareFingers SquareFingers I'd recommend using the # suffix so it also works in programs that have OPTION DEFINT. EDIT: I'd also make the max length a parameter, so it can be used on the lower screen and as part of a line. And to answer your question, a variable named PERCENT should have a percent value. Perhaps you're looking for PROGRESS#. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS length is in pixels, so it doesn't really matter if it's an integer or not. 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS (also function arguments ignore type suffixes) SquareFingers SquareFingers The code has changed since my comment, and it is true that in the current version of SmileBasic, variable suffixes on actual parameters are meaningless, but the recommendation remains that variable names - including suffix - are better more descriptive than less (until you run into excessive wordiness, which one extra symbol is not). 12Me21 12Me21 Admin Syntax Highlighter Received for creating the code syntax highlighter on SBS I usually put type suffixes on function arguments (this function doesn't have them because I was bad at programming when I wrote it). But now that I think about it, using type suffixes here is actually kind of misleading, since it implies that SB will convert the passed values to the specified type. For example: DEF EVEN(X#) X#=X#/2 RETURN FLOOR(X#)==X# END It looks like it should work, but if you do EVEN(5) it will return TRUE. This is because X# is actually an integer in that case. (This won't stop me from using type suffixes, though.)