
FreeBASIC's Official Forums
|
| View previous topic :: View next topic |
| Author |
Message |
|
|
Posted: Jan 23, 2006 0:48 Post subject: Ascii Chart |
|
|
This is a little utility program to display ascii chars and box styles.
| Code:
|
|
'An ascii chart for low and high ascii chars' 'Richard D. Clark' 'Freeware' '*****************************************************************' Const fbWhite = RGB (255, 255, 255) Const fbYellow = RGB (255, 255, 000) Const fbGrey = RGB (192, 192, 192) Const fbBlack = RGB (0, 0, 0) Const fbGreen = RGB (000, 255, 000) Const fbEmeraldGreen = RGB (000, 201, 087) Const fbGreenPale = RGB (152, 251, 152) Const fbYellowGreen = RGB (154, 205, 050) Const fbOrange = RGB (255, 128, 000) Const fbSalmon = RGB (250, 128, 114) Const fbCarrot = RGB (237, 145, 033) Const fbMarsYellow = RGB (227, 112, 026) Const fbGold = RGB (255, 215, 000) Const fbMelon = RGB (227, 168, 105)
WindowTitle "Ascii Code Table" Screen 18, 32
Sub PrintAscii Dim As Integer i, ccol, col, row Dim As String cout Color fbWhite, fbBlack Cls col = 1 row = 1 Color fbOrange, fbBlack Locate row, col Print "Low Ascii" For i = 0 To 127 row += 1 ccol = col cout = trim$(Str$(i)) If Len(cout) < 3 Then cout = String$(3 - Len(cout), "0") + cout End If Color fbWhite, fbBlack Locate row, ccol Print cout ccol += 3 Color fbGrey, fbBlack Locate row, ccol Print ":" ccol += 1 If i >= 65 And i <= 90 Then Color fbGreen, fbBlack Elseif i >= 97 And i <= 122 Then Color fbEmeraldGreen, fbBlack Elseif i >= 48 And i <= 57 Then Color fbGreenPale, fbBlack Elseif i >= 3 And i <= 6 Then Color fbYellowGreen, fbBlack Else Color fbYellow, fbBlack End If If i <> 7 Then Locate row, ccol Print Chr$(i) End If ccol += 1 Locate row, ccol Print " " If row = 14 Then row = 1 col = ccol + 2 End If Next row = 15 Color fbOrange, fbBlack col = 1 Locate row, col Print "High Ascii" For i = 128 To 255 row += 1 ccol = col cout = trim$(Str$(i)) If Len(cout) < 3 Then cout = String$(3 - Len(cout), "0") + cout End If Color fbWhite, fbBlack Locate row, ccol Print cout ccol += 3 Color fbGrey, fbBlack Locate row, ccol Print ":" ccol += 1 If i >= 176 And i <= 178 Then Color fbGold, fbBlack Elseif i >= 219 And i <= 223 Then Color fbSalmon, fbBlack Elseif i = 201 Or i = 205 Or i = 203 Or i = 187 Or _ i = 186 Or i = 204 Or i = 206 Or i = 185 Or _ i = 200 Or i = 202 Or i = 188 Then Color fbCarrot, fbBlack Elseif i = 218 Or i = 196 Or i = 194 Or i = 191 Or _ i = 179 Or i = 195 Or i = 197 Or i = 180 Or _ i = 192 Or i = 193 Or i = 217 Then Color fbMarsYellow, fbBlack Elseif i = 213 Or i = 209 Or i = 184 Or i = 198 Or _ i = 198 Or i = 216 Or i = 181 Or i = 212 Or _ i = 207 Or i = 190 Then Color fbMelon, fbBlack Else Color fbYellow, fbBlack End If Locate row, ccol Print Chr$(i) ccol += 1 Locate row, ccol Print " " If row = 28 Then row = 15 col = ccol + 2 End If Next Color fbWhite, fbBlack Locate 30, 1 Print "Press B for box codes. ESC to quit."; End Sub
Sub DrawBox Color fbWhite, fbBlack Cls Locate 1, 1 Print "Double-line box:" Color fbYellow, fbBlack Locate 2, 1 Print Chr$(201);chr$(205);chr$(205);chr$(203);chr$(205);chr$(205);chr$(187) Locate 3, 1 Print Chr$(186);chr$(32);chr$(32);chr$(186);chr$(32);chr$(32);chr$(186) Locate 4, 1 Print Chr$(204);chr$(205);chr$(205);chr$(206);chr$(205);chr$(205);chr$(185) Locate 5, 1 Print Chr$(186);chr$(32);chr$(32);chr$(186);chr$(32);chr$(32);chr$(186) Locate 6, 1 Print Chr$(200);chr$(205);chr$(205);chr$(202);chr$(205);chr$(205);chr$(188) Color fbWhite, fbBlack Locate 2, 9 Print "201 ";"205 ";"205 ";"203 ";"205 ";"205 ";"187" Locate 3, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186" Locate 4, 9 Print "204 ";"205 ";"205 ";"206 ";"205 ";"205 ";"185 " Locate 5, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186 " Locate 6, 9 Print "200 ";"205 ";"205 ";"202 ";"205 ";"205 ";"188 "
Color fbWhite, fbBlack Locate 8, 1 Print "Single-line box:" Color fbYellow, fbBlack Locate 9, 1 Print Chr$(218);chr$(196);chr$(196);chr$(194);chr$(196);chr$(196);chr$(191) Locate 10, 1 Print Chr$(179);chr$(32);chr$(32);chr$(179);chr$(32);chr$(32);chr$(179) Locate 11, 1 Print Chr$(195);chr$(196);chr$(196);chr$(197);chr$(196);chr$(196);chr$(180) Locate 12, 1 Print Chr$(179);chr$(32);chr$(32);chr$(179);chr$(32);chr$(32);chr$(179) Locate 13, 1 Print Chr$(192);chr$(196);chr$(196);chr$(193);chr$(196);chr$(196);chr$(217) Color fbWhite, fbBlack Locate 9, 9 Print "218 ";"196 ";"196 ";"194 ";"196 ";"196 ";"191" Locate 10, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179" Locate 11, 9 Print "195 ";"196 ";"196 ";"197 ";"196 ";"196 ";"180 " Locate 12, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179 " Locate 13, 9 Print "192 ";"196 ";"196 ";"193 ";"196 ";"196 ";"217 "
Color fbWhite, fbBlack Locate 15, 1 Print "Double/single line box:" Color fbYellow, fbBlack Locate 16, 1 Print Chr$(213);chr$(205);chr$(205);chr$(209);chr$(205);chr$(205);chr$(184) Locate 17, 1 Print Chr$(179);chr$(32);chr$(32);chr$(179);chr$(32);chr$(32);chr$(179) Locate 18, 1 Print Chr$(198);chr$(205);chr$(205);chr$(216);chr$(205);chr$(205);chr$(181) Locate 19, 1 Print Chr$(179);chr$(32);chr$(32);chr$(179);chr$(32);chr$(32);chr$(179) Locate 20, 1 Print Chr$(212);chr$(205);chr$(205);chr$(207);chr$(205);chr$(205);chr$(190) Color fbWhite, fbBlack Locate 16, 9 Print "213 ";"205 ";"205 ";"209 ";"205 ";"205 ";"184" Locate 17, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179" Locate 18, 9 Print "198 ";"205 ";"205 ";"216 ";"205 ";"205 ";"181 " Locate 19, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179 " Locate 20, 9 Print "212 ";"205 ";"205 ";"207 ";"205 ";"205 ";"190 "
Color fbWhite, fbBlack Locate 22, 1 Print "Single/Double line box:" Color fbYellow, fbBlack Locate 23, 1 Print Chr$(214);chr$(196);chr$(196);chr$(210);chr$(196);chr$(196);chr$(183) Locate 24, 1 Print Chr$(186);chr$(32);chr$(32);chr$(186);chr$(32);chr$(32);chr$(186) Locate 25, 1 Print Chr$(199);chr$(196);chr$(196);chr$(215);chr$(196);chr$(196);chr$(182) Locate 26, 1 Print Chr$(186);chr$(32);chr$(32);chr$(186);chr$(32);chr$(32);chr$(186) Locate 27, 1 Print Chr$(211);chr$(196);chr$(196);chr$(208);chr$(196);chr$(196);chr$(189) Color fbWhite, fbBlack Locate 23, 9 Print "214 ";"196 ";"196 ";"210 ";"196 ";"196 ";"183" Locate 24, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186" Locate 25, 9 Print "199 ";"196 ";"196 ";"215 ";"196 ";"196 ";"182 " Locate 26, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186" Locate 27, 9 Print "211 ";"196 ";"196 ";"208 ";"196 ";"196 ";"189 " Color fbWhite, fbBlack Locate 30, 1 Print "Press any key to return to ascii chart."; Sleep While Inkey$<>"":Wend End Sub
Dim skey As String
PrintAscii Do skey = Ucase$(Inkey$) If skey = "B" Then DrawBox PrintAscii End If Sleep 1 Loop Until skey = Chr$(27) End
|
|
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 23, 2006 2:12 Post subject: |
|
|
Thats cool, I like the colors ^_^
~Thrawn~ |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 23, 2006 2:28 Post subject: |
|
|
| That is really nice. I also like the colors chose, they work well. |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 23, 2006 3:25 Post subject: |
|
|
realy useful i like this tool.
Joshy |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 23, 2006 10:43 Post subject: |
|
|
| this should be added to the examples distributed with freebasic, maybe with the name like ascii_demo.bas or something ^.^ |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 23, 2006 12:08 Post subject: |
|
|
| Thanks guys. I was tired of looking up codes and then wondering how they would look on screen. :) |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 23, 2006 13:39 Post subject: |
|
|
| thats just one more reason why an ide like qb's is just what fb needs. all that kinda stuff was right there for you. |
| |
|
| Back to top |
|
 |
