Author Topic: QB64 v1.2 on Linux and OS/X has big problems!  (Read 4214 times)

0 Members and 1 Guest are viewing this topic.

Offline Fifi

  • Forum Regular
  • Posts: 181
    • View Profile
    • My small QB64 contribution
QB64 v1.2 on Linux and OS/X has big problems!
« on: August 20, 2018, 06:13:05 pm »
Hi all,

Sorry but I've been away for a while.

So, just downloaded the last stable Linux release and unfortunately it doesn't work anymore (on Ubuntu 16.04.5 x84 as well as 18.04.1 x64)!

Trying to compile quite a basic program ends with the error message: "C++ Compilation failed (check ./internal/temp/compillog.txt"

Below is the content of this file;

Code: QB64: [Select]
  1. /usr/bin/x86_64-linux-gnu-ld: libqb/os/lnx/libqb_1_2_000000000000.o: relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIC
  2. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_callbacks.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  3. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_cursor.o): relocation R_X86_64_32S against `.data' can not be used when making a PIE object; recompile with -fPIC
  4. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_display.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  5. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_init.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  6. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_input_devices.o): relocation R_X86_64_32 against `.text' can not be used when making a PIE object; recompile with -fPIC
  7. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_joystick.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
  8. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_main.o): relocation R_X86_64_32 against `.text' can not be used when making a PIE object; recompile with -fPIC
  9. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_menu.o): relocation R_X86_64_32 against undefined symbol `glutBitmapHelvetica18' can not be used when making a PIE object; recompile with -fPIC
  10. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_spaceball.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
  11. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_state.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  12. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_structure.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  13. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_window.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
  14. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_ext.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  15. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_font.o): relocation R_X86_64_32S against undefined symbol `glutBitmap8By13' can not be used when making a PIE object; recompile with -fPIC
  16. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_gamemode.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  17. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_geometry.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
  18. /usr/bin/x86_64-linux-gnu-ld: parts/core/os/lnx/src.a(freeglut_misc.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
  19. /usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
  20. collect2: error: ld returned 1 exit status

The problem seems to be that the executable isn't created (or wrongly created) !

Any help would be truly appreciated since I mainly use QB64on Linux boxes (baremetal and VMs).

Best regards.
Fifi
« Last Edit: September 08, 2018, 01:12:45 pm by Fifi »
It's better to look like an idiot for a short time while asking something obvious to an expert than pretending to be smart all your life. (C) Me.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: QB64 v1.2 rev 20180202/85 on Linux can't execute any stuff!
« Reply #1 on: August 20, 2018, 07:09:46 pm »
Looks like qb64 did not setup 'freeglut' correctly. How did you install qb64?

Here is a link to installing qb64 on Linux Mint. Should work for Ubunutu.


Let me know how you went?

J
Logic is the beginning of wisdom.

FellippeHeitor

  • Guest
Re: QB64 v1.2 rev 20180202/85 on Linux can't execute any stuff!
« Reply #2 on: August 20, 2018, 07:54:26 pm »
Please try the latest dev build and let us know if that one works.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: QB64 v1.2 rev 20180202/85 on Linux can't execute any stuff!
« Reply #3 on: August 20, 2018, 09:05:18 pm »
... I would go with Fillippe's suggestion first ...  lol
Logic is the beginning of wisdom.

Offline Fifi

  • Forum Regular
  • Posts: 181
    • View Profile
    • My small QB64 contribution
Re: QB64 v1.2 rev 20180202/85 on Linux can't execute any stuff!
« Reply #4 on: September 08, 2018, 07:21:23 am »
Hello,

Sorry for the delay to respond but due to a huge storm, I've been out of computer for these last three weeks (power supply to change on my iMac 27 and hard drive to change on my Fujitsu tablet). So, both computers are fixed now and I'm back with my problem(s).

Just installed QB64 v 1.2 (20180228/86) on my iMac (OS/X 10.9.5) and ran into the same problem I had with Linux.

Description of the behavior :

I load a .bas source file (loan.bas) and hit the F5 key. Then QB64 compiles the source without any problem (I get the OK message), creates the executable... but doesn't start it and freeze with the message: Starting program...

However, if I launch the created executable with a double left click, it runs well!

More, the "loan_start.command" script created just opens the terminal but closes it immediately without running the program.

This behavior is similar with Linux (Ubuntu 16.04.5 64_bit), but all is OK on Windows 10 Pro 64_bit.

Here is the program I use:

Code: QB64: [Select]
  1. '
  2. ' Program name: loan.bas
  3. '
  4. ' Program that computes for a client the montly payments, interest, principal
  5. ' and balance for a certain amount with a certain fixed interest rate and for
  6. ' a certain number of years and prints the amortization table.
  7. '
  8. ' The executable can be launched with four parameters : name of the client,
  9. ' amount, interest and term.
  10. '
  11. ' The parameters must be entered using a command line arguments in a string of
  12. ' the form: "&name=abcd&amount=xxx&rate=rr.rr&term=zz"
  13. ' where name is the client name (a string without space)
  14. ' xxx is the amount (a long)
  15. ' rr.rr is the rate (a float) - maximum 20
  16. ' and zz is the number of years (an int) - maximun 99
  17. ' e.g. loan &name=John&amount=12000&rate=2.57&term=5
  18. '
  19. ' NOTE:
  20. ' Space(s) can be included between arguments but not between the argument
  21. ' and the sign "=" nor between the sign "=" and the argument value such as:
  22. ' e.g. loan & name=John & amount=12000 & rate=2.57 & term=5
  23. '
  24. ' NOTE:
  25. ' Only the dot sign "." is allowed in float to separate the integer part from
  26. ' its decimal part (no comma sign "," anywhere in a float).
  27. '
  28. ' NOTE:
  29. ' If no parameters are set, the program ask you the values.
  30. ' If there is no value entered (just hit the Enter key), the program computes
  31. ' the default values (Client, 10000.00, 3.5% and 5 years).
  32. '
  33.  
  34.  
  35. '
  36. ' title of the windows when used in a console
  37. '
  38. _TITLE "Loan calculator"
  39.  
  40. '
  41. ' miscelaneous variables initialisation
  42. '
  43. Arg$ = ""
  44. NbArg% = 0
  45. DIM ArrayArg$(4)
  46. lastPayment# = 1.00
  47. Year% = 1
  48.  
  49. '
  50. ' Get the Arguments of the command line
  51. '
  52. LineArg$ = COMMAND$
  53.  
  54. '
  55. ' force parameters if the argument line is empty.
  56. '
  57. IF LEN(LineArg$) = 0 THEN
  58.     '    LineArg$ = "& name=- & amount=10000.00 & rate=3.5 & term=1"
  59.     PRINT "Please enter your name (any name, may be empty but no space):               ";
  60.     INPUT yourname$
  61.     PRINT "Enter the amount to borrow (long, decimal characters) e.g. 1000000:         ";
  62.     INPUT amount$
  63.     PRINT "Enter the % rate of the loan (float, decimal characters with .) e.g. 1.65 : ";
  64.     INPUT rate$
  65.     PRINT "Enter the number of year of the loan (integer, decinal characters) e.g. 12: ";
  66.     INPUT term$
  67.     LineArg$ = "& name=" + yourname$ + " & amount=" + amount$ + " & rate=" + rate$ + " & term=" + term$
  68.  
  69. '
  70. ' store the execution start time
  71. '
  72. timeStart# = TIMER(0.001)
  73.  
  74. '
  75. ' check if the expected arguments names and argument values are the right ones and if so get their relevant values
  76. ' if one argument name or argument type isn't what is expected, use the default argument values.
  77. '
  78. WHILE NbArg% < 4
  79.     IF LEN(LineArg$) > 0 THEN
  80.         FOR i% = 1 TO LEN(LineArg$ + " ")
  81.             GetChar$ = MID$(LineArg$, i%, 1)
  82.             IF (GetChar$ <> "" AND GetChar$ <> " " AND GetChar$ <> "&") THEN
  83.                 Arg$ = Arg$ + GetChar$
  84.             ELSE
  85.                 IF Arg$ <> "" THEN
  86.                     SELECT CASE NbArg%
  87.                         CASE 0
  88.                             IF LEFT$(Arg$, 5) <> "name=" THEN
  89.                                 '    PRINT "problem with the " + CHR$(34) + "first argument naming that should be name= but is: " + CHR$(34) + LEFT$(Arg$, 5) + CHR$(34)
  90.                                 EXIT WHILE
  91.                             ELSEIF isValidArg%(MID$(Arg$, 6), "str") = 0 THEN
  92.                                 '    PRINT "problem with the content of name= that is: " + CHR$(34) + MID$(Arg$, 6) + CHR$(34) + " and isn't a valid string!"
  93.                                 EXIT WHILE
  94.                             ELSE
  95.                                 Arg$ = MID$(Arg$, 6)
  96.                             END IF
  97.                         CASE 1
  98.                             IF LEFT$(Arg$, 7) <> "amount=" THEN
  99.                                 '    PRINT "problem with the " + CHR$(34) + "second argument naming that should be amount= but is: " + CHR$(34) + LEFT$(Arg$, 7) + CHR$(34)
  100.                                 EXIT WHILE
  101.                             ELSEIF isValidArg%(MID$(Arg$, 8), "flt") = 0 THEN
  102.                                 '    PRINT "problem with the content of amount= that is: " + CHR$(34) + MID$(Arg$, 8) + CHR$(34) + " and isn't a valid float!"
  103.                                 EXIT WHILE
  104.                             ELSE
  105.                                 Arg$ = MID$(Arg$, 8)
  106.                             END IF
  107.                         CASE 2
  108.                             IF LEFT$(Arg$, 5) <> "rate=" THEN
  109.                                 '    PRINT "problem with the " + CHR$(34) + "third argument naming that should be rate= but is: " + CHR$(34) + LEFT$(Arg$, 5) + CHR$(34)
  110.                                 EXIT WHILE
  111.                             ELSEIF isValidArg%(MID$(Arg$, 6), "flt") = 0 THEN
  112.                                 '    PRINT "problem with the content of rate= that is: " + CHR$(34) + MID$(Arg$, 6) + CHR$(34) + " and isn't a valid float!"
  113.                                 EXIT WHILE
  114.                             ELSE
  115.                                 Arg$ = MID$(Arg$, 6)
  116.                             END IF
  117.                         CASE 3
  118.                             IF LEFT$(Arg$, 5) <> "term=" THEN
  119.                                 '    PRINT "problem with the " + CHR$(34) + "last argument naming that should be term= but is: " + CHR$(34) + LEFT$(Arg$, 5) + CHR$(34)
  120.                                 EXIT WHILE
  121.                             ELSEIF isValidArg%(MID$(Arg$, 6), "int") = 0 THEN
  122.                                 '    PRINT "problem with the content of rate= that is: " + CHR$(34) + MID$(Arg$, 6) + CHR$(34) + " and isn't a valid integer!"
  123.                                 EXIT WHILE
  124.                             ELSE
  125.                                 Arg$ = MID$(Arg$, 6)
  126.                             END IF
  127.                     END SELECT
  128.                     ArrayArg$(NbArg%) = Arg$
  129.                     Arg$ = ""
  130.                     NbArg% = NbArg% + 1
  131.                 END IF
  132.             END IF
  133.         NEXT i%
  134.     END IF
  135.  
  136. '
  137. ' Default arguments
  138. '
  139. IF ArrayArg$(0) <> "" AND ArrayArg$(0) <> " " AND ArrayArg$(0) <> "-" THEN
  140.     name$ = ArrayArg$(0)
  141. ELSEIF yourname$ = "" THEN
  142.     name$ = "Client" ' default name
  143.     name$ = yourname$
  144.  
  145. IF ArrayArg$(1) <> "" AND ArrayArg$(0) <> " " AND VAL(ArrayArg$(1)) > 1 THEN
  146.     Amount# = VAL(ArrayArg$(1))
  147. ELSEIF amount$ = "" THEN
  148.     Amount# = 10000.00 ' default amount
  149.     Amount# = VAL(amount$)
  150.  
  151. IF ArrayArg$(2) <> "" AND ArrayArg$(2) <> " " AND VAL(ArrayArg$(2)) > 0 THEN
  152.     Rate# = VAL(ArrayArg$(2)) / 100
  153. ELSEIF rate$ = "" THEN
  154.     Rate# = 3.5 / 100 ' default rate
  155.     Rate# = VAL(rate$)
  156.  
  157. IF Rate# > 20 THEN
  158.     Rate# = 20.00 ' default maximum rate
  159.  
  160. IF ArrayArg$(3) <> "" AND ArrayArg$(3) <> " " AND VAL(ArrayArg$(3)) > 0 THEN
  161.     Term# = _ROUND(VAL(ArrayArg$(3)))
  162. ELSEIF term$ = "" THEN
  163.     Term# = 5 ' default term
  164.     Term# = VAL(term$)
  165. IF Term# > 99 THEN
  166.     Term# = 99 ' default maximum term
  167.  
  168. '
  169. ' start the main routines of the program
  170. '
  171.  
  172. '
  173. ' computation formulas of the monthly payment and global cost
  174. '
  175. Payment# = Amount# * Rate# / 12 * ((1 + Rate# / 12) ^ (Term# * 12)) / ((1 + Rate# / 12) ^ (Term# * 12) - 1)
  176. Cost# = (Term# * 12 * Payment#) - Amount#
  177.  
  178. '
  179. ' prepare the first result$ string for output.
  180. '
  181. result$ = CHR$(13) + CHR$(10) + "Dear " + name$ + ", the requested loan goes as follows:" + CHR$(13) + CHR$(10)
  182. Ratio# = 100 / (Amount# / Cost#)
  183.  
  184. '
  185. ' add the next statements
  186. '
  187. result$ = result$ + "Loan" + CHR$(9) + "details" + CHR$(13) + CHR$(10)
  188. result$ = result$ + "Amount" + CHR$(9) + printUsing$(Amount#) + CHR$(13) + CHR$(10)
  189. result$ = result$ + "Rate" + CHR$(9) + printUsing$(Rate# * 100) + "%" + CHR$(13) + CHR$(10)
  190. result$ = result$ + "Term" + CHR$(9) + LTRIM$(STR$(Term#)) + " year(s)" + CHR$(13) + CHR$(10)
  191. result$ = result$ + "Cost" + CHR$(9) + printUsing$(Cost#) + " (" + printUsing$(Ratio#) + "%)" + CHR$(13) + CHR$(10)
  192.  
  193. '
  194. ' add the monthly computations
  195. '
  196. FOR i% = 1 TO Term#
  197.     '
  198.     ' add the next statements
  199.     '
  200.     result$ = result$ + CHR$(13) + CHR$(10) + "YEAR" + STR$(Year%) + CHR$(13) + CHR$(10)
  201.     result$ = result$ + "month" + CHR$(9) + CHR$(9) + "payment" + CHR$(9) + CHR$(9) + "interest" + CHR$(9) + "principal" + CHR$(9) + "balance" + CHR$(13) + CHR$(10)
  202.     '
  203.     ' Call the compute sub routine
  204.     '
  205.     CALL compute(Month%, Amount#, Rate#, Interest#, Payment#, Principal#, lastPayment#, result$)
  206.     IF Month% = 12 THEN
  207.         IF Amount# > 0 THEN
  208.             Month% = 0
  209.             Year% = Year% + 1
  210.         END IF
  211.     END IF
  212. NEXT i%
  213.  
  214. '
  215. ' add the elapsed time to execute the program
  216. '
  217. timeEnd# = TIMER(0.001)
  218. '
  219. ' add the last statements
  220. '
  221. result$ = result$ + "This table was generated in " + printUsing$(((timeEnd# - timeStart#) * 1000)) + " ms. "
  222. result$ = result$ + "(on a 3GHz CPU 1 ms = 3,000,000 cycles)"
  223.  
  224. '
  225. ' option: unrem to create the .txt files
  226. '
  227. 'CALL createFile("loan-calculator.txt", result$)
  228.  
  229. '
  230. ' print the result into the console
  231. '
  232. PRINT result$
  233.  
  234. '
  235. ' wait for an input
  236. '
  237. 'INPUT (a)
  238.  
  239. '
  240. ' end of the program and exit from the console with a 200 return
  241. '
  242. 'SYSTEM 200
  243.  
  244. '
  245. ' sub routine to create the loan-bas.html and loan-bas.txt files
  246. '
  247. SUB createFile (fileName$, result$)
  248.     '
  249.     ' delete the old fileName$ file
  250.     '
  251.     IF _FILEEXISTS(fileName$) THEN
  252.         KILL fileName$
  253.     END IF
  254.     '
  255.     ' create the fileName$ file
  256.     '
  257.     IF existFile%(fileName$) = 0 THEN
  258.         OPEN fileName$ FOR APPEND AS #1
  259.         PRINT #1, result$
  260.         CLOSE #1
  261.     END IF
  262.  
  263. '
  264. ' sub routine to compute and print the monthly elements
  265. '
  266. SUB compute (Month%, Amount#, Rate#, Interest#, Payment#, Principal#, lastPayment#, result$)
  267.     SHARED Month%, _
  268.            Amount#, _
  269.            Rate#, _
  270.            Interest#, _
  271.            Payment#, _
  272.            Principal#, _
  273.            lastPayment#, _
  274.            formatNumber$, _
  275.            result$
  276.  
  277.     DIM monthList$(11)
  278.     monthList$(0) = "January"
  279.     monthList$(1) = "February"
  280.     monthList$(2) = "March"
  281.     monthList$(3) = "April"
  282.     monthList$(4) = "May "
  283.     monthList$(5) = "June"
  284.     monthList$(6) = "July"
  285.     monthList$(7) = "August"
  286.     monthList$(8) = "September"
  287.     monthList$(9) = "October"
  288.     monthList$(10) = "November"
  289.     monthList$(11) = "December"
  290.  
  291.     interest$ = "Interest: "
  292.     payment$ = "Payment: "
  293.     principal$ = "Principal: "
  294.     FOR Month% = 0 TO 11
  295.         Interest# = (Amount# * Rate#) / 12
  296.         IF Amount# > Payment# THEN
  297.             Amount# = (Amount# - Payment#) + Interest#
  298.             Principal# = Payment# - Interest#
  299.         ELSE
  300.             IF lastPayment# > 0 THEN
  301.                 lastPayment# = 0
  302.                 Payment# = Amount#
  303.                 Principal# = Amount# - Interest#
  304.                 Amount# = 0
  305.             ELSE
  306.                 Amount# = 0
  307.                 Payment# = 0
  308.                 Interest# = 0
  309.                 Principal# = 0
  310.             END IF
  311.         END IF
  312.         '
  313.         ' add the next statements
  314.         '
  315.         IF monthList$(Month%) = "February" OR monthList$(Month%) = "September" OR monthList$(Month%) = "November" OR monthList$(Month%) = "December" THEN
  316.             result$ = result$ + monthList$(Month%) + CHR$(9)
  317.         ELSE
  318.             result$ = result$ + monthList$(Month%) + CHR$(9) + CHR$(9)
  319.         END IF
  320.         IF LEN(printUsing$(Payment#)) > 7 THEN
  321.             result$ = result$ + printUsing$(Payment#) + CHR$(9)
  322.         ELSE
  323.             result$ = result$ + printUsing$(Payment#) + CHR$(9) + CHR$(9)
  324.         END IF
  325.         IF LEN(printUsing$(Interest#)) > 7 THEN
  326.             result$ = result$ + printUsing$(Interest#) + CHR$(9)
  327.         ELSE
  328.             result$ = result$ + printUsing$(Interest#) + CHR$(9) + CHR$(9)
  329.         END IF
  330.         IF LEN(printUsing$(Principal#)) > 7 THEN
  331.             result$ = result$ + printUsing$(Principal#) + CHR$(9)
  332.         ELSE
  333.             result$ = result$ + printUsing$(Principal#) + CHR$(9) + CHR$(9)
  334.         END IF
  335.         result$ = result$ + printUsing$(Amount#) + CHR$(13) + CHR$(10)
  336.     NEXT
  337.     result$ = result$ + CHR$(13) + CHR$(10)
  338.  
  339. '
  340. ' function to check if an argument is a valid string to be processed by this loan.bas program
  341. '
  342. FUNCTION isValidArg% (arg$, type$)
  343.     isValidArg% = 0
  344.     isStr% = 0
  345.     type$ = LCASE$(type$)
  346.     SELECT CASE (type$)
  347.         CASE "str"
  348.             t$ = LCASE$(arg$)
  349.             base$ = "abcdefghijklmnopqrstuvwxyz-"
  350.         CASE "flt"
  351.             base$ = ".1234567890"
  352.             IF LEN(arg$) = 1 AND arg$ = "." THEN
  353.                 isValidArg% = 0
  354.                 EXIT FUNCTION
  355.             END IF
  356.         CASE "int"
  357.             base$ = "1234567890"
  358.         CASE ELSE
  359.             arg$ = ""
  360.             type$ = ""
  361.             isValidArg% = 0
  362.             EXIT FUNCTION
  363.     END SELECT
  364.     isValidArg% = 0
  365.     isStr% = 0
  366.     t$ = LCASE$(arg$)
  367.     FOR i = 1 TO LEN(arg$)
  368.         argChar$ = MID$(t$, i, 1)
  369.         FOR j = 1 TO LEN(base$)
  370.             baseChar$ = MID$(base$, j, 1)
  371.             IF baseChar$ = argChar$ THEN
  372.                 isValidArg% = isValidArg% + 1
  373.                 isStr% = 1
  374.                 EXIT FOR
  375.             ELSE
  376.                 isStr% = 0
  377.                 IF (j = LEN(base$)) THEN
  378.                     isStr% = 0
  379.                     EXIT FOR
  380.                 END IF
  381.             END IF
  382.         NEXT j
  383.         IF isStr% = 0 THEN
  384.             isValidArg% = 0
  385.             EXIT FOR
  386.         END IF
  387.     NEXT i
  388.  
  389. '
  390. '
  391. '
  392. FUNCTION existFile% (fileName$)
  393.     f% = FREEFILE
  394.     OPEN fileName$ FOR APPEND AS #f%
  395.     IF LOF(f%) THEN
  396.         existFile% = 1
  397.         CLOSE #f%
  398.     ELSE
  399.         existFile% = 0
  400.         CLOSE #f%
  401.         KILL fileName$
  402.     END IF
  403.  
  404. '
  405. ' function to format the integer part of a float and round its decimal part
  406. '
  407. FUNCTION printUsing$ (nb#)
  408.     printUsing$ = intPart$(nb#) + decPart$(nb#)
  409.  
  410. '
  411. ' function to format and round the decimal part of a float
  412. '
  413. FUNCTION decPart$ (nb#)
  414.     dot$ = "."
  415.     dotPos% = INSTR(LTRIM$(STR$(nb#)), dot$)
  416.     IF dotPos% = 0 THEN
  417.         partdec$ = ".00"
  418.     ELSE
  419.         partdec$ = MID$(LTRIM$(STR$(nb#)), dotPos%)
  420.         strlen% = LEN(partdec$)
  421.     END IF
  422.     IF strlen% = 1 THEN
  423.         partdec$ = ".00"
  424.     ELSE
  425.         SELECT CASE strlen%
  426.             CASE 2
  427.                 partdec$ = partdec$ + "0"
  428.             CASE IS > 3
  429.                 IF VAL(MID$(partdec$, 4, 1)) >= 5 THEN
  430.                     MID$(partdec$, 3, 1) = LTRIM$(STR$(VAL(MID$(partdec$, 3, 1)) + 1))
  431.                 END IF
  432.                 partdec$ = LEFT$(partdec$, 3)
  433.         END SELECT
  434.     END IF
  435.     decPart$ = partdec$
  436.  
  437. '
  438. ' function to format the integer part of a float
  439. '
  440. FUNCTION intPart$ (nb#)
  441.     i$ = LTRIM$(RTRIM$(STR$(FIX(nb#))))
  442.     IF nb# < 0 THEN
  443.         i$ = MID$(i$, 2)
  444.     END IF
  445.     lenI = LEN(i$)
  446.     IF lenI > 3 THEN
  447.         m3 = lenI MOD 3
  448.         IF m3 <> 0 THEN
  449.             i$ = LEFT$(i$, m3) + "," + MID$(i$, m3 + 1)
  450.         END IF
  451.         idx = m3 + 4 + (m3 = 0)
  452.         WHILE idx < LEN(i$)
  453.             i$ = LEFT$(i$, idx) + "," + MID$(i$, idx + 1)
  454.             idx = idx + 4
  455.         WEND
  456.     ELSEIF lenI = 0 THEN
  457.         i$ = "0"
  458.     END IF
  459.     IF nb# < 0 AND lenI > 0 THEN
  460.         i$ = "-" + i$
  461.     END IF
  462.     intPart$ = i$
  463.  

Any idea what's going wrong?

Futher, how to set the size of the terminal window with length 120 characters and 40 lines?

Cheers.
Fifi
It's better to look like an idiot for a short time while asking something obvious to an expert than pretending to be smart all your life. (C) Me.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: QB64 v1.2 rev 20180202/85 on Linux and OS/X can't execute any stuff!
« Reply #5 on: September 08, 2018, 07:36:39 am »
I ran it on my Linux machine. Executed but just sat there with the program loaded into the IDE.

Ran it from a Terminal. Again the IDE sat there. BUT... the Terminal asked for my name; the amount of $; Interest rate and length of loan...

I hope this has helped...

J
Logic is the beginning of wisdom.

FellippeHeitor

  • Guest
Re: QB64 v1.2 rev 20180202/85 on Linux and OS/X can't execute any stuff!
« Reply #6 on: September 08, 2018, 07:50:00 am »
The build numbers haven't been updated in the dev builds. Is this the dev build? What does it say in the about box after "From git"?

Offline Fifi

  • Forum Regular
  • Posts: 181
    • View Profile
    • My small QB64 contribution
Re: QB64 v1.2 on Linux and OS/X can't execute any stuff!
« Reply #7 on: September 08, 2018, 11:39:42 am »
Hi Fellippe,

The build numbers haven't been updated in the dev builds. Is this the dev build? What does it say in the about box after "From git"?

No, this was not with the dev built but just the last stable for OS/X.

So I'd just downloaded and installed the dev built for OS/X (qb64_2018-08-17-21-19-37_6cb81e1-development_osx.tar.gz) and there is a new behavior: when using the F5 key, now QB64 compiles the loan.bas program, creates the loan executable and doesn't stay frozen anymore (I get the OK message at the end of the compilation) but still doesn't launch the executable as it's supposed to do.

Further, the "loan_start.command" script created after the compilation just opens and closes the terminal session without the excutable been started.

However, the loan executable created by QB64 runs fine when started with a double left mouse click.

Note: Just saw that the "Start Detached" option isn't available anymore from the Run menu. May I ask why?

Now, just donwloaded the dev built for Linux (qb64_2018-08-17-21-19-37_6cb81e1-development_osx.tar on a fresh Ubuntu 16.04.5 64-bit install) and it's even worst. Once QB64 is succesfully created (using the basic setup_lnx.sh script), it doesn't even launch itself !

Cheers.
Fifi
« Last Edit: September 08, 2018, 12:53:04 pm by Fifi »
It's better to look like an idiot for a short time while asking something obvious to an expert than pretending to be smart all your life. (C) Me.

Offline Fifi

  • Forum Regular
  • Posts: 181
    • View Profile
    • My small QB64 contribution
Re: QB64 v1.2 rev 20180202/85 on Linux and OS/X can't execute any stuff!
« Reply #8 on: September 08, 2018, 01:11:26 pm »
Hi johnno56,

I ran it on my Linux machine. Executed but just sat there with the program loaded into the IDE.

Ran it from a Terminal. Again the IDE sat there. BUT... the Terminal asked for my name; the amount of $; Interest rate and length of loan...

I hope this has helped...

J

This is the classic use of this program as described in the top of the source file.

If you don't pass one of the four parameters as arguments in the command line, then the program asks for a name (that can be empty), an amount, a rate and the number of year(s) of the loan.

If you don't respond to one of these four questions when only sending the Enter key, the program computes a default loan sample for the name "Client" of an amount of 10,000.00 with a rate of 3.5 % and a duration of 5 years and prints the loan table.

However, you can ignore one parameter that will be replaced by its defaut value.

Note: The maximum rate is 20% and the maximum number of years is 99.

Hope this helps.

Cheers.
Fifi
« Last Edit: September 08, 2018, 06:26:58 pm by Fifi »
It's better to look like an idiot for a short time while asking something obvious to an expert than pretending to be smart all your life. (C) Me.

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: QB64 v1.2 on Linux and OS/X has big problems!
« Reply #9 on: September 08, 2018, 02:59:34 pm »
1.2 runs first go Linux mint 19 / cinnamon.. x64 (only had sound issue but is great now) no complaints here.. great job and keep it up. only one thing i would like changed. the char.h to support more than 16color. rgb32 gives me plenty of colors but assigned to 16color
MackyWhite

Offline Fifi

  • Forum Regular
  • Posts: 181
    • View Profile
    • My small QB64 contribution
Re: QB64 v1.2 on Linux and OS/X has big problems!
« Reply #10 on: September 08, 2018, 07:21:39 pm »
Hi PMACKAY,

1.2 runs first go Linux mint 19 / cinnamon.. x64 (only had sound issue but is great now) no complaints here.. great job and keep it up. only one thing i would like changed. the char.h to support more than 16color. rgb32 gives me plenty of colors but assigned to 16color

I've the last Mint 19 v2 - 64-bit installed on VM machines (both VMware and VirtualBox and both on Linux, OS/X and Windows 10) as well as all these OSes on a baremetal PC.

Please could you say me what's the exact QB64 release you're using, since none of my tests are doing right.

Could you also try on your computer the "loan.bas" sample program I proposed above but that you can get again below since this could help all of us (my code could be damned wrong) a lot:

Code: QB64: [Select]
  1. '
  2. ' Program name: loan.bas
  3. '
  4. ' Program that computes for a client the montly payments, interest, principal
  5. ' and balance for a certain amount with a certain fixed interest rate and for
  6. ' a certain number of years and prints the amortization table.
  7. '
  8. ' The executable can be launched with four parameters : name of the client,
  9. ' amount, interest and term.
  10. '
  11. ' The parameters must be entered using a command line arguments in a string of
  12. ' the form: "&name=abcd&amount=xxx&rate=rr.rr&term=zz"
  13. ' where name is the client name (a string without space)
  14. ' xxx is the amount (a long)
  15. ' rr.rr is the rate (a float) - maximum 20
  16. ' and zz is the number of years (an int) - maximun 99
  17. ' e.g. loan &name=John&amount=12000&rate=2.57&term=5
  18. '
  19. ' NOTE:
  20. ' Space(s) can be included between arguments but not between the argument
  21. ' and the sign "=" nor between the sign "=" and the argument value such as:
  22. ' e.g. loan & name=John & amount=12000 & rate=2.57 & term=5
  23. '
  24. ' NOTE:
  25. ' Only the dot sign "." is allowed in float to separate the integer part from
  26. ' its decimal part (no comma sign "," anywhere in a float).
  27. '
  28. ' NOTE:
  29. ' If no parameters are set, the program ask you the values.
  30. ' If there is no value entered (just hit the Enter key), the program computes
  31. ' the default values (Client, 10000.00, 3.5% and 5 years).
  32. '
  33.  
  34.  
  35. '
  36. ' title of the windows when used in a console
  37. '
  38. _TITLE "Loan calculator"
  39.  
  40. '
  41. ' miscelaneous variables initialisation
  42. '
  43. Arg$ = ""
  44. NbArg% = 0
  45. DIM ArrayArg$(4)
  46. lastPayment# = 1.00
  47. Year% = 1
  48.  
  49. '
  50. ' Get the Arguments of the command line
  51. '
  52. LineArg$ = COMMAND$
  53.  
  54. '
  55. ' force parameters if the argument line is empty.
  56. '
  57. IF LEN(LineArg$) = 0 THEN
  58.     '    LineArg$ = "& name=- & amount=10000.00 & rate=3.5 & term=1"
  59.     PRINT "Please enter your name (any name, may be empty but no space):               ";
  60.     INPUT yourname$
  61.     PRINT "Enter the amount to borrow (long, decimal characters) e.g. 1000000:         ";
  62.     INPUT amount$
  63.     PRINT "Enter the % rate of the loan (float, decimal characters with .) e.g. 1.65 : ";
  64.     INPUT rate$
  65.     PRINT "Enter the number of year of the loan (integer, decinal characters) e.g. 12: ";
  66.     INPUT term$
  67.     LineArg$ = "& name=" + yourname$ + " & amount=" + amount$ + " & rate=" + rate$ + " & term=" + term$
  68.  
  69. '
  70. ' store the execution start time
  71. '
  72. timeStart# = TIMER(0.001)
  73.  
  74. '
  75. ' check if the expected arguments names and argument values are the right ones and if so get their relevant values
  76. ' if one argument name or argument type isn't what is expected, use the default argument values.
  77. '
  78. WHILE NbArg% < 4
  79.     IF LEN(LineArg$) > 0 THEN
  80.         FOR i% = 1 TO LEN(LineArg$ + " ")
  81.             GetChar$ = MID$(LineArg$, i%, 1)
  82.             IF (GetChar$ <> "" AND GetChar$ <> " " AND GetChar$ <> "&") THEN
  83.                 Arg$ = Arg$ + GetChar$
  84.             ELSE
  85.                 IF Arg$ <> "" THEN
  86.                     SELECT CASE NbArg%
  87.                         CASE 0
  88.                             IF LEFT$(Arg$, 5) <> "name=" THEN
  89.                                 '    PRINT "problem with the " + CHR$(34) + "first argument naming that should be name= but is: " + CHR$(34) + LEFT$(Arg$, 5) + CHR$(34)
  90.                                 EXIT WHILE
  91.                             ELSEIF isValidArg%(MID$(Arg$, 6), "str") = 0 THEN
  92.                                 '    PRINT "problem with the content of name= that is: " + CHR$(34) + MID$(Arg$, 6) + CHR$(34) + " and isn't a valid string!"
  93.                                 EXIT WHILE
  94.                             ELSE
  95.                                 Arg$ = MID$(Arg$, 6)
  96.                             END IF
  97.                         CASE 1
  98.                             IF LEFT$(Arg$, 7) <> "amount=" THEN
  99.                                 '    PRINT "problem with the " + CHR$(34) + "second argument naming that should be amount= but is: " + CHR$(34) + LEFT$(Arg$, 7) + CHR$(34)
  100.                                 EXIT WHILE
  101.                             ELSEIF isValidArg%(MID$(Arg$, 8), "flt") = 0 THEN
  102.                                 '    PRINT "problem with the content of amount= that is: " + CHR$(34) + MID$(Arg$, 8) + CHR$(34) + " and isn't a valid float!"
  103.                                 EXIT WHILE
  104.                             ELSE
  105.                                 Arg$ = MID$(Arg$, 8)
  106.                             END IF
  107.                         CASE 2
  108.                             IF LEFT$(Arg$, 5) <> "rate=" THEN
  109.                                 '    PRINT "problem with the " + CHR$(34) + "third argument naming that should be rate= but is: " + CHR$(34) + LEFT$(Arg$, 5) + CHR$(34)
  110.                                 EXIT WHILE
  111.                             ELSEIF isValidArg%(MID$(Arg$, 6), "flt") = 0 THEN
  112.                                 '    PRINT "problem with the content of rate= that is: " + CHR$(34) + MID$(Arg$, 6) + CHR$(34) + " and isn't a valid float!"
  113.                                 EXIT WHILE
  114.                             ELSE
  115.                                 Arg$ = MID$(Arg$, 6)
  116.                             END IF
  117.                         CASE 3
  118.                             IF LEFT$(Arg$, 5) <> "term=" THEN
  119.                                 '    PRINT "problem with the " + CHR$(34) + "last argument naming that should be term= but is: " + CHR$(34) + LEFT$(Arg$, 5) + CHR$(34)
  120.                                 EXIT WHILE
  121.                             ELSEIF isValidArg%(MID$(Arg$, 6), "int") = 0 THEN
  122.                                 '    PRINT "problem with the content of rate= that is: " + CHR$(34) + MID$(Arg$, 6) + CHR$(34) + " and isn't a valid integer!"
  123.                                 EXIT WHILE
  124.                             ELSE
  125.                                 Arg$ = MID$(Arg$, 6)
  126.                             END IF
  127.                     END SELECT
  128.                     ArrayArg$(NbArg%) = Arg$
  129.                     Arg$ = ""
  130.                     NbArg% = NbArg% + 1
  131.                 END IF
  132.             END IF
  133.         NEXT i%
  134.     END IF
  135.  
  136. '
  137. ' Default arguments
  138. '
  139. IF ArrayArg$(0) <> "" AND ArrayArg$(0) <> " " AND ArrayArg$(0) <> "-" THEN
  140.     name$ = ArrayArg$(0)
  141. ELSEIF yourname$ = "" THEN
  142.     name$ = "Client" ' default name
  143.     name$ = yourname$
  144.  
  145. IF ArrayArg$(1) <> "" AND ArrayArg$(0) <> " " AND VAL(ArrayArg$(1)) > 1 THEN
  146.     Amount# = VAL(ArrayArg$(1))
  147. ELSEIF amount$ = "" THEN
  148.     Amount# = 10000.00 ' default amount
  149.     Amount# = VAL(amount$)
  150.  
  151. IF ArrayArg$(2) <> "" AND ArrayArg$(2) <> " " AND VAL(ArrayArg$(2)) > 0 THEN
  152.     Rate# = VAL(ArrayArg$(2)) / 100
  153. ELSEIF rate$ = "" THEN
  154.     Rate# = 3.5 / 100 ' default rate
  155.     Rate# = VAL(rate$)
  156.  
  157. IF Rate# > 20 THEN
  158.     Rate# = 20.00 ' default maximum rate
  159.  
  160. IF ArrayArg$(3) <> "" AND ArrayArg$(3) <> " " AND VAL(ArrayArg$(3)) > 0 THEN
  161.     Term# = _ROUND(VAL(ArrayArg$(3)))
  162. ELSEIF term$ = "" THEN
  163.     Term# = 5 ' default term
  164.     Term# = VAL(term$)
  165. IF Term# > 99 THEN
  166.     Term# = 99 ' default maximum term
  167.  
  168. '
  169. ' start the main routines of the program
  170. '
  171.  
  172. '
  173. ' computation formulas of the monthly payment and global cost
  174. '
  175. Payment# = Amount# * Rate# / 12 * ((1 + Rate# / 12) ^ (Term# * 12)) / ((1 + Rate# / 12) ^ (Term# * 12) - 1)
  176. Cost# = (Term# * 12 * Payment#) - Amount#
  177.  
  178. '
  179. ' prepare the first result$ string for output.
  180. '
  181. result$ = CHR$(13) + CHR$(10) + "Dear " + name$ + ", the requested loan goes as follows:" + CHR$(13) + CHR$(10)
  182. Ratio# = 100 / (Amount# / Cost#)
  183.  
  184. '
  185. ' add the next statements
  186. '
  187. result$ = result$ + "Loan" + CHR$(9) + "details" + CHR$(13) + CHR$(10)
  188. result$ = result$ + "Amount" + CHR$(9) + printUsing$(Amount#) + CHR$(13) + CHR$(10)
  189. result$ = result$ + "Rate" + CHR$(9) + printUsing$(Rate# * 100) + "%" + CHR$(13) + CHR$(10)
  190. result$ = result$ + "Term" + CHR$(9) + LTRIM$(STR$(Term#)) + " year(s)" + CHR$(13) + CHR$(10)
  191. result$ = result$ + "Cost" + CHR$(9) + printUsing$(Cost#) + " (" + printUsing$(Ratio#) + "%)" + CHR$(13) + CHR$(10)
  192.  
  193. '
  194. ' add the monthly computations
  195. '
  196. FOR i% = 1 TO Term#
  197.     '
  198.     ' add the next statements
  199.     '
  200.     result$ = result$ + CHR$(13) + CHR$(10) + "YEAR" + STR$(Year%) + CHR$(13) + CHR$(10)
  201.     result$ = result$ + "month" + CHR$(9) + CHR$(9) + "payment" + CHR$(9) + CHR$(9) + "interest" + CHR$(9) + "principal" + CHR$(9) + "balance" + CHR$(13) + CHR$(10)
  202.     '
  203.     ' Call the compute sub routine
  204.     '
  205.     CALL compute(Month%, Amount#, Rate#, Interest#, Payment#, Principal#, lastPayment#, result$)
  206.     IF Month% = 12 THEN
  207.         IF Amount# > 0 THEN
  208.             Month% = 0
  209.             Year% = Year% + 1
  210.         END IF
  211.     END IF
  212. NEXT i%
  213.  
  214. '
  215. ' add the elapsed time to execute the program
  216. '
  217. timeEnd# = TIMER(0.001)
  218. '
  219. ' add the last statements
  220. '
  221. result$ = result$ + "This table was generated in " + printUsing$(((timeEnd# - timeStart#) * 1000)) + " ms. "
  222. result$ = result$ + "(on a 3GHz CPU 1 ms = 3,000,000 cycles)"
  223.  
  224. '
  225. ' option: unrem to create the .txt files
  226. '
  227. 'CALL createFile("loan-calculator.txt", result$)
  228.  
  229. '
  230. ' print the result into the console
  231. '
  232. PRINT result$
  233.  
  234. '
  235. ' wait for an input
  236. '
  237. 'INPUT (a)
  238.  
  239. '
  240. ' end of the program and exit from the console with a 200 return
  241. '
  242. 'SYSTEM 200
  243.  
  244. '
  245. ' sub routine to create the loan-bas.html and loan-bas.txt files
  246. '
  247. SUB createFile (fileName$, result$)
  248.     '
  249.     ' delete the old fileName$ file
  250.     '
  251.     IF _FILEEXISTS(fileName$) THEN
  252.         KILL fileName$
  253.     END IF
  254.     '
  255.     ' create the fileName$ file
  256.     '
  257.     IF existFile%(fileName$) = 0 THEN
  258.         OPEN fileName$ FOR APPEND AS #1
  259.         PRINT #1, result$
  260.         CLOSE #1
  261.     END IF
  262.  
  263. '
  264. ' sub routine to compute and print the monthly elements
  265. '
  266. SUB compute (Month%, Amount#, Rate#, Interest#, Payment#, Principal#, lastPayment#, result$)
  267.     SHARED Month%, _
  268.            Amount#, _
  269.            Rate#, _
  270.            Interest#, _
  271.            Payment#, _
  272.            Principal#, _
  273.            lastPayment#, _
  274.            formatNumber$, _
  275.            result$
  276.  
  277.     DIM monthList$(11)
  278.     monthList$(0) = "January"
  279.     monthList$(1) = "February"
  280.     monthList$(2) = "March"
  281.     monthList$(3) = "April"
  282.     monthList$(4) = "May "
  283.     monthList$(5) = "June"
  284.     monthList$(6) = "July"
  285.     monthList$(7) = "August"
  286.     monthList$(8) = "September"
  287.     monthList$(9) = "October"
  288.     monthList$(10) = "November"
  289.     monthList$(11) = "December"
  290.  
  291.     interest$ = "Interest: "
  292.     payment$ = "Payment: "
  293.     principal$ = "Principal: "
  294.     FOR Month% = 0 TO 11
  295.         Interest# = (Amount# * Rate#) / 12
  296.         IF Amount# > Payment# THEN
  297.             Amount# = (Amount# - Payment#) + Interest#
  298.             Principal# = Payment# - Interest#
  299.         ELSE
  300.             IF lastPayment# > 0 THEN
  301.                 lastPayment# = 0
  302.                 Payment# = Amount#
  303.                 Principal# = Amount# - Interest#
  304.                 Amount# = 0
  305.             ELSE
  306.                 Amount# = 0
  307.                 Payment# = 0
  308.                 Interest# = 0
  309.                 Principal# = 0
  310.             END IF
  311.         END IF
  312.         '
  313.         ' add the next statements
  314.         '
  315.         IF monthList$(Month%) = "February" OR monthList$(Month%) = "September" OR monthList$(Month%) = "November" OR monthList$(Month%) = "December" THEN
  316.             result$ = result$ + monthList$(Month%) + CHR$(9)
  317.         ELSE
  318.             result$ = result$ + monthList$(Month%) + CHR$(9) + CHR$(9)
  319.         END IF
  320.         IF LEN(printUsing$(Payment#)) > 7 THEN
  321.             result$ = result$ + printUsing$(Payment#) + CHR$(9)
  322.         ELSE
  323.             result$ = result$ + printUsing$(Payment#) + CHR$(9) + CHR$(9)
  324.         END IF
  325.         IF LEN(printUsing$(Interest#)) > 7 THEN
  326.             result$ = result$ + printUsing$(Interest#) + CHR$(9)
  327.         ELSE
  328.             result$ = result$ + printUsing$(Interest#) + CHR$(9) + CHR$(9)
  329.         END IF
  330.         IF LEN(printUsing$(Principal#)) > 7 THEN
  331.             result$ = result$ + printUsing$(Principal#) + CHR$(9)
  332.         ELSE
  333.             result$ = result$ + printUsing$(Principal#) + CHR$(9) + CHR$(9)
  334.         END IF
  335.         result$ = result$ + printUsing$(Amount#) + CHR$(13) + CHR$(10)
  336.     NEXT
  337.     result$ = result$ + CHR$(13) + CHR$(10)
  338.  
  339. '
  340. ' function to check if an argument is a valid string to be processed by this loan.bas program
  341. '
  342. FUNCTION isValidArg% (arg$, type$)
  343.     isValidArg% = 0
  344.     isStr% = 0
  345.     type$ = LCASE$(type$)
  346.     SELECT CASE (type$)
  347.         CASE "str"
  348.             t$ = LCASE$(arg$)
  349.             base$ = "abcdefghijklmnopqrstuvwxyz-"
  350.         CASE "flt"
  351.             base$ = ".1234567890"
  352.             IF LEN(arg$) = 1 AND arg$ = "." THEN
  353.                 isValidArg% = 0
  354.                 EXIT FUNCTION
  355.             END IF
  356.         CASE "int"
  357.             base$ = "1234567890"
  358.         CASE ELSE
  359.             arg$ = ""
  360.             type$ = ""
  361.             isValidArg% = 0
  362.             EXIT FUNCTION
  363.     END SELECT
  364.     isValidArg% = 0
  365.     isStr% = 0
  366.     t$ = LCASE$(arg$)
  367.     FOR i = 1 TO LEN(arg$)
  368.         argChar$ = MID$(t$, i, 1)
  369.         FOR j = 1 TO LEN(base$)
  370.             baseChar$ = MID$(base$, j, 1)
  371.             IF baseChar$ = argChar$ THEN
  372.                 isValidArg% = isValidArg% + 1
  373.                 isStr% = 1
  374.                 EXIT FOR
  375.             ELSE
  376.                 isStr% = 0
  377.                 IF (j = LEN(base$)) THEN
  378.                     isStr% = 0
  379.                     EXIT FOR
  380.                 END IF
  381.             END IF
  382.         NEXT j
  383.         IF isStr% = 0 THEN
  384.             isValidArg% = 0
  385.             EXIT FOR
  386.         END IF
  387.     NEXT i
  388.  
  389. '
  390. '
  391. '
  392. FUNCTION existFile% (fileName$)
  393.     f% = FREEFILE
  394.     OPEN fileName$ FOR APPEND AS #f%
  395.     IF LOF(f%) THEN
  396.         existFile% = 1
  397.         CLOSE #f%
  398.     ELSE
  399.         existFile% = 0
  400.         CLOSE #f%
  401.         KILL fileName$
  402.     END IF
  403.  
  404. '
  405. ' function to format the integer part of a float and round its decimal part
  406. '
  407. FUNCTION printUsing$ (nb#)
  408.     printUsing$ = intPart$(nb#) + decPart$(nb#)
  409.  
  410. '
  411. ' function to format and round the decimal part of a float
  412. '
  413. FUNCTION decPart$ (nb#)
  414.     dot$ = "."
  415.     dotPos% = INSTR(LTRIM$(STR$(nb#)), dot$)
  416.     IF dotPos% = 0 THEN
  417.         partdec$ = ".00"
  418.     ELSE
  419.         partdec$ = MID$(LTRIM$(STR$(nb#)), dotPos%)
  420.         strlen% = LEN(partdec$)
  421.     END IF
  422.     IF strlen% = 1 THEN
  423.         partdec$ = ".00"
  424.     ELSE
  425.         SELECT CASE strlen%
  426.             CASE 2
  427.                 partdec$ = partdec$ + "0"
  428.             CASE IS > 3
  429.                 IF VAL(MID$(partdec$, 4, 1)) >= 5 THEN
  430.                     MID$(partdec$, 3, 1) = LTRIM$(STR$(VAL(MID$(partdec$, 3, 1)) + 1))
  431.                 END IF
  432.                 partdec$ = LEFT$(partdec$, 3)
  433.         END SELECT
  434.     END IF
  435.     decPart$ = partdec$
  436.  
  437. '
  438. ' function to format the integer part of a float
  439. '
  440. FUNCTION intPart$ (nb#)
  441.     i$ = LTRIM$(RTRIM$(STR$(FIX(nb#))))
  442.     IF nb# < 0 THEN
  443.         i$ = MID$(i$, 2)
  444.     END IF
  445.     lenI = LEN(i$)
  446.     IF lenI > 3 THEN
  447.         m3 = lenI MOD 3
  448.         IF m3 <> 0 THEN
  449.             i$ = LEFT$(i$, m3) + "," + MID$(i$, m3 + 1)
  450.         END IF
  451.         idx = m3 + 4 + (m3 = 0)
  452.         WHILE idx < LEN(i$)
  453.             i$ = LEFT$(i$, idx) + "," + MID$(i$, idx + 1)
  454.             idx = idx + 4
  455.         WEND
  456.     ELSEIF lenI = 0 THEN
  457.         i$ = "0"
  458.     END IF
  459.     IF nb# < 0 AND lenI > 0 THEN
  460.         i$ = "-" + i$
  461.     END IF
  462.     intPart$ = i$
  463.  

TIA for your time, help and concern?

Cheers.
Fifi
It's better to look like an idiot for a short time while asking something obvious to an expert than pretending to be smart all your life. (C) Me.

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: QB64 v1.2 on Linux and OS/X has big problems!
« Reply #11 on: September 10, 2018, 06:41:17 pm »
QB64 VERSION 1.2 REVISION 20180228/86

there was a sound issue in qb64 when compiled on x64... but this is easy fix. will even send you a copy of my patched file if you are using x64

The latest version of mint 19.2 is installed on my system. i do not use anything but mint... no windows or mac. no virtual box.... just linux since 2003.

i have attached my qb64 file for download. hope this helps

I had removed the programs folder from the zip and andriod folder to get this to fit.. if you want the sample files you will have to copy them from the other zip you download from qb64.org

(I had installed timidity along with sound fonts) - this is needed for some music files to work such as midi
MackyWhite