Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AtomicSlaughter

Pages: [1]
1
InForm-based programs / Message Encoder
« on: October 05, 2021, 08:16:10 pm »
Ok so this is a rather simple program that uses a shifting shift cypher to encode a message.

You pick your own numeric key of any length, type your message and the program will use a shift cypher on each letter of your message, cycling through your key for each letter of the message.

check it out.

2
from what ive noticed the mouse pointer is visable as soon as you move it out of the app window and dissapears again when you move it back in

3
Programs / Re: Epoch/UNIX Time Function
« on: April 27, 2021, 11:15:47 am »
i dont even know why that -1 is in there thats a bit odd i dont remember putting that -1 in there

4
How about using _MOUSEHIDE and _MOUSESHOW and just hide it when you need to.

5
Programs / Epoch/UNIX Time Function
« on: April 27, 2021, 08:43:18 am »
I needed a function to generate epoch time from within qb64.
the following code/file, is a function that generate epoch time in seconds.

The usage for the code is:
Code: QB64: [Select]
  1. x = epoch

Code: QB64: [Select]
  1. FUNCTION epoch&&
  2.     DIM mc(12)
  3.     '--get days passed since 1-1-1970--
  4.     year_day_count = INT((VAL(RIGHT$(DATE$, 4)) - 1970) * 365)
  5.     leap_year_days = INT((VAL(RIGHT$(DATE$, 4)) - 1970) / 4)
  6.     total_past_days = year_day_count + leap_year_days
  7.     total_past_sec = total_past_days * 86400
  8.  
  9.     '--get days so far in month--------
  10.     mc(1) = 31
  11.     mc(2) = 28
  12.     mc(3) = 31
  13.     mc(4) = 30
  14.     mc(5) = 31
  15.     mc(6) = 30
  16.     mc(7) = 31
  17.     mc(8) = 31
  18.     mc(9) = 30
  19.     mc(10) = 31
  20.     mc(11) = 30
  21.     mc(12) = 31
  22.     '--get days past to month start----
  23.     FOR i = 1 TO 12
  24.         x = x + 1
  25.         IF x >= VAL(LEFT$(DATE$, 2)) THEN EXIT FOR
  26.         day_count = day_count + mc(x)
  27.     NEXT
  28.     current_month_sec = day_count * 86400
  29.  
  30.     month_days = VAL(MID$(DATE$, 4, 2))
  31.     month_time_sec = month_days * 86400
  32.  
  33.     '--get current seconds in day------
  34.     hours = (VAL(LEFT$(TIME$, 2)) - 1) * 3600
  35.     mins = VAL(MID$(TIME$, 4, 2)) * 60
  36.     sec = VAL(RIGHT$(TIME$, 2))
  37.     day_time_sec = hours + mins + sec
  38.  
  39.     epoch = total_past_sec + month_time_sec + current_month_sec + day_time_sec

Hope someone finds this useful.

6
QB64 Discussion / mySQL & QB64
« on: April 18, 2021, 03:45:45 pm »
OK, so i have been experimenting with mySQL and QB64 under Linux (Ubuntu 20.04) and here is what i have discovered.

Using Pipecom by SpriggsySpriggs, I have been able to impliment a rudimentary mySQL interface

Here is the code for creating and adding to the database
Code: QB64: [Select]
  1. Shell "echo 'CREATE DATABASE epos' | mysql -uroot"
  2. Shell "echo 'CREATE TABLE plu (item CHAR(20), price CHAR(20), grp CHAR(20), tax CHAR(20), kit CHAR(20))' | mysql -uroot epos"
  3.  
  4.     Input "item>   ", item$
  5.     Input "price>  ", price$
  6.     Input "group>  ", grp$
  7.     Input "tax>    ", tax$
  8.     Input "kitchen ", kit$
  9.     Print ""
  10.     Shell "echo " + Chr$(34) + "INSERT INTO plu (item, price, grp, tax, kit) VALUES ('" + item$ + "', " + price$ + ", " + grp$ + ", " + tax$ + ", " + kit$ + ")" + Chr$(34) + " | mysql -uroot epos"
  11.  
  12.  
  13. '$INCLUDE:'pipecom.bas'