|
|
Posted: Jan 23, 2006 14:06 Post subject: |
|
|
Yep I agree with cha0s.
Oh, Im not trying to you know to put your project down or anything but when Im running a program it slows down my lappy some, so I just use this:
ASCII Chart
Did I mention I like the colors?
Oh ya the box codes were good too...very helpful
~Thrawn~ |
| |
|
| Back to top |
|
 |
|
|
Posted: Feb 08, 2006 20:51 Post subject: |
|
|
| Thrawn89 wrote: | Oh, Im not trying to you know to put your project down or anything but when Im running a program it slows down my lappy some, so I just use this:
ASCII Chart
~Thrawn~ |
I disagree :D
Program is nice, beautifull and simple as hell.
Just run it on secondary desktop and use first one for programming. :D |
| |
|
| Back to top |
|
 |
|
|
Posted: Feb 09, 2006 9:32 Post subject: |
|
|
| Nice and very useful. |
| |
|
| Back to top |
|
 |
|
|
Posted: Feb 23, 2006 15:00 Post subject: |
|
|
If you look at the code in my chart program, you'll see that I am using a graphics screen so I could use some pretty colors. :) However, I noticed that some of the characters weren't being printed (26 through 31) so I made a console version:
| Code:
|
|
'An ascii chart for low and high ascii chars' 'Console version of chart, compiled with FreeBasic .15b' 'Richard D. Clark' 'Freeware' '*****************************************************************' Const Black = 0 Const Blue = 1 Const Green = 2 Const Cyan = 3 Const Red = 4 Const Magenta = 5 Const Brown = 6 Const LtGrey = 7 Const DkGrey = 8 Const BBlue = 9 Const BGreen = 10 Const BCyan = 11 Const BRed = 12 Const BMagenta = 13 Const Yellow = 14 Const White = 15
Windowtitle "Ascii Code Table" Width 80, 30
Sub PrintAscii Dim As Integer i, ccol, col, row Dim As String cout Color White, Black Cls col = 1 row = 1 Color Yellow, fbBlack Locate row, col Print "Low Ascii" For i = 0 To 127 row += 1 ccol = col cout = trim(Str(i)) If Len(cout) < 3 Then cout = String(3 - Len(cout), "0") + cout End If Color White, Black Locate row, ccol Print cout ccol += 3 Color Grey, Black Locate row, ccol Print ":" ccol += 1 If i >= 65 And i <= 90 Then Color Green, Black Elseif i >= 97 And i <= 122 Then Color BGreen, Black Elseif i >= 48 And i <= 57 Then Color BRed, Black Elseif i >= 3 And i <= 6 Then Color Cyan, fbBlack Else Color Yellow, Black End If If i <> 7 Then Locate row, ccol Print Chr(i) End If ccol += 1 Locate row, ccol Print " " If row = 14 Then row = 1 col = ccol + 2 End If Next row = 15 Color Yellow, Black col = 1 Locate row, col Print "High Ascii" For i = 128 To 255 row += 1 ccol = col cout = trim(Str(i)) If Len(cout) < 3 Then cout = String(3 - Len(cout), "0") + cout End If Color White, Black Locate row, ccol Print cout ccol += 3 Color Grey, Black Locate row, ccol Print ":" ccol += 1 If i >= 176 And i <= 178 Then Color BGreen, fbBlack Elseif i >= 219 And i <= 223 Then Color BCyan, Black Elseif i = 201 Or i = 205 Or i = 203 Or i = 187 Or _ i = 186 Or i = 204 Or i = 206 Or i = 185 Or _ i = 200 Or i = 202 Or i = 188 Then Color BBlue, Black Elseif i = 218 Or i = 196 Or i = 194 Or i = 191 Or _ i = 179 Or i = 195 Or i = 197 Or i = 180 Or _ i = 192 Or i = 193 Or i = 217 Then Color BMagenta, Black Elseif i = 213 Or i = 209 Or i = 184 Or i = 198 Or _ i = 198 Or i = 216 Or i = 181 Or i = 212 Or _ i = 207 Or i = 190 Then Color BRed, fbBlack Else Color Yellow, Black End If Locate row, ccol Print Chr(i) ccol += 1 Locate row, ccol Print " " If row = 28 Then row = 15 col = ccol + 2 End If Next Color White, Black Locate 30, 1 Print "Press B for box codes. ESC to quit."; End Sub
Sub DrawBox Color White, Black Cls Locate 1, 1 Print "Double-line box:" Color Yellow, Black Locate 2, 1 Print Chr(201);Chr(205);Chr(205);Chr(203);Chr(205);Chr(205);Chr(187) Locate 3, 1 Print Chr(186);Chr(32);Chr(32);Chr(186);Chr(32);Chr(32);Chr(186) Locate 4, 1 Print Chr(204);Chr(205);Chr(205);Chr(206);Chr(205);Chr(205);Chr(185) Locate 5, 1 Print Chr(186);Chr(32);Chr(32);Chr(186);Chr(32);Chr(32);Chr(186) Locate 6, 1 Print Chr(200);Chr(205);Chr(205);Chr(202);Chr(205);Chr(205);Chr(188) Color White, Black Locate 2, 9 Print "201 ";"205 ";"205 ";"203 ";"205 ";"205 ";"187" Locate 3, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186" Locate 4, 9 Print "204 ";"205 ";"205 ";"206 ";"205 ";"205 ";"185 " Locate 5, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186 " Locate 6, 9 Print "200 ";"205 ";"205 ";"202 ";"205 ";"205 ";"188 "
Color White, Black Locate 8, 1 Print "Single-line box:" Color Yellow, Black Locate 9, 1 Print Chr(218);Chr(196);Chr(196);Chr(194);Chr(196);Chr(196);Chr(191) Locate 10, 1 Print Chr(179);Chr(32);Chr(32);Chr(179);Chr(32);Chr(32);Chr(179) Locate 11, 1 Print Chr(195);Chr(196);Chr(196);Chr(197);Chr(196);Chr(196);Chr(180) Locate 12, 1 Print Chr(179);Chr(32);Chr(32);Chr(179);Chr(32);Chr(32);Chr(179) Locate 13, 1 Print Chr(192);Chr(196);Chr(196);Chr(193);Chr(196);Chr(196);Chr(217) Color White, Black Locate 9, 9 Print "218 ";"196 ";"196 ";"194 ";"196 ";"196 ";"191" Locate 10, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179" Locate 11, 9 Print "195 ";"196 ";"196 ";"197 ";"196 ";"196 ";"180 " Locate 12, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179 " Locate 13, 9 Print "192 ";"196 ";"196 ";"193 ";"196 ";"196 ";"217 "
Color White, Black Locate 15, 1 Print "Double/single line box:" Color Yellow, Black Locate 16, 1 Print Chr(213);Chr(205);Chr(205);Chr(209);Chr(205);Chr(205);Chr(184) Locate 17, 1 Print Chr(179);Chr(32);Chr(32);Chr(179);Chr(32);Chr(32);Chr(179) Locate 18, 1 Print Chr(198);Chr(205);Chr(205);Chr(216);Chr(205);Chr(205);Chr(181) Locate 19, 1 Print Chr(179);Chr(32);Chr(32);Chr(179);Chr(32);Chr(32);Chr(179) Locate 20, 1 Print Chr(212);Chr(205);Chr(205);Chr(207);Chr(205);Chr(205);Chr(190) Color White, Black Locate 16, 9 Print "213 ";"205 ";"205 ";"209 ";"205 ";"205 ";"184" Locate 17, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179" Locate 18, 9 Print "198 ";"205 ";"205 ";"216 ";"205 ";"205 ";"181 " Locate 19, 9 Print "179 ";" ";" ";"179 ";" ";" ";"179 " Locate 20, 9 Print "212 ";"205 ";"205 ";"207 ";"205 ";"205 ";"190 "
Color White, Black Locate 22, 1 Print "Single/Double line box:" Color Yellow, Black Locate 23, 1 Print Chr(214);Chr(196);Chr(196);Chr(210);Chr(196);Chr(196);Chr(183) Locate 24, 1 Print Chr(186);Chr(32);Chr(32);Chr(186);Chr(32);Chr(32);Chr(186) Locate 25, 1 Print Chr(199);Chr(196);Chr(196);Chr(215);Chr(196);Chr(196);Chr(182) Locate 26, 1 Print Chr(186);Chr(32);Chr(32);Chr(186);Chr(32);Chr(32);Chr(186) Locate 27, 1 Print Chr(211);Chr(196);Chr(196);Chr(208);Chr(196);Chr(196);Chr(189) Color White, Black Locate 23, 9 Print "214 ";"196 ";"196 ";"210 ";"196 ";"196 ";"183" Locate 24, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186" Locate 25, 9 Print "199 ";"196 ";"196 ";"215 ";"196 ";"196 ";"182 " Locate 26, 9 Print "186 ";" ";" ";"186 ";" ";" ";"186" Locate 27, 9 Print "211 ";"196 ";"196 ";"208 ";"196 ";"196 ";"189 " Color White, Black Locate 30, 1 Print "Press any key to return to ascii chart."; Sleep While inkey<>"":Wend End Sub
Dim skey As String
PrintAscii Do skey = Ucase(Inkey) If skey = "B" Then DrawBox PrintAscii End If Sleep 1 Loop Until skey = Chr$(27)
|
|
| |
|
| Back to top |
|
 |
|
|
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
|
|