dynamitemedia

stringregexp question/help

9 posts in this topic

Ok so im trying to use ffmpeg to get the Dshow devices available 

Here is what i have so far

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Global $sFolder = @ScriptDir & "\www\videos"
Global $FFmpegDir =  @ScriptDir & "\www\bin\"

$sCommands = "FFmpeg -list_devices true -f dshow -i dummy"
$iPID = Run("cmd /c " & $sCommands, $FFmpegDir , @SW_Hide , $stderr_child + $stdout_child)

$sOutput = ""
 While 1
        $sOutput &= StderrRead($iPID)

        If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
            ExitLoop
        EndIf
     WEnd

;ConsoleWrite($sOutput  & @CRLF)

Local $iPosition = StringInStr($sOutput, "[dshow")
Local $sString = StringTrimLeft($sOutput, $iPosition -1)
Local $iPosition2 = StringInStr($sString, "dummy: Immediate exit requested")
Local $iLength = StringLen($sString)
Local $CutRight = $iLength - $iPosition2
Local $dStrings = StringTrimRight($sString, $CutRight + 1)
ConsoleWrite($dStrings  & @CRLF)


this is what i get back:

[dshow @ 02b85e40] DirectShow video devices
[dshow @ 02b85e40]  "CyberLink Webcam Splitter"
[dshow @ 02b85e40]  "USB Video Device"
[dshow @ 02b85e40]  "IP Camera [JPEG/MJPEG]"
[dshow @ 02b85e40]  "DroidCam"
[dshow @ 02b85e40] DirectShow audio devices
[dshow @ 02b85e40]  "USB Audio Device"
[dshow @ 02b85e40]  "Realtek HD Audio Input"


all i really want is the devices split up can come back as an array so i can put into a combo box for each of the below

1.) DirectShow video devices
2.)  DirectShow audio devices

each machine i am assuming will have different  than this "[dshow @ 02b85e40]"  so not a 100 % sure i could/should just do another "StringTrimLeft" just in case its more letters/numbers.

heck i prob didn't need what i had done as it is... sure there is an easier way

Thank you for your help

Share this post


Link to post
Share on other sites



This ?

#Include <Array.au3>

$dStrings = '[dshow @ 02b85e40] DirectShow video devices' & @CRLF & _
           '[dshow @ 02b85e40]  "CyberLink Webcam Splitter"' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Video Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "IP Camera [JPEG/MJPEG]"' & @CRLF & _
           '[dshow @ 02b85e40]  "DroidCam"' & @CRLF & _
           '[dshow @ 02b85e40] DirectShow audio devices' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Audio Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "Realtek HD Audio Input"'

$sVideo = StringRegExpReplace($dStrings, '(?s).*\[[^\]]+\]\h+DirectShow video devices\R((?:\[[^\]]+\]\h+"[^"]+"(?:\R|$))+).*', "$1")
$aVideoDevices = StringRegExp($sVideo, '"([^"]+)"', 3)
_ArrayDisplay($aVideoDevices, "Video devices")


$sAudio = StringRegExpReplace($dStrings, '(?s).*\[[^\]]+\]\h+DirectShow audio devices\R((?:\[[^\]]+\]\h+"[^"]+"(?:\R|$))+).*', "$1")
$aAudioDevices = StringRegExp($sAudio, '"([^"]+)"', 3)
_ArrayDisplay($aAudioDevices, "Audio devices")

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

'nother one ...  :)

#Include <Array.au3>

$dStrings = '[dshow @ 02b85e40] DirectShow video devices' & @CRLF & _
           '[dshow @ 02b85e40]  "CyberLink Webcam Splitter"' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Video Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "IP Camera [JPEG/MJPEG]"' & @CRLF & _
           '[dshow @ 02b85e40]  "DroidCam"' & @CRLF & _
           '[dshow @ 02b85e40] DirectShow audio devices' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Audio Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "Realtek HD Audio Input"'