And here is the code for reading the data back
Code: QB64: [Select]
  1.     price_search
  2.  
  3. Sub price_search
  4.     Cls
  5.     Print "price search"
  6.     Input "Enter item Name >", q$
  7.     query$ = pipecom_lite("echo " + Chr$(34) + "SELECT price FROM plu WHERE item = '" + q$ + "'" + Chr$(34) + " | mysql -uroot epos -s")
  8.     Print "the price of " + q$ + " is " + query$
  9.     q$ = ""
  10.     query$ = ""
  11.     _Delay 2
  12.  
  13. '$INCLUDE:'pipecom.bas'

Not sure if this is useful to anyone but here it is anyway

7
QB64 Discussion / Re: QB64 and FreeBasic
« on: February 25, 2021, 02:18:36 pm »
I wouldn't really bother when you can use Geany as a pretty capable IDE for FreeBASIC, along with a dozen other languages.

8
QB64 Discussion / Re: Adding a Decimal Value
« on: February 25, 2021, 02:11:24 pm »
You can try this if you need to print a decimal place to screen, but you will have to convert your number into a string first using
Code: QB64: [Select]
  1. a$ = STR$(variable)
first.


Code: QB64: [Select]
  1. INPUT "enter a number", a$
  2. Numeric_Decimal (a$)
  3.  
  4. SUB Numeric_Decimal (a$)
  5.  
  6.     l = LEN(a$)
  7.     penny$ = RIGHT$(a$, 2)
  8.     IF LEN(LTRIM$(penny$)) = 1 THEN
  9.         pound$ = "0"
  10.         penny$ = "0" + LTRIM$(penny$)
  11.         conv$ = pound$ + "." + penny$
  12.         a$ = conv$
  13.     ELSE
  14.         pound$ = LEFT$(a$, (l - 2))
  15.         conv$ = pound$ + "." + penny$
  16.         a$ = conv$
  17.     END IF
  18.     IF LEN(conv$) = 3 THEN a$ = "0" + conv$
  19.  

9
QB64 Discussion / Re: reading and writing to a file
« on: February 25, 2021, 01:15:12 pm »
This is a slightly more refined version of my previous post with error reporting and partial name search, that prints the output of the seach to the screen.

Code: QB64: [Select]
  1. ON ERROR GOTO ErrorLevel
  2.  
  3. start
  4.  
  5. ErrorLevel:
  6. PRINT "File not found"
  7. start
  8.  
  9. SUB start
  10.     DO
  11.         CLS
  12.         INPUT "[1]Read or[2] Write >", rw
  13.         IF rw = 2 THEN rw = 0: Data_Entry
  14.         IF rw = 1 THEN rw = 0: Read_Data
  15.     LOOP
  16.  
  17. SUB Data_Entry 'Asks for a filename for data to be input to
  18.     INPUT "please enter a filename>", filename$
  19.     OPEN filename$ FOR APPEND AS #1
  20.     INPUT "name >", n$
  21.     INPUT "address >", a$
  22.     INPUT "Tel. No. >", t$
  23.     WRITE #1, n$, a$, t$
  24.     CLOSE #1
  25.  
  26.  
  27. SUB Read_Data ' Aks for filename to open and name search paramerters
  28.     INPUT "Enter a filename >", filename$
  29.     OPEN filename$ FOR INPUT AS #1
  30.     INPUT "Enter a name to search for >", search$
  31.     CLS
  32.     DO
  33.         INPUT #1, n$, a$, t$
  34.         IF INSTR(n$, search$) THEN PRINT n$, a$, t$ ' this line seaches for any instance of search$ in the n$ variable
  35.     LOOP UNTIL EOF(1)
  36.     PRINT: PRINT: PRINT "Press any key to continue"
  37.     SLEEP 5
  38.     CLOSE #1
  39.  

10
QB64 Discussion / Re: reading and writing to a file
« on: February 25, 2021, 12:35:54 pm »
If you use the write command you can create a basic CSV file and load them back easier

