Jump to content

"var" in "for" syntax problems


Recommended Posts

Hi

Ok heres the basics.

I've been looking for a sample playing program for a while but then it hit me. Make one!

Now this all started well but some of the people i dj with started asking if they could have a copy ect.... no problem with that but it needed tidying and making so anyone could use it.

This is what i have so far, the problem i have is opening the files through the for statment.

#include <GUIConstants.au3>
#include <Sound.au3>
#include <array.au3>

$inifile = @WorkingDir & "\settings.ini"

$keys = IniReadSection ( $inifile, "keys" )

_ArrayDisplay ( $keys )

For $i = 1 To $keys[0][0]
    MsgBox(4096, $keys[$i][0], $keys[$i][1])
    HotKeySet ( "!" & $keys[$i][0], "_play" & $i )
    MsgBox(4096, $keys[$i][0], "_play" & $i)
        $play & $i = _SoundOpen ( $keys[$i][1] )   <<<<<<--------- Errors here
    Next

$Form1 = GUICreate("Client", 238, 121, 193, 125)
GUISetState(@SW_SHOW)

While 1
    Sleep(1)
WEnd
 
func _play1 ( )
    _SoundPlay($play[1] , 0 )
    $play[1] = _SoundOpen ( $keys[$i][1] )
EndFunc

func _play2 ( )
    _SoundPlay($play[2] , 0 )
    $play[2] = _SoundOpen ( $keys[$i][1] )
EndFunc

I hope you can see what im trying todo and point me the way i need to go.

Thanks

Link to comment
Share on other sites

What the heck are you trying to do? "$play & $i = _SoundOpen( $keys[$i][1] )" makes no sense. Perhaps you are trying to call one of your _play# functions? If so you should do it like: Call("_play" & $i). Other than that, you are going to have to explain what exactly you are trying to do here.

Link to comment
Share on other sites

ok. this is what im trying to get it to do.

The way the program sould work is that any time a ALT + key is pressed it should play a sample or ident thats been set to it via the ini file.

So from the start it reads the ini file

[keys]
1=C:\sweep\2.mp3
2=C:\sweep\3.mp3
q=C:\sweep\4.mp3
a=C:\sweep\5.mp3
z=C:\sweep\6.mp3
t=C:\sweep\7.mp3
h=C:\sweep\8.mp3

Sets up the hotkeys that are needed and then loads the samples using the _SoundOpen func.

The part at the start of the _SoundOpen command is to set the name it calls to play the preloaded sound. Im going to put the func's in for all they possible keys once its working, but the $play & $i tells it which sound.

so $play & $i should tell it to play the sound linked with the key pressed.

Hope that makes it a little easyer

Thx

Edited by res2cpu
Link to comment
Share on other sites

I guess you want to use an Array for every Sound ID from every File you have in the ini.

But you missed the right syntax for creating Arrays.

You cant concatenate (join) two variables in the way you did. Thats only possible with Strings.

;Wrong:
$play & $i = "SoundID"oÝ÷ Ù«­¢+ØíI¥¡Ðè(ÀÌØíÁ±äôÅÕ½ÐíM½Õ¹%ÅÕ½ÐìµÀìÀÌØíoÝ÷ Ø­¶¬ÂíéiÊ°Ør¢êé®åzk(ÈhÃ*.-¢è¥êåÊëºÚÊÆ®¶­sb6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC°¢6æ6ÇVFRfÇCµ6÷VæBæS2fwC°¢6æ6ÇVFRfÇC¶'&æS2fwC° ¢b33c¶æfÆRÒv÷&¶ætF"fײgV÷C²b3#·6WGFæw2æægV÷C° ¢b33c¶¶W2Òæ&VE6V7Föâb33c¶æfÆRÂgV÷C¶¶W2gV÷C² ¥ô'&F7Æb33c¶¶W2 ¤FÒb33c·Æ²b33c¶¶W5³Õ³ÕÒ²7&VFRâ'&vò22×V6VÆVÖVçG22æ¶W0 ¤f÷"b33c¶ÒFòb33c¶¶W5³Õ³Ð¢×6t&÷CbÂb33c¶¶W5²b33c¶Õ³ÒÂb33c¶¶W5²b33c¶Õ³Ò¢÷D¶W6WBgV÷C²b333²gV÷C²fײb33c¶¶W5²b33c¶Õ³ÒÂgV÷Cµ÷ÆgV÷C²fײb33c¶¢×6t&÷CbÂb33c¶¶W5²b33c¶Õ³ÒÂgV÷Cµ÷ÆgV÷C²fײb33c¶¢b33c·Æ²b33c¶ÒÒõ6÷VæD÷Vâb33c¶¶W5²b33c¶Õ³Ò²76væærFR6÷VæBBFò'&VÆVÖVçBb33c¶¢æW@ ¢b33c´f÷&ÓÒuT7&VFRgV÷C´6ÆVçBgV÷C²Â#3Â#Â2Â#R¤uT6WE7FFR5uõ4õr ¥vÆR¢6ÆVW¥tVæ@ ¦gVæ2÷Æb33cµ4ç"²W6RFRb33cµ4ç"&ÖWFW"FòFVÆÂFRgVæ7Föâv66÷VæB÷RvçBFòW6P¢bb33cµ4ç"fwC²V&÷VæBb33c·ÆÓFVâ²Ö¶R7W&RFB÷RFöçB6ÆÂç6÷VæBv6v6çBâFRæ¢×6t&÷ÃÂgV÷C´W'&÷#¢F26÷VæB6çB&VVâÆöFVBgV÷C²¢&WGW&à¢VæF`¢õ6÷VæEÆb33c·Æ²b33cµ4ç%Ò£·âb33c·Æ²b33cµ4ç%ÒÒõ6÷VæD÷Vâb33c¶¶W5²b33c¶Õ³Ò²÷RFöçBæVVBFò&VÆöBFR6÷VæB÷R§W7BÆVBâ÷RÇ&VGfRÆöFVBBâFRf÷"Æö÷¤VæDgVæ0
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Link to comment
Share on other sites

Thanks

Arrays have always caused me problems, never have got the hang of them.

I have tried your code but its still having problems, im looking through to see if i can work it out but as i said arrays have never liked me!

As for reloading the sound, i found i needed to before with my old code.

Link to comment
Share on other sites

ok its all working but im getting an error on the HotKeySet, it needs to pass the key pressed onto the func

HotKeySet ( "!" & $keys[$i][0], "_play"($keys[$i][0])" )

func _play ($SNr); use the $SNr parameter to tell the function which sound you want to use
    if $SNr > Ubound($play)-1 then; Make sure that you dont call any sound which wasnt in the ini
        MsgBox(0,0,"Error: this Sound hasnt been loaded")
        return
    Endif
    _SoundPlay($play[$SNr] , 0 )
;~  $play[$SNr] = _SoundOpen ( $keys[$i][1] ); You dont need to reload the Sound you just played. You already have loaded it in the For Loop
EndFunc

Can anyone give me a clue on the correct syntax for this?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...