$nV = "DirectShow video devices"
$nA = "DirectShow audio devices"
$dev = StringRegExp($dStrings, '(?s)(' & $nV & '.*)(' & $nA & '.*)', 3)

$video = StringRegExp($dev[0], '"([^"]+)"' , 3)
_ArrayDisplay($video, $nV)

$audio = StringRegExp($dev[1], '"([^"]+)"' , 3)
_ArrayDisplay($audio, $nA)

 

Edited by mikell

Share this post


Link to post
Share on other sites

thanks guys i like both of these.  is there any advantage of using one or the other?

 

Share this post


Link to post
Share on other sites

this is what i did, is there a way to make the for loops into one? to clean it up?
 

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#Include <Array.au3>

Global $FFmpegDir =  @ScriptDir & "\www\bin\"

$sCommands = "FFmpeg -list_devices true -f dshow -i dummy"
$iPID = Run("cmd /c " & $sCommands, $FFmpegDir , @SW_Hide , $stderr_child + $stdout_child)

$sOutput = ""
 While 1
        $sOutput &= StderrRead($iPID)

        If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
            ExitLoop
        EndIf
     WEnd


$sVideo = StringRegExpReplace($sOutput, '(?s).*\[[^\]]+\]\h+DirectShow video devices\R((?:\[[^\]]+\]\h+"[^"]+"(?:\R|$))+).*', "$1")
$aVideoDevices = StringRegExp($sVideo, '"([^"]+)"', 3)

$sAudio = StringRegExpReplace($sOutput, '(?s).*\[[^\]]+\]\h+DirectShow audio devices\R((?:\[[^\]]+\]\h+"[^"]+"(?:\R|$))+).*', "$1")
$aAudioDevices = StringRegExp($sAudio, '"([^"]+)"', 3)


Local $vDshow = ""
For $vid In $aVideoDevices
    $vDshow = $vDshow & $vid & @CRLF
 Next
MsgBox(0, "DirectShow video devices", $vDshow)


Local $aDshow = ""
For $aud In $aAudioDevices
    $aDshow = $aDshow & $aud & @CRLF
 Next
MsgBox(0, "DirectShow audio devices", $aDshow)

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Try with this code :

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Global $FFmpegDir = @ScriptDir & "\www\bin\"

$sCommands = "FFmpeg -list_devices true -f dshow -i dummy"
$iPID = Run("cmd /c " & $sCommands, $FFmpegDir , @SW_Hide , $stderr_child + $stdout_child)

$sOutput = ""
While 1
    $sOutput &= StderrRead($iPID)
    If @error Then ExitLoop
WEnd
Local $sVideoDevices, $sAudioDevices
Local $iVideoLine = 0, $iAudioLine = 0

$aLines = StringRegExp($sOutput, '\[[^\]]+\]\h+(?|(DirectShow (?:audio|video) devices)|"([^"]+)"|(Could not enumerate\N+))', 3)
For $i = 0 To UBound($aLines) - 1
    If StringInStr($aLines[$i], "DirectShow video devices") Then
        $iVideoLine = 1
        $iAudioLine = 0
        ContinueLoop
    ElseIf StringInStr($aLines[$i], "DirectShow audio devices") Then
        $iAudioLine = 1
        $iVideoLine = 0
        ContinueLoop
    EndIf
    
    If $iVideoLine Then $sVideoDevices &= $aLines[$i] & @CRLF
    If $iAudioLine Then $sAudioDevices &= $aLines[$i] & @CRLF
Next

MsgBox(0, "DirectShow video devices", $sVideoDevices)
MsgBox(0, "DirectShow audio devices", $sAudioDevices)

Edit : I edited my code because when I tried the code on my computer an I saw this error :

