rnbw
New Member
Posts: 4
|
Post by rnbw on Oct 10, 2020 16:44:46 GMT
I can see why rogerm would want to use a more up to date Basic than PC-Basic, but why rewrite the code when you can simply load it into another more modern Basic (with a very minor change in Freebasic) and then simply run it. Of the Basics that I have used recently, only QB64 and Freebasic will print the border characters natively. I've done a very limited check and they print the border characters to a Brother laser printer via Wifi. I can also see why rogerm would like to use Just Basic. It is very easy to work with and would do the job. However, I agree with tenochtitlanuk and would use the system he proposed for the borders. I would also suggest, that if this is for work purposes, rogerm invest in a copy of Liberty Basic and use that rather than Just Basic. I think if it is being used in a commercial environment, then it is only fair to Carl Gundel that Liberty Basic be used. Just Basic is intended to promote Liberty Basic, not replace it. The cost of Liberty Basic is very reasonable.
|
|
|
Post by rogerm on Oct 12, 2020 19:28:50 GMT
I can see why rogerm would want to use a more up to date Basic than PC-Basic, but why rewrite the code when you can simply load it into another more modern Basic (with a very minor change in Freebasic) and then simply run it. Of the Basics that I have used recently, only QB64 and Freebasic will print the border characters natively. I've done a very limited check and they print the border characters to a Brother laser printer via Wifi. I had tried Freebasic a year or so ago (this has been an on-again, off-again project as I've had time to look at it) but it threw so many errors on trying to compile the code I quickly wrote it off. However, on the basis of this reply, I tried with just a small section of the original code and after turning on the -lang deprecated switch and fixing a couple of 'missing eol' errors that undoubtedly resulted from my copy and paste job, the darned thing compiled, ran, and printed a correctly-formatted report on my HP printer.
I certainly enjoy trying things out with Just BASIC and you all have been incredibly quick and helpful in your responses. I'll definitely keep using Just BASIC (and, potentially, Liberty BASIC eventually!) but for this particular implementation I think I've got my fix now.
Thanks all!
|
|
|
Post by tsh73 on Oct 12, 2020 21:11:39 GMT
I'm a bit too late - and it did not came as perfect as I hoped. Fixed now. But here's an idea If we look at UTF8, ordinary ASCII goes unchanged and box characters are just 3 lines in 16x16 table So I printed 16x16 table copied it pasted to Notepad and saved as UTF8 Viola - now I have 3-byte character codes for box characters in UTF8 And I added marker in the beginning of the file so Notepad opens it as Unicode First program demonstrate it, tested under Win10 I added hex codes (B0 etc) so I could find box character I need. It prints these codes into text file and opens it with Notepad You should change notepad font for monospaced font for equal width box characters. I got really nice borders with Lucida Console font (with Courier I had gaps between lines) (btw do you know you can print with notepad /p ?)
'use UTF8 'ASCII (codes 323-127) goes unchanged 'box characters (codes ' from 176 to 223 ' from B0 to DF ') changed to 3 bytes each by table 'And I add marker EFBBBF in the beginning of text 'so Notepad shows box characters. 'Do you know you can print with Notepad /p (/pt with naming printer)
hexString$ = "E29691E29692E29693E29482E294A4E295A1E295A2E29596E29595E295A3E29591E29597E2959DE2959CE2959BE29490E29494E294B4E294ACE2949CE29480E294BCE2959EE2959FE2959AE29594E295A9E295A6E295A0E29590E295ACE295A7E295A8E295A4E295A5E29599E29598E29592E29593E295ABE295AAE29498E2948CE29688E29684E2968CE29690E29680" boxChars$="" for i = 1 to len(hexString$) step 2 boxChars$=boxChars$+chr$(hexdec(mid$(hexString$, i, 2))) next
fileName$="outUTF8.txt" open fileName$ for output as #1
'print marker print #1, chr$(hexdec("ef"));chr$(hexdec("bb"));chr$(hexdec("bf"));
'ASCII text goes as normal - single byte for i = 2 to 7 for j =0 to 15 c$=chr$(i*16+j) print c$; print #1, c$; next print print #1, "" 'normal CR LF next
print print #1, "" 'normal CR LF
'skip 3 lines (j=8,9,10) to 3 lines of box characters 'box sumbols goes from table, 3 bytes 'I print B0 etc marks so I could pick needed box characters later for i = 11 to 13 'start of the line mark print dechex$(i*16);" "; print #1, dechex$(i*16);" "; for j =0 to 15 'middle mark if j = 8 then print " ";dechex$(i*16+8);" "; if j = 8 then print #1," ";dechex$(i*16+8);" "; c=i*16+j c$=mid$(boxChars$,(c-176)*3+1,3) '3 bytes by table print chr$(i*16+j); 'that's code in codepage 437. Does not work here print #1, c$; next print print #1, "" next
close #1
'make small pause and run Notepad with the file timer 300, [wait] wait [wait] timer 0 run "notepad.exe ";fileName$
Second program used these codes to make table border And with Lucida Console font it looks really good (if I already had files with borders in codepage 437, I'd just change all characters with codes "c" from 176 to 223 to mid$(boxChars$,(c-176)*3+1,3) )
I had a problem with the first line of the table - I got "d1" printed there T box symbol should be. (it happened then printing to file, nothing showed on the mainwin) But I circumvented it by making lone first then printing it. So now output is perfect.
hexString$ = "E29691E29692E29693E29482E294A4E295A1E295A2E29596E29595E295A3E29591E29597E2959DE2959CE2959BE29490E29494E294B4E294ACE2949CE29480E294BCE2959EE2959FE2959AE29594E295A9E295A6E295A0E29590E295ACE295A7E295A8E295A4E295A5E29599E29598E29592E29593E295ABE295AAE29498E2948CE29688E29684E2968CE29690E29680" global boxChars$ boxChars$="" for i = 1 to len(hexString$) step 2 boxChars$=boxChars$+chr$(hexdec(mid$(hexString$, i, 2))) next
'print box$("d1") 'print box$("c9");string$(box$("="), 10);box$("d1");string$(box$("="), 10);box$("bb") 'end
fileName$="outTableUTF8.txt" open fileName$ for output as #1
'print marker print #1, chr$(hexdec("ef"));chr$(hexdec("bb"));chr$(hexdec("bf"));
'first line should work, But somehow it produces d1 in the center 'print #1,box$("c9");string$(box$("="), 10);box$("d1");string$(box$("="), 10);box$("bb") aLine$=box$("c9");string$(box$("="), 10);box$("d1");string$(box$("="), 10);box$("bb") print #1, aLine$
print #1,box$("!");center$("X",10);box$("|");center$("Y",10);box$("!") print #1,box$("cc");string$(box$("="), 10);box$("d8");string$(box$("="), 10);box$("b9")
for x = 0 to 6.3 step 0.3 y = sin(x) print #1,box$("!");center$(using ("#.##",x),10);box$("|");center$(using ("##.#####",y),10);box$("!") next print #1,box$("d3");string$(box$("-"), 10);box$("c1");string$(box$("-"), 10);box$("bd") close #1
'make small pause and run Notepad with the file timer 300, [wait] wait [wait] timer 0 run "notepad.exe ";fileName$
'functions '--------------------------------------------- function box$(hex$) box$="." 'default wrong char select case hex$ case "-":hex$="c4" case "=":hex$="cd" case "|":hex$="b3" case "!":hex$="ba" '|| end select c=hexdec(hex$) ' from 176 to 223 ' from B0 to DF if c <176 or c >223 then exit function box$=mid$(boxChars$,(c-176)*3+1,3) '3 bytes by table end function
function string$(c$, n) for i = 1 to n string$ = string$ +c$ next end function
'adds spaces from the left until 'n' symbols 'if n<len(a$) returns left$(a$,n) function padl$(a$,n) padl$ = left$(space$(n-len(a$))+a$,n) end function
'adds spaces from the right until 'n' symbols 'if n<len(a$) returns left$(a$,n) function padr$(a$,n) padr$ = left$(a$+space$(n-len(a$)),n) end function
function center$(a$,n) center$ = left$(space$((n-len(a$))/2)+a$+space$((n-len(a$))/2+1),n) end function
|
|
|
Post by tsh73 on Oct 12, 2020 21:19:27 GMT
Just tested it under Win XP It looks like it will not find text file until you save program So put it in JB, save it, then run. Works OK (and the line that gave me troubles works too. I don't really mind)
|
|
|
Post by donnybowers on Oct 13, 2020 1:03:38 GMT
Hello all!
Very brief background: I support a legacy DOS-based accounting program (written in PC-BASIC) as part of my job duties. Over time I have taken it from running on native hardware (dedicated x86 workstation and a dot matrix printer), to running in an XP environment in a compatibility mode terminal window using DOSPRN to handle the printing. However I'd like to get beyond XP for security purposes and I was looking to port the entire program into a newer version of BASIC. Just BASIC seems ideal as there's minimal conversion from the original source and I love being able to print with no go-betweens.
However...
Many (most) of the original reports make extensive use of the old high ASCII box characters. I know Windows isn't a fan of ASCII, and it appears based on my searches here in the forum that Just BASIC isn't compatible with Unicode. Do I have any other option at all to get these characters translated over? I've thought about replacing them with some generic character like an asterisk or something but 1) there are a LOT of borders and boxes and they're all hard-coded, and 2) even if I can do all that I've still got users who don't deal well with change so maintaining the look and feel of the original (early 1990's) system is unfortunately pretty important.
Thanks all! Roger M
Edit to add - just in case anyone is unfamiliar with what I'm talking about, the original code uses the ASCII equivalents of the following:
I have a Unicode compatible font (DejaVu Sans) and I can fairly easily use the characters in Word or even here (┏┳┳┓╔══════╗) but when I paste them into Just Basic I get a string of question marks.
I have a couple of ideas, but I may be all wet. Perhaps someone else would know more about whether these ideas would work in Just BASIC or not, or maybe in Liberty BASIC. 1. Use graphics windows and draw the boxes. I'm pretty sure you could create a screen Display experience almost exactly like DOS using LINE and BOX commands with a white or light gray foreground on a black background. What I don't know about this is whether or not you would be able to print these graphics windows on a printer other than to use the PRNT SCRN key. I haven't used BASIC to print to printers since the entire industry changed from the DOS era to the Windows era. The book that came with your printer almost always came with instructions on how to print both text and graphics using BASIC. That's no longer the case and the technology has changed drastically since then. 2. Perhaps use the graphics window idea for the user interface and then send the data to a DOS program that would process the printing and insert the dos box characters at printout (if necessary). Perhaps this could be done using some invisible characters in the original document like TABs, chr$(9) [ASCII character 9], or maybe just by counting characters. Of course this might be difficult if there are a lot of different kinds of tables etc. that your program makes for different things, but if the box windows are all basically the same, this might be fairly easy to do. I guess the biggest problem with this is that newer versions of Windows probably don't have the ability to shell to a DOS program. Something I can't tell you because I no longer use Windows (since they came out with Windows Vista). I do all my JB programming in Linux's Wine compatibility layer or else in a virtual XP machine now. I suppose that if worse came to worst you might consider using a virtual XP machine for your work program, though your users might also have to do some mental work to get used to using the virtual machine too. But if that program is pretty much all they're using you could set up the machine to start the virtual machine on boot and they'd never have to switch back and forth. But using a virtual machine it's really just a matter of switching windows to use their other programs. This shouldn't be a huge learning curve to overcome. You might have to upgrade the memory of the machine, but I use a virtual XP machine all the time and I only have 4 GB of memory. If you have 8 GB or more, which most newer machines probably do; I think the virtual machine would work. Depending on what DOS programming you use, you should be able to set a graphics mode that utilizes the full screen in the XP DOS compatibility environment, though I'm sure you already know this. But if you were only using DOS for printing to the printer this wouldn't be an issue anyway unless you needed to have a DOS based print preview to go with it. I know you can shell to a DOS program in an XP virtual machine, and I would assume you should be able to send output to the printer, though I've never had the need to try this myself. The other obstacle you might run into is the problem of XP being abandonware. I don't know if you can get a license to use XP on a virtual machine or not. But I wouldn't think this should be an issue since the machine is already licensed for whatever version of Windows the company is using. I do know that you can download a copy of 32 bit Windows XP that at winworldpc.com that works great in VirtualBox. Just a couple of brainstorm ideas that may or may not help to trigger another even better idea for a solution.
|
|
|
Post by tenochtitlanuk on Oct 13, 2020 17:18:19 GMT
Anatoly- that was a very neat solution!
|
|