Code: QB64: [Select]
  1. start
  2.  
  3. SUB start
  4.     DO
  5.         CLS
  6.         INPUT "[1]Read or[2] Write >", rw
  7.         IF rw = 2 THEN rw = 0: Data_Entry
  8.         IF rw = 1 THEN rw = 0: Read_Data
  9.     LOOP
  10.  
  11. SUB Data_Entry
  12.     INPUT "please enter a filename>", filename$
  13.     OPEN filename$ FOR APPEND AS #1
  14.     INPUT "name >", n$
  15.     INPUT "address >", a$
  16.     INPUT "Tel. No. >", t$
  17.     WRITE #1, n$, a$, t$
  18.     CLOSE #1
  19.  
  20.  
  21. SUB Read_Data
  22.     INPUT "Enter a filename >", filename$
  23.     INPUT "Enter a name to search for >", search$
  24.     OPEN filename$ FOR INPUT AS #1
  25.     CLS
  26.     DO
  27.         INPUT #1, n$, a$, t$
  28.         IF n$ = search$ THEN
  29.  
  30.             PRINT n$, a$, t$
  31.         END IF
  32.     LOOP UNTIL EOF(1)
  33.     PRINT: PRINT: PRINT "Press any key to continue"
  34.     SLEEP
  35.     CLOSE #1
  36.  
  37.  
  38.  

11
Programs / Formatting Decimal Currency
« on: February 11, 2021, 02:55:27 pm »
So this SUB came about because I'm currently writing an EPOS system, and could not for the life of me get the math to work properly due to floaty math.

The inability for QB64 to track numbers to the decimal place with accuracy and getting sick of having my program write 1.9 to screen as £1.90 i wrote this piece of code to convert the integers into a string to print to screen.

it is a bit lacking as I first have to convert the integer to string, but this simplifies the process some what.

It is very useful to me, hopefully someone else will find it useful in their program.

Code: QB64: [Select]
  1. SUB Currency (a$)
  2.     l = LEN(a$)
  3.     penny$ = RIGHT$(a$, 2)
  4.     IF LEN(penny$) = 1 THEN
  5.         pound$ = "0"
  6.         penny$ = "0" + penny$:
  7.         conv$ = pound$ + "." + penny$
  8.         a$ = conv$
  9.     ELSE
  10.         pound$ = LEFT$(a$, (l - 2))
  11.         conv$ = pound$ + "." + penny$
  12.         a$ = conv$
  13.     END IF
  14.     IF LEN(conv$) = 3 THEN a$ = "0" + conv$

12
Programs / Re: TCP/IP Printer
« on: February 04, 2021, 06:25:57 pm »
Thank you for your help with this SpriggsySpriggs

13
Programs / TCP/IP Printer
« on: February 04, 2021, 02:29:52 pm »
So i wrote a program that will print a file to printer in raw text.

I needed this as the LPRINT command is unavailable on LINUX.

I hope this file is helpful to you all.

Code: QB64: [Select]
  1. DIM PrinterConnect AS LONG
  2. DIM LinePrint AS STRING
  3. CRLF$ = CHR$(13) + CHR$(10) ' end current print line and starts new line
  4. FF$ = CHR$(12) ' end current print line and finish printing
  5. ESC$ = CHR$(27)
  6. PrinterConnect = _OPENCLIENT("TCP/IP:9100:***.***.***.***") 'replace astrix with your printers IP address. opens a connection to your printer
  7. IF PrinterConnect THEN
  8.     PRINT "[Connected to " + _CONNECTIONADDRESS(PrinterConnect) + "]"
  9. ELSE PRINT "[Connection Failed!]"
  10.  
  11. printstring1$ = "this is a printed line" + CRLF$
  12.  
  13. INPUT "please enter the name of the file you want to print>", FileName$
  14. OPEN FileName$ FOR INPUT AS #1
  15.     LINE INPUT #1, LinePrint$
  16.     PrintString$ = LinePrint$ + CRLF$
  17.     PUT #PrinterConnect, , PrintString$:
  18. PUT #PrinterConnect, , FF$

14
Programs / Linux Desktop Entry
« on: January 29, 2021, 08:54:50 am »
A small separate program to create a Desktop entry file on linux.

Also a new qb64 executable that will automatically create a desktop entry on  first run.

Pages: [1]