[dshow @ 02c09800] DirectShow video devices (some may be both video and audio devices)
[dshow @ 02c09800] Could not enumerate video devices (or none found).
[dshow @ 02c09800] DirectShow audio devices
[dshow @ 02c09800]  "Realtek Digital Input (Realtek "
[dshow @ 02c09800]     Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\Realtek Digital Input (Realtek "
dummy: Immediate exit requested

Edited by jguinch

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

or this one  :D

$dStrings = '[dshow @ 02b85e40] DirectShow video devices' & @CRLF & _
           '[dshow @ 02b85e40]  "CyberLink Webcam Splitter"' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Video Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "IP Camera [JPEG/MJPEG]"' & @CRLF & _
           '[dshow @ 02b85e40]  "DroidCam"' & @CRLF & _
           '[dshow @ 02b85e40] DirectShow audio devices' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Audio Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "Realtek HD Audio Input"'

$nV = "DirectShow video devices"
$nA = "DirectShow audio devices"
$dev = StringRegExp($dStrings, '(?s)(' & $nV & '.*)(' & $nA & '.*)', 3)

$pattern = '(?m)(^[^"]+"?)|("(?=\R?))'
msgbox(0, $nV, $nV &@crlf&@crlf& StringRegExpReplace($dev[0], $pattern , ""))
msgbox(0, $nA, $nA &@crlf&@crlf& StringRegExpReplace($dev[1], $pattern , ""))

 

Edited by mikell
1 person likes this

Share this post


Link to post
Share on other sites

 

​heck yeah that was a lot cleaner code than mine...

i think the issue is the $dstrings wouldb ebe different on every pc so i went with just getting the $sOutput from the  StderrRead​

seems to work without the need for the $dDtrings

Share this post


Link to post
Share on other sites

#Include <Array.au3>

$dStrings = '[dshow @ 02b85e40] DirectShow video devices' & @CRLF & _
           '[dshow @ 02b85e40]  "CyberLink Webcam Splitter"' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Video Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "IP Camera [JPEG/MJPEG]"' & @CRLF & _
           '[dshow @ 02b85e40]  "DroidCam"' & @CRLF & _
           '[dshow @ 02b85e40] DirectShow audio devices' & @CRLF & _
           '[dshow @ 02b85e40]  "USB Audio Device"' & @CRLF & _
           '[dshow @ 02b85e40]  "Realtek HD Audio Input"'

$aSplit = stringsplit($dStrings , "DirectShow audio devices" & @CRLF , 3)

$aVideo = stringsplit($aSplit[0] , @CRLF , 3)
_ArrayDelete($aVideo , ubound($aVideo) - 1)
_ArrayDelete($aVideo , 0)

$aAudio = stringsplit($aSplit[1] , @CRLF , 3)


_ArrayDisplay($aVideo , "Video")
_ArrayDisplay($aAudio , "Audio")

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
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

  • Similar Content

    • Robinson1
      By Robinson1
      Well the plan is to use the power of regular expressions engine of AutoIT for patching binary data.
      Something like this: StringRegExp( $BinaryData,  "(?s)\x55\x8B.."
       
      <cut> ... Okay straight to question/problem
      ... certain bytes that are in the range from 0x80 to 0xA0 won't match.
      Hmm seem to be a char encoding problem. In detail these are 27 chars: 0x80, 0x82~8C, 0x8E, 0x91~9C, 0x9E,0x9F
      Here's a small code snippet to explore / explain this problem:
      #include "StringConstants.au3" $TestData = BinaryToString("0x7E7F808182") ;Okay $match = StringRegExp( $TestData ,'\x7E' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Okay $match = StringRegExp( $TestData ,'\x7F' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Error no match $match = StringRegExp( $TestData ,'\x80' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Okay $match = StringRegExp( $TestData ,'\x81' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;Error no match $match = StringRegExp( $TestData ,'\x82' ,$STR_REGEXPARRAYFULLMATCH) ConsoleWrite('@extended = ' & @extended & ' $match = ' & $match & @CRLF) ;~ output: ;~ @extended = 2 $match = ;~ @extended = 3 $match = ;~ @extended = 0 $match = 1 ;~ @extended = 5 $match = ;~ @extended = 0 $match = 1 Hmm what to do? Go back and use the 'numberstring monster' implementation or just omit that range of 'unsafe bytes'. What is the root of this problem?
      Any idea how to fix this?
       
      Update: Okay I know a byte is not a character.
      But StringRegExp operates on String and so character level.
      Okay as long as you stay at Ansi encoding and only use /x00 - /X7F in the search pattern using  StringRegExp works well to search for binary data.
      What bytes can be matched that are in the range from /X7F - /xFF is also depending on the code page.
      So this avoid to search for bytes in the range from 0x80-0xa0 only applies to Germany.
      I just change this country setting:

      to Thai and now near all bytes from /X7F - /xFF fails to match.
    • Carm01
      By Carm01
      Hello,
      I have spent the past day fooling with StringRegExp to no avail attempting to get what would be a simple solution to an issue using StringRegExp.
      I will post the code in a sec. The string 'Java x Update y' where x and y are numeric values ONLY if a letter is mixed in anywhere then it should fail. I have been able to successfully deal with the x value so if x = 1234 or a1234 or 1a234 or 1234a would result in a fail if 'a' was in the string. However, when y = 1a234 then I get an output of 1 and when y = 1234a then the output = 1234 when both should fail. I am probably overlooking something simple and in looking through all the material and experimenting I am unable to figure it out and my experience with stringregexp and trying to find examples of this proved difficult. If someone could assist or point me to a thread ? Here is my code ; prob a simple fix. I am also trying to avoid white spaces.
      Thanks in advance
      #include <array.au3> $aArray = StringRegExp('Java 3009 Update 1a21', '(?i)Java (\d+) Update (\d+)', $STR_REGEXPARRAYGLOBALMATCH) If @error Then Exit _ArrayDisplay($aArray)  
    • VIP
      By VIP
      Need help to make function better  with full infomation
      #include <Array.au3> #include <File.au3> _TEST(@ScriptFullPath) _TEST("A:") _TEST("A:\B.c") _TEST("D:\E\F\") _TEST("G:\H/../J.k/") _TEST("M:\N\k..J.k") _TEST("D:\E\F\..\G\G\I..J.K.M") Func _TEST($sFilePath) Local $sDrive = "", $sFullPathDir = "", $sDirPath = "", $sDirName = "", $sFileName = "", $sFileNameExt = "", $sExtension = "", $sExt = "" Local $aPathSplit = _PathSplitByRef($sFilePath, $sDrive, $sFullPathDir, $sDirPath, $sDirName, $sFileName, $sFileNameExt, $sExtension, $sExt) ConsoleWrite("!Path IN : " & $sFilePath & @CRLF) ; C:\Windows\System32\etc\hosts.exe ConsoleWrite("- Driver : " & $sDrive & @CRLF) ; C: ConsoleWrite("- DirPath : " & $sFullPathDir & @CRLF) ; C:\Windows\System32\etc\etc ConsoleWrite("- DirPath : " & $sDirPath & @CRLF) ; \Windows\System32\etc\ ConsoleWrite("- DirName : " & $sDirName & @CRLF) ; etc ConsoleWrite("- FileName : " & $sFileName & @CRLF) ; hosts ConsoleWrite("- FileNameExt: " & $sFileNameExt & @CRLF) ; hosts.exe ConsoleWrite("- Extension : " & $sExtension & @CRLF) ; .exe ConsoleWrite("- Ext : " & $sExt & @CRLF & @CRLF) ; exe ;~ ConsoleWrite("!Path IN : " & $aPathSplit[0] & @CRLF) ; C:\Windows\System32\etc\hosts.exe ;~ ConsoleWrite("- Driver : " & $aPathSplit[1] & @CRLF) ; C: ;~ ConsoleWrite("- DirPath : " & $aPathSplit[2] & @CRLF) ; C:\Windows\System32\etc\etc ;~ ConsoleWrite("- DirPath : " & $aPathSplit[3] & @CRLF) ; \Windows\System32\etc\ ;~ ConsoleWrite("- DirName : " & $aPathSplit[4] & @CRLF) ; etc ;~ ConsoleWrite("- FileName : " & $aPathSplit[5] & @CRLF) ; hosts ;~ ConsoleWrite("- FileNameExt: " & $aPathSplit[6] & @CRLF) ; hosts.exe ;~ ConsoleWrite("- Extension : " & $aPathSplit[7] & @CRLF) ; .exe ;~ ConsoleWrite("- Ext : " & $aPathSplit[8] & @CRLF) ; exe ;~ _ArrayDisplay($aPathSplit, "_PathSplit of " & $sFilePath) EndFunc ;==>_TEST Func _PathSplitByRef($sFilePath, ByRef $sDrive, ByRef $sFullPathDir, ByRef $sDirPath, ByRef $sDirName, ByRef $sFileName, ByRef $sFileNameExt, ByRef $sExtension, ByRef $sExt) If StringInStr($sFilePath,"..") Then $sFilePath=_PathFull($sFilePath) Local $aPartOfPath=StringRegExp($sFilePath, "^\h*((?:\\\\\?\\)*(\\\\[^\?\/\\]+|[A-Za-z]:)?(.*[\/\\]\h*)?((?:[^\.\/\\]|(?(?=\.[^\/\\]*\.)\.))*)?([^\/\\]*))$", $STR_REGEXPARRAYMATCH) ;~ If @error Then ReDim $aPartOfPath[9] ;~ $aPartOfPath[0] = $sFilePath ;~ EndIf $aPartOfPath[0] = $sFilePath ; C:\Windows\System32\etc\hosts.exe $sDrive = $aPartOfPath[1] ; C: $sFullPathDir = $aPartOfPath[1] & $aPartOfPath[2] ; C:\Windows\System32\etc If StringLeft($aPartOfPath[2], 1) == "/" Then $sDirPath = StringRegExpReplace($aPartOfPath[2], "\h*[\/\\]+\h*", "\/") Else $sDirPath = StringRegExpReplace($aPartOfPath[2], "\h*[\/\\]+\h*", "\\") EndIf $aPartOfPath[2] = $sFullPathDir ; C:\Windows\System32\etc $sDirName=StringReplace($sDirPath,"\","") $sDirName=StringReplace($sDirPath,"/","") $sFileName = $aPartOfPath[3] ; hosts $aPartOfPath[5] = $sFileName ; hosts $sExtension = $aPartOfPath[4] ; .exe $aPartOfPath[7] = $sExtension ; .exe $aPartOfPath[3] = $sDirPath ; \Windows\System32\etc\ $aPartOfPath[4] = $sDirName ; etc $aPartOfPath[6] = $sFileName & $sExtension ; hosts.exe $sFileNameExt = $aPartOfPath[6] ; hosts.exe $sExt = StringReplace($sExtension,".","") ; exe $aPartOfPath[8] = $sExt ; exe Return $aPartOfPath EndFunc ;==>_PathSplitByRef  
    • Subz
      By Subz
      Does anyone know how to split a string using multiple delimiters, returning both the values and delimiters withing the Array using StringRegExp?  For example:
      ;~ Split on " Not ", " And ", " Or " $sString = ' Not $a = 1 And $b = 2 Or $b = 3' $aArray = StringRegExp($sString,...) ;~ Returned Results $aArray[0] = '$a = 1' $aArray[1] = 'And' $aArray[2] = '$b = 2' $aArray[3] = 'Or' $aArray[4] = '$b = 3' At the moment I'm using
      Local $aArray1 = StringRegExp($sString, '(?i) Or | And | Not ', 3) Creating a new array using string split and then joining the two arrays together again
      Local $aArray1 = StringSplit(StringRegExpReplace($sString, '(?i) Or | And | Not ', '******'), '******', 3) Unfortunately regular expression isn't my forte.
    • VIP
      By VIP
      Hi,
      I need help string RegEx to get string from CREATE to GO
      #include <StringConstants.au3> ;~ Global $fileSQL1 = @ScriptDir & "\fileSQL1.sql" ;~ Global $fileSQL2 = @ScriptDir & "\fileSQL2.sql" Global $tmpSQLfile = @TempDir & "\tmpFile.sql" OnAutoItExitRegister("_OnExit") _SetTMPsql() If Not FileExists($tmpSQLfile) Then OnAutoItExitUnRegister("_OnExit") Exit MsgBox(48, "/!\", "File: " & $tmpSQLfile & @CRLF & " is not Exists!", 3) EndIf Global $ContentSQLfile = FileRead($tmpSQLfile) _Start() Func _Start() Local $aArray, $iOffset = 1, $stringRegExp = '(?i)CREATE(.*?)GO' While 1 $aArray = StringRegExp($ContentSQLfile, $stringRegExp, $STR_REGEXPARRAYMATCH, $iOffset) If @error Then MsgBox(48, "StringRegExp Error " & @error, "+> StringRegExp: " & $stringRegExp & @CRLF & @CRLF & "=> With STRING:" & @CRLF & @CRLF & $ContentSQLfile) ExitLoop EndIf $iOffset = @extended For $i = 0 To UBound($aArray) - 1 MsgBox(0, "RegExp Test with Option 1 - " & $i, $aArray[$i]) Next WEnd EndFunc ;==>_Start Func _SetTMPsql() Local $tmpSQLContent = "" $tmpSQLContent &= "USE [Master]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "CREATE DATABASE [Sales] ON PRIMARY " & @CRLF $tmpSQLContent &= "( NAME = N’Sales’, FILENAME = N’\FSASQLDBSales.mdf’ , " & @CRLF $tmpSQLContent &= " SIZE = 2GB , MAXSIZE = 8GB, FILEGROWTH = 1GB )" & @CRLF $tmpSQLContent &= "LOG ON " & @CRLF $tmpSQLContent &= "( NAME = N’Sales_log’, FILENAME = N’\FSASQLDBSales_log.ldf’ , " & @CRLF $tmpSQLContent &= " SIZE = 1GB , MAXSIZE = 2GB , FILEGROWTH = 10%)" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "USE [Sales]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "-- Table Product" & @CRLF $tmpSQLContent &= "CREATE TABLE [dbo].[Product]" & @CRLF $tmpSQLContent &= "(" & @CRLF $tmpSQLContent &= " [ProductId] [uniqueidentifier] DEFAULT NEWID() NOT NULL," & @CRLF $tmpSQLContent &= " [ProductName] [nchar](50) NULL," & @CRLF $tmpSQLContent &= " [ProductDescription] [nchar](3000) NULL," & @CRLF $tmpSQLContent &= " [ProductPrice] MONEY NULL" & @CRLF $tmpSQLContent &= ") ON [PRIMARY]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "-- Table Sales" & @CRLF $tmpSQLContent &= "CREATE TABLE [dbo].[Sales]" & @CRLF $tmpSQLContent &= "( " & @CRLF $tmpSQLContent &= " [SaleId] [uniqueidentifier] DEFAULT NEWID() NOT NULL," & @CRLF $tmpSQLContent &= " [SaleName] [nchar](50) NULL," & @CRLF $tmpSQLContent &= " [SaleInfo] [nchar](3000) NULL," & @CRLF $tmpSQLContent &= " [SaleMoney] MONEY NULL" & @CRLF $tmpSQLContent &= ") ON [PRIMARY]" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "SET ANSI_NULLS ON" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "SET QUOTED_IDENTIFIER ON" & @CRLF $tmpSQLContent &= "GO" & @CRLF $tmpSQLContent &= "" & @CRLF $tmpSQLContent &= "-- The End" & @CRLF Local $hOpen = FileOpen($tmpSQLfile, 2 + 8 + 128) FileWrite($hOpen, $tmpSQLContent) Return FileClose($hOpen) EndFunc ;==>_SetTMPsql Func _OnExit() Exit FileDelete($tmpSQLfile) EndFunc ;==>_OnExit  
      mikell