Thanks Charles,
examples worked well here! I had a look at the code, there are some unbelieveable stunts. With proper documentation, Oxygen will be perfect.
Happy Petr
These examples are included in the examples/COM folder.
Basic access to SAPI voice Interface
[code=thinbasic]
'-----------------------------------------
'SAPI VOICE
'=========================================
Uses "oxygen"
Dim src As String
src="
#basic
#include Voice.inc
'
'
'
' ###############
' ###################
' ### ###
' ### ### ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### #### ## ###
' ### #### ###
' ### ###
' ### ###
' #############
' #########
CoInitialize(byval 0)
dim as GUID VoiceObjGuid, ISpVoiceGuid
dim as HRESULT hr
dim as ISpVoice ptr voice
dim as LPUNKNOWN pUnkOuter
dim as dword flags
const as PVOID NULL=0
guidval VoiceObjGuid, "96749377-3391-11D2-9EE3-00C04F797396"
guidval ISpVoiceGuid, "6C44DF74-72B9-4992-A1EC-EF996E0422D4"
& pUnkouter=0
hr=CoCreateInstance VoiceObjGuid, pUnkouter, context, ISpVoiceGuid, voice
if hr then print "SAPI Error " hex(hr) : jmp fwd done
voice.Speak w("Hello Everyone!"),flags,NULL
voice.WaitUntilDone &hFFFFFFFF
voice.Release
& voice=0
done:
CoUninitialize()
"
'msgbox 0,O2_prep src+o2_error
O2_asmo src
if Len(O2_ERROR) Then
msgbox 0,O2_ERROR
else
o2_exec
end if
[/code]
OOPIFIED:
[code=thinbasic]
'=================================
'ATTACHING SAPI VOICE TO AN OBJECT
'=================================
'
'
' ###############
' ###################
' ### ###
' ### ### ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### ## ## ###
' ### #### ## ###
' ### #### ###
' ### ###
' ### ###
' #############
' #########
Uses "oxygen"
Dim c,src As String
dim v as long
src="
#basic
#include Voice.inc
incl VoiceMacros
Connect voice
ErrorHandler jmp fwd done
'---------
class mind
'=========
memory as string
end class
'-----------
class person
'===========
ISpVoice * voice
has mind
'
method new()
memory="<>"
end method
'
method del()
memory=""
end method
'
method learn(string s)
memory+=s "<>"
end method
'
method recall(string s)
sys a,b,c
string r
a=instr(memory,s)
if a then
a+=len(s)
b=instr(a,memory,"<>")
end if
if a then
r=mid(memory,a,b-a)
else
r="I do not remember " s
end if
if & voice then
voice.speak w(r)
voice.WaitUntilDone forever
else
print r
end if
end method
'
end class
def Create
{
%1 %2
%2.new()
}
def CreatePersistent
{
%1 * %2
& %2=news sizeof %1
%2.new
}
def Delete
{
%1.del
frees & %1
& %1=0
}
'====
'MAIN
'====
CreatePersistent Person Hilda
Give Hilda voice
'Remove Hilda voice
Hilda.learn ".greeting. Hello Everyone"
Hilda.recall ".greeting."
Delete Hilda
'====
done:
'====
DisConnect voice
"
'msgbox 0,O2_prep src+o2_error
O2_asmo src
if Len(O2_ERROR) Then
msgbox 0,O2_ERROR
else
o2_exec
end if
[/code]
Latest Oxygen
http://community.thinbasic.com/index.php?topic=2517
Charles
Thanks Charles,
examples worked well here! I had a look at the code, there are some unbelieveable stunts. With proper documentation, Oxygen will be perfect.
Happy Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Chals,
you are doing an astonishing incredible work!
I agree with Petr: some documentation is needed not to vaste the great amount of work done and time spent.
You have an great product.
Eros
www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000
Thanks Petr and Eros,
You will find documentation in its raw state in o2keyw.bas. All the main keywords are coded in this file along with descriptive records which will be used to generate the manual in whichever format is desired. I'm continually adding new material to this file, and occasionally removing redundant keywords.
The syntax rules are still evolving - mostly towards reading C header files in their entirety.
Charles
Example
[code=thinbasic]
data "#case" ,-13, 41
'===========================
'action: specify mode of case sensitivity.
'use: case can be 'sensitive' insensitive' or 'capital'
example:
' #case insensitive 'AbC is the same as 'aBC' and 'ABC'
' #case sensitive 'AbC and 'abc' are not the same
' #case capital 'AbC is the same as 'aBC' but not 'ABC'
'remarks: The default is 'insensitive'.
' #case has block scope and reverts to its previous state when
' the block ends.
[/code]
thanks Charles for those examples, i have tried voice.Speak w(spk),flags,NULL with big texts assigned to string variable spk and it is working properly.
the compiler co2.exe in the new version seems not working. i have tried an older oxygen version downloaded in Mars-5-2010 and it is working such as compiling like this:
co2.exe fibo.bas to produce the standalone fibo.exe but not in the new version
[code=thinbasic]#file "fibo.exe"
Function fibonacci(ByVal sequence As DWord) As DWord
If sequence < 2 Then
Function = sequence
Else Function = fibonacci(sequence - 1) + fibonacci(sequence - 2)
End If
End Function
Print fibonacci(30)
terminate[/code]
Hi Zak,
Yes I see the the problem. It is looking in the wrong locations for thinBasic_Oxygen.dll. If you place a copy of this in the same folder as your compiled EXE or DLL then it should work.
Meanwhile I will investigate why it loses the path.
Many thanks
Charles
PS: scripts compiling directly from thinBasic (#file "myprog.exe") do not manifest this problem.
I've fixed the problem.
There is a new instruction for explicitly configuring the Oxygen filepaths.
#o2paths
I have deployed this in CO2Maker:
Charles
[code=thinbasic]
#o2paths "
`.\thinBasic_oxygen.dll`? `lib\thinBasic_oxygen.dll`?
`..\thinBasic_Oxygen.dll`?
`..\lib\thinBasic_Oxygen.dll`?
`\thinbasic\lib\thinBasic_Oxygen.dll`?
`c:\thinbasic\lib\thinBasic_Oxygen.dll`? "
[/code]
Hi Charles
the new Oxygen co2.exe are working perfectly on windows 7, and i guess the same for vista,
just a report that in windows xp/sp2 it gives an error like in the attached picture, i have tried it on two computers with xp/sp2. but i do not know the situation with xp/sp3, i need someone else to confirm or not the situation with xp/sp3.
the older version downloaded in mars 2010 was working okay on xp/sp2.
regards
P.S:when we double click co2_maker.tbasic it will make co2.exe with a message compiled ok.
but using it will give the error as in the picture " co2.exe is not a valid win32 application"
the helloworld.exe in the picture is compiled using windows 7
I tried the CO2 from SVN,
after launching co2_maker.tbasic it creates 4608 bytes big CO2, but when I try to launch it, it says it is not valid Win32 app on Windows XP SP3.
I tried to shutdown antivirus for a while, but with same results.
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
I will investigate!
I have pre-March versions stored away somewhere. I'm assuming the problem came in when I introduced 64 bit capability, so I will check the flag settings. Were you able to run these samples under XP2 previously?
Charles
Bookmarks