Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Large Integer and Base Conversion Integer Parent Script
RotateWithSound
Play Soundfile
Cut Behavior (Ctrl + X)
f3VideoCapture
Protected Code
==> FlashFere2.2 Available now !!
Echo Vibes
Sprite Player v.2
Ripple Follow Mouse on Rollover-Alphamania
 

 

 

Behavior File Association and save

Added on 10/2/2000

 

Compatibilities:
D7 D8 PC Script

Required Xtras:
Buddy API

This item has not yet been rated

Author: MediaMacros (website)

This is a set of scripts that will allow you to associate a file type (by extension) so that clicking on the save file will open your projector and feed back the data.

--The 4 parts work as follows...
---------------
--Create the file association first like so...
--createSaveAssociation(threeLetterExtension, thePathToTheProjector, nameOfTheTypeOfFile, description)
--Example : createSaveAssociation("sav", the applicationPath & "start.exe", "SaveFile" , "Game Save Data")
---------------
--Save a file to the users drive.  This can be used alone for saving an encrypted save file or you can use the same extension from --the last function to make an associated save file.  It works like this...
--saveFile(theFilenameIncludingThePath, listOfDataHeadings, listOfDataValues, encryptionKey)
--Example : saveFile("C:saveFile.sav", ["UserName", "Score"], ["Chuck", "999,999"], "ThisKey")
---------------
--Get the data back from the users file.
--getFileData(fileNameIncludingThePath, listOfDataHeadings-SameAsTheSavelistOfDataHeadings, key-SameAsSaveKey)
--Example : valueList = getFileData("C:saveFile.sav", ["UserName", "Score"], "ThisKey")
---------------
--Last we have the option to pull the data if the file was double-clicked on rather than loaded through the projector.
--checkFileOpen(listOfDataHeadings, key)
--Example : valueList = checkFileopen(["UserName", "Score"], "ThisKey")

on createSaveAssociation Extension, ProgramPath, theFileType, Description
  set shortFileName = baShortFileName(ProgramPath)
  baWriteIni( "Extensions", Extension, shortFileName && "^." & Extension, "win.ini" )
  baSendMsg( 65535, 26, 0, 0, true )
  if the number of chars in Extension <= 3 then    
    baWriteRegString("." & Extension, "", theFileType, "HKEY_CLASSES_ROOT" )
    baWriteRegString( theFileType & "\Shell\Open\Command", "", shortFileName && "%1", "HKEY_CLASSES_ROOT" )
    baWriteRegString( theFileType, "", Description, "HKEY_CLASSES_ROOT" )
  end if
end


on checkFileOpen keyList, key
  set thefileName = baCommandArgs( )
  set partFile = char 2 to the number of chars in thefilename of thefilename
  set driveLetter = baFindDrive( "a", partFile )
  if thefileName <> "" then
    set stringList = getFileData (driveLetter & thefileName, keyList, key)
    return stringList
  else
    return void
  end if  
end


on saveFile thefileName, keyList, valueList, key
  repeat with x = 1 to count(keyList)
    baWriteIni("SaveData", getAt(keyList, x), baEncryptText(getAt(valueList,x), key), thefileName)
  end repeat
end


on getFileData whatFile, keyList, key
  valueList = []
  repeat with x = 1 to count(keyList)
    thisvalue = baDecryptText(baReadIni( "SaveData",  getAt(keyList, x), "Error", whatFile),key)
    add valueList, thisvalue
  end repeat
  return valueList
end

on getBehaviorDescription me
  describe = "This is a set of scripts that will allow you to associate a file type (by extension) so that clicking on the save file will open your projector and feed back the data."
  describe = describe & return & "The 4 parts work as follows..." & return & return & "-------------" & return & "Create the file association first like so..." & return & "createSaveAssociation(threeLetterExtension, thePathToTheProjector, nameOfTheTypeOfFile, description)" & return & "Example : createSaveAssociation(" & quote & "sav" & quote & ", the applicationPath & " & quote & "start.exe" & quote & ", " & quote & "SaveFile" & quote && ", " & quote & "Game Save Data" & quote & ")"
  describe = describe & return & "-------------"  & return &  "Save a file to the users drive.  This can be used alone for saving an encrypted save file or you can use the same extension from the last function to make an associated save file.  It works like this..." & Return & "saveFile(theFilenameIncludingThePath, listOfDataHeadings, listOfDataValues, encryptionKey)" & return & "The list of data headings is a linear list of what each saved field should be called.  The second list is the values in the same order."& return & "Example : saveFile(" & quote & "C:\saveFile.sav" & quote & ", [" & quote & "UserName" & quote & ", " & quote & "Score" & quote & "], [" & quote & "Chuck" & quote & ", " & quote & "999,999" & quote & "], " & quote & "ThisKey" & quote & ")"
  describe = describe & return & "-------------" & return & "Get the data back from the users file." & return & "Use like this..." & return & "getFileData(fileNameIncludingThePath, listOfDataHeadings-SameAsTheSavelistOfDataHeadings, key-SameAsSaveKey)" & Return & "This will return a list of the cooresponding values." & return & "Example : valueList = getFileData(" & quote & "C:\saveFile.sav" & quote & ", [" & quote & "UserName" & quote & ", " & quote & "Score" & quote & "], " & quote & "ThisKey" & quote & ")"
  describe = describe & return & "-------------" & return & "Last we have the option to pull the data if the file was double-clicked on rather than loaded through the projector." & Return & "It works like this..." & return & "checkFileOpen(listOfDataHeadings, key)" & Return & "Use the same list of data headings and call this in the start movie handler or wherever you want to pull the data from the loaded movie (before you need to access these values.)" & return & "Example : valueList = checkFileopen(["& quote & "UserName" & quote & ", " & quote & "Score" & quote & "], " & quote & "ThisKey" & quote & ")"
  return describe
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail