System.Console.BeepBeep(frequency, duration)

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
abmuzzy
Posts: 4
Joined: Mon Mar 04, 2019 6:28 pm

System.Console.BeepBeep(frequency, duration)

Post by abmuzzy »

Is there any way to run
System.Console.BeepBeep(frequency, duration)
or any other function to produce frequency/length defined sound
while using OpenOffice scripting?
Not just beep
Not calling prestored wav file, but generating a sound of a certain frequency during a certain time?
ON LINUX?
UBUNTU?

On PC, Windows, MS Office, VBA
it will be as below
===================================================
'Dim freq As Integer = Integer.Parse(txtFrequency.Text)
'Dim duration As Integer = Integer.Parse(txtDuration.Text)

Dim freq As Integer
Dim duration As Integer
freq = 500
duration = 1000 'ms
System.Console.Beep(freq, duration)
================================

When I run it on LibreOffice Calc it runs upto the
System.Console.Beep(freq, duration)

and

returns

BASIC syntax error

where the culprit is "System"
===============================================================
So I am looking for a way to call System.Console.Beep(freq, duration) with Basic as Script
Or some other way of GENERATING a sound with certain length and certain frequency
ANy help will be appreciated
OpenOffice 2.4 on Ubuntu 16.04
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: System.Console.BeepBeep(frequency, duration)

Post by JeJe »

On windows its just the Beep function which you can declare at the top of a module. Don't know whether these work under Linux with WINE installed.

Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
abmuzzy
Posts: 4
Joined: Mon Mar 04, 2019 6:28 pm

Re: System.Console.BeepBeep(frequency, duration)

Post by abmuzzy »

Just tried.

Code: Select all

REM  *****  BASIC  *****

Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Sub Main
msgbox "hello"
End Sub

Function eps () 
Msgbox "Func"
end Function

Sub press
'Dim freq As Integer = Integer.Parse(txtFrequency.Text)
'Dim duration As Integer = Integer.Parse(txtDuration.Text)


'Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Dim freq As Integer
Dim duration As Integer


'freq = Integer.Parse(txtFrequency.Text)
'duration = Integer.Parse(txtDuration.Text)


freq = 500
duration = 10

'System.Console.Beep(freq, duration)

msgbox "hello"
Call eps
Call Beep(500,1000)

End Sub
OpenOffice 2.4 on Ubuntu 16.04
abmuzzy
Posts: 4
Joined: Mon Mar 04, 2019 6:28 pm

Re: System.Console.BeepBeep(frequency, duration)

Post by abmuzzy »

kernel32
Error Not declared
OpenOffice 2.4 on Ubuntu 16.04
abmuzzy
Posts: 4
Joined: Mon Mar 04, 2019 6:28 pm

Re: System.Console.BeepBeep(frequency, duration)

Post by abmuzzy »

'I found some kind of a walkaround.


Sub Main

'man page Beep
'Shell("firefox",2)
'msgbox "hello"

Shell("beep -f 1000 -n -f 2000 -n -f 1500 ")

End Sub


'Thanks anyway.
OpenOffice 2.4 on Ubuntu 16.04
Post Reply