How to accurately test code in Python?

I am trying to compare some custom C modules with the standard Python modules. For instance, I wanted to test if a random function in C could out-perform Pythons randint method.
I have tried using the timeit module, but I am curious if I am skewing my own results in any way.
import timeit
import ctypes
import random
my_test_lib = ctypes.cdll.LoadLibrary('/home/name/workspace/Testing/test.so')
crand_timer = timeit.Timer("crand()", "from __main__ import crand")
prand_timer = timeit.Timer("prand()", "from __main__ import prand")
def crand():
for i in range(10):
my_test_lib.get_random(1, 10)
def prand():
for i in range(10):
random.randint(1,10)
if __name__ == '__main__':
print crand_timer.timeit()
print prand_timer.timeit()
Just for kicks, here is the C code:
#include <stdlib.h>
#include <time.h>
#define TRUE 1
#define FALSE 0
static int randomized = FALSE;
void randomize(void)
srand(time(NULL));
randomized = TRUE;
/* returns a random number between base and max, inclusive */
int get_random(int base, int max)
if (randomized == FALSE){
randomize();
return rand() % (max - base + 1) + base;
I compiled the C code with O3. The results seem to indicated the C code is about 2.3 times faster than the Python randint method.
Am I skewing the results in any way? I have a large amount of C code to test. I will be integrating a bunch of low level C modules into a Python program I am going to build. I want to learn how to test efficiently before I start.
edit:
If anyone needs/wants/interested in knowing-- I plan to build a tile based game with multi-threaded procedural dungeon generator. I want to build the generator in C and make it as fast as possible.
Last edited by Google (2011-10-27 07:21:54)

Hi,
If you increase the samples (say loop 5000 times instead of 10), the answers will be better, but accurate benchmarking is really hard.
Have you seen The Computer Language Benchmarks Game. I find it interesting.
When it comes to compilation flags, -O2 vs -O3 is seldom the problem. It's hard to choose the best algorithm and it's hard to make it scale as intented.
Do you know of Big O notation? That could be helpful.
Good luck with the game and dungeon generator.

Similar Messages

  • How to accurately test if timezone data is updated?

    Dear Sir,
    I updated JRE 1.5.0_13 with the newly released tzupdater version. The output of the command:
    #java -jar tzupdater.jar -V
    tzupdater version 1.3.0-b01
    JRE time zone data version: tzdata2007h
    Embedded time zone data version: tzdata2007h
    Even through it shows that the tzdata used by JRE is updated, I was interested to know if there is any other method that can systematically find out if the timezone data is updated eg. By displaying the date of a country that uses DST whose details have been newly updated by tzupdate.
    Thank you for investing your precious time to read this message.
    With regards,
    Santhoshkumar.
    [email protected]

    I don't bother going online when I am using maps except when I am using the satellite map option.
    For the moment the best way to keep your map data up to date is do use Map Loader once every month or two, delete all map data and then reinstall whatever bits you want.
    Hopefully we will be able to check map status with the next Map Loader update.

  • How can I test the log in state from in side the Operator Interface code.

    From inside LabVIEW Full OI, I want to test if the operator logged in after the IApplicationMgr Start.
    Right after the IApplicationMgr ‘Start’ I have a loop that tests the IApplicationMgr ‘LoginLogoutRunning’ state and waits until the LoginLogout call back is done.
    I want to exit if the program if operator canceled the login and did not log in.
    I have tried “GetEngine” ref. From there get the “CurrentUser” ref but seems not to contain any information about the Current User.
    How can I test from my Operator Interface code logged in state of the application?
    Thanks
    Jim D.

    Try Engine.CurrentUserHasPrivilege
    For the string parameter 'privilegeName' enter Priv_UserLoggedIn or the string value "*".
    "Priv_UserLoggedIn–(Value: "*") Use this value with the Engine.CurrentUserHasPrivilege method to determine whether a user is logged in."
    Option 2: You could also setup a callback on application manager for UserChanged Event.  If the User is null then the login was canceled.  (see a copy of the help further down)
    From the teststand help for Engine.CurrentUserHasPrivilege method below...
    CurrentUserHasPrivilege Method
    Syntax
    Engine.CurrentUserHasPrivilege ( privilegeName)
    Return Value
    Boolean
    True if the current user has the privilege.
    Purpose
    Confirms whether the current user or any user group that the user is a member of has a specific privilege.
    Remarks
    Returns True when the privilege property is True, when the privilege property of any group that contains the privilege is True, or when privilege checking is disabled, StationOptions.EnableUserPrivilegeChecking is False. If privilege checking is disabled but StationOptions.RequireUserLogin is True, this function returns True only if there is a user currently logged on.
    Parameters
    privilegeName As String
    [In] Specifies the name of the privilege to check. You can specify the name of any privilege property. You can specify the full privilege path in the user privileges property tree, for example, Debug.RunSelectedSteps, or you can specify the base privilege name, RunSelectedSteps. If you specify only the base privilege name and more than one instance of the base privilege name exists, then the method returns the value of the first base privilege it finds with that name. Refer to UserPrivileges for more information.
    Teststand callback for UserChanged Event...
    UserChanged Event
    Syntax
    ControlName_UserChanged ( user)
    Applies To
    ApplicationMgr
    Purpose
    Occurs when the current user logged in changes.
    Remarks
    Use this event to update the parts of your user interface that depend on user permissions when the current user logged in changes.
    Parameters
    user As User
    [In] Current user. If this parameter is NULL, there is no user logged in.

  • How can i test if i'm in the EOF of my file text in applescript?

    hello
    i want to known how can i test my EOF of my file text or if i meet "Plan N°" when i read each linesdxhezdcxezkchcochzhejc
    my file text :
    Plan N°1
    94.64%
    MDF_280;;3050;1850;1
    piece;0;0;500;500;0;AAA
    piece;0;504;500;500;0;AAA
    piece;0;1008;500;500;0;AAA
    piece;0;1512;500;500;0;AAA
    piece;0;2016;500;500;0;AAA
    piece;0;2520;500;500;0;AAA
    chute;0;3024;26;500
    piece;504;0;500;500;0;AAA
    piece;504;504;500;500;0;AAA
    piece;504;1008;500;500;0;AAA
    piece;504;1512;500;500;0;AAA
    piece;504;2016;500;500;0;AAA
    piece;504;2520;500;500;0;AAA
    chute;504;3024;26;500
    piece;1008;0;500;500;0;AAA
    piece;1008;504;500;500;0;AAA
    piece;1008;1008;500;500;0;AAA
    piece;1008;1512;500;500;0;AAA
    piece;1008;2016;500;500;0;AAA
    piece;1008;2520;500;500;0;AAA
    chute;1008;3024;26;500
    piece;1512;0;700;300;1;BBB
    piece;1512;704;700;300;1;BBB
    piece;1512;1408;700;300;1;BBB
    piece;1512;2112;700;300;1;BBB
    chute;1512;2816;234;300
    chute;1816;0;3050;34
    Plan N°2
    93.58%
    MDF_280;;3050;1850;1
    piece;0;0;300;700;0;BBB
    piece;0;304;300;700;0;BBB
    piece;0;608;300;700;0;BBB
    i want test
    i : line 1 ok next
    i <- 94... ok -< next
    if i == MDF_280 => loop (exit while EOF or when i == Plan N°)
    do ....
    end loop
    soory but i'm novice in apple script
    and i'm french
    i need to improve my english
    this is my applescript
    repeat with l in lesLignes
    if (l as text) starts with "MDF_280" then
    while ???? (!= EOF or "MDF_280") do ....
    if (l as text) starts with "piece" then .....
    end if
    end if
    end repeat
    THANKS

    property sString01 : "Plan N" -- String to search for.
    property sString02 : "MDF_280" -- String to search for.
    set uFile to (choose file) -- Select file to process.
    set tText to read uFile -- Read contents of selected file.
    repeat -- Cycle through contents of 'tText'.
    set {offset01, offset02} to {offset of sString01 in tText, offset of sString02 in tText} -- Obtain offset locations of 'sString01' and 'sString02'.
    if (offset01 = 0) then exit repeat -- If 'sString01' does not exist, exit repeat loop.
    -- Adjust content of 'tText' as to position of 'offset02' relative to 'offset01'.
    if (offset02 > offset01) then set tText to get (characters (offset02 + (count sString02)) through (count tText) of tText) as string
    set offset01 to (offset of sString01 in tText) - 1 -- Obtain next offset of 'String01'.
    if (offset01 < 1) then set offset01 to (count tText) -- Correct 'offset01' to obtain remaining contents of 'tText'.
    set tmpText to get (characters 1 through offset01 of tText) as string -- Obtain subset content of 'tText' - between 'sString02' and next 'sString01', of end of 'tText'.
    display dialog tmpText -- Display obtain subset of content of 'tText'.
    end repeat
    Since you posted 'how can i read a file text by applescript', and have not replied to others posts; nor marked any reply as 'answered' or even 'helpful'; and, I anticipate you creating a new post asking how to incorporate one of the 'how can i read a file text by applescript' replies into the above (or similar) code - a revised version of 'how can i read a file text by applescript' incorporated within the above code is provided below.
    property sString01 : "Plan N" -- String to search for.
    property sString02 : "MDF_280" -- String to search for.
    property sString03 : "piece" -- String to search for.
    property sString04 : "chute" -- String to search for.
    set uFile to (choose file) -- Select file to process.
    set tText to read uFile -- Read contents of selected file.
    repeat -- Cycle through contents of 'tText'.
    set {offset01, offset02} to {offset of sString01 in tText, offset of sString02 in tText} -- Obtain offset locations of 'sString01' and 'sString02'.
    if (offset01 = 0) then exit repeat -- If 'sString01' does not exist, then exit the repeat loop.
    -- Adjust content of 'tText' as to position of 'offset02' relative to 'offset01'.
    if (offset02 > offset01) then set tText to get (characters (offset02 + (count sString02)) through (count tText) of tText) as string
    set offset01 to (offset of sString01 in tText) - 1 -- Obtain next offset of 'String01'.
    if (offset01 < 1) then set offset01 to (count tText) -- Correct 'offset01' to obtain remaining contents of 'tText'.
    set tmpText to get (characters 1 through offset01 of tText) as string -- Obtain subset content of 'tText' - between 'sString02' and next 'sString01', of end of 'tText'.
    set tPars to paragraphs of tmpText -- Obtain list of 'piece' entries.
    repeat with i in tPars -- Cycle through list.
    if (i begins with sString03) then
    set {var01, var02, var03, var04, var05, var06} to my handle_List(i) -- Obtain individual values.
    -- Your code here.
    display dialog ("Piece: " & var01 & " ... " & var02 & " ... " & var03 & " ... " & var04 & " ... " & var05 & " ... " & var06) -- Code sample.
    else if (i begins with sString04) then
    set {var01, var02, var03, var04} to my handle_List(i)
    -- Your code here.
    display dialog ("Chute: " & var01 & " ... " & var02 & " ... " & var03 & " ... " & var04) -- Code sample.
    end if
    end repeat
    end repeat
    on handle_List(localList) -- Extract values, from each line of data, and place into a list.
    set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ";"}
    set tItems to text items 2 through -1 of localList
    set AppleScript's text item delimiters to oAStid
    return tItems -- Return a list of values.
    end handle_List

  • How can i test my vpn connection?

    so recently i decided to test if ver 1.3.0.3 of the quickvpn client would work better with the 1.3.0.5 rvs4000 firmware. i loaded quickvpn to an xp pro computer (freshly built, i might add) and got to work. in order to test the connection, i attempted to piggy back off an unsecured wireless network. this network is on the same ISP network as i am.
    i use dynamic DNS, and the unsecured wireless network could resolve my IP correctly, but for some reason i couldnt connect to my home network from the unsecured network. my router is set to respond to lan requests, but i couldnt ping it. my router passes HTTP traffic to a computer in my network, but i couldnt bring up the webpage. finally, my router responds with the router config page over port 443, and i couldnt bring that up.
    so i used my ISP's dialup service to test. initially, as always, i had a million problems with the vpn client. systematically, i tried to resolve the issues. i installed the patch in the readme for quickvpn. i checked log files to see where stuff was failing. eventually, i could connect to the VPN, but would get that "remote gateway is not responding" crap. i know of a (poor) workaround for this which allows you to "finalize" the connection, but that workaround doesnt allow you to ping around in your network. sometime later, after randomly messing with settings, the tunnel would connect without the workaround. i have no idea what "fixed" this.
    despite all this, my 28.8Kbps connection wouldnt allow me to do anything meaningful on my network. i couldnt connect to the router or to a server of mine (http or fileshare). the only thing i could do was ping internal devices. other requests seemed to "hang" rather than timeout or do anything more concrete. basically, i gave up on testing using dialup, even though my router and the client software confirm a good connection. but i still wasnt convinced.
    next, i figured i could create some type of "DMZ" on my network by placing a switch between my ISP's modem and my router. im not a cisco network professional by any means, but im pretty familiar with networking on a above-average level. that said, despite my best, i couldnt get my quickvpn computer to see my router from the "DMZ".
    finally, i figured i could just test the tunnel while directly connected to my network's lan. bad idea. everything seems to go okay until it locks up on "activating policy". rebooting or otherwise ending the negotiation ends in the computer being unable to do anything anymore. when i try to ping anything, i get "negotiating ip security" ad infinitum. the only way i could fix this was by doing a system restore.
    so here's the question: how can i test my quickvpn connection?why can't i just tunnel through my network? and before you scream that you can't, thegreenbow vpn client has NO PROBLEM connecting to my rvs4000 while connected to my own network.

    Hi Aaron,
    I am going exactly the same thing as you however, I had my cousin buy and install a RVS4000 at his house in Australia.
    I access it from the USA so that I can help manage his Local Area Network, he is just not technical..
    I setup a DDNS client on his RVS4000 so that I can always get to his Router via a domain name rather than a IP address.
    I noticed that you didn't mention anything regarding importing client certificate into the directory of the VPN client on your PC.
    I also noticed I disabled IPSec passthrough on the router in Australia, see the pictures below, not sure why, but the VPN client is working.
    I also did not setup any gateway to gateway VPN tunnels, Only added a client , exported certificate as per the manual, See the last screen capture below.
    You will also note if you view the screen captures that my cousins RVS4000 has not been upgraded to the new code.Is there a reason for that...not really...he's just a user, not really technical.  Also note I have not added any VPN tunnels on my RVS4000.
    I have a reasonably reliable connection between the USA and Australia. I didn;t have to play with any other options, just add users to the VPN client database.
    Your description of the working environment of your PC is missing details on the version of XP, so i will mention the following taken from the software release notes of the RVS4000 ;
    There is a known issue with Windows XP SP2 Firewall.
    ICMP packets are always dropped by the firewall when the firewall is enabled.
    This issue causes the QuickVPN client to be unable to establish a tunnel with the remote QuickVPN server successfully.
    Microsoft has released a patch to fix this issue, which you can get from:
    http://support.microsoft.com/kb/889527/en-us
    After you install the patch, the issue should be resolved. You can also fix this issue by upgrading Windows XP to SP3.
    You cannot plug a PC on the same network as the router for testing, they must be on dissimilar WAN  networks for testing purposes.
    Your remote  PC VPN client will not be allocated a IP address in the RVS4000's network, hosts behind the RVS4000 will still respond to pings, as they direct the responses to their default gateway, the RVS4000.
    The thegreenbow VPN client is a distracter at this point costing 50 something EURO  for a license, lets try to get the quickVPN client working !
    So, if you still wish try the following, firstly make sure your XP has been upgraded to  SP3;
    1.  If you upgraded your router to the new version of code, then reset your router to factory defaults to re-initialize your router, yes start again.
    2.  Export the VPN client certificate to the directory that contains the VPN client.  In my case it is;
               "C:\Program Files\Cisco Small Business\QuickVPN Client"
    3.  add a VPN client account to the router
    4.  Use port 60443 from the quickVPN client. and try  VPNing to the router.
    5  hmmm, if the client still fails try disabling IPSec Passthrough on the router for grins and giggles.
    If this fails, call the SBSC at the following location for resolution;
    http://www.cisco.com/en/US/support/tsd_cisco_small_business_support_center_contacts.html
    good luck ...regards Dave

  • How can i test the boolean state of button action?

    Hello,
    in as2.0, how can i test the boolean value if a button was
    pressed or not?
    I have a simple function im trying to work with like this...
    button_btn.onRelease = function (success:Boolean) {
    if (success) {
    trace("we pressed the button - value is true");
    else {
    trace("value is false");
    working with booleans in this way is new to me - any pointers
    will do - thanks!

    Well, I'm not really that familiar with using video in flash,
    but from what I understand of what you are going for, these are my
    suggestions:
    If the code within your button has scope of the variable you
    are testing for:
    _global.myInfoObject;
    button_btn.onRelease = function(){
    if( myInfoObject.code == (value your are testing for) ) {
    trace("value is correct);
    } else {
    trace ("value incorrect");
    if you aren't in scope you can always maybe forward the
    onRelease function to some handler that is in scope:
    var myInfoObject;
    var release = function(){
    //to do code here;
    button_btn.onRelease = release;
    I hope some of these ideas help a little.
    You can always send your .fla to my email at
    [email protected] and I'll take a look at it.

  • How To Use PMD Code Checker in Jdeveloper 9

    Hai
    Please Any one tell me How To Use PMD Code Checker in Jdeveloper 9
    Thanks

    Timo
    You Checking file with PMD in **Jdeveloper** possible in jdev 10.1.3
    for the earlier versions you told me to use command prompt
    that's why when iam checking my file with pmd the output is like the below:
    D:\jdev9\OAF\jdevbin\jdev\lib\ext\pmd-bin-4.2.5\pmd-4.2.5\java14\bin>pmd D:/satyas/Test.java xml rulesets/unusedcode.xml -debug
    In JDK 1.5 mode
    Loaded rule UnusedPrivateMethod
    Loaded rule UnusedPrivateField
    Loaded rule UnusedFormalParameter
    Loaded rule UnusedLocalVariable
    Processing D:\satyas\Test.java
    Could not find class Test, due to: java.lang.ClassNotFoundException: Test
    <?xml version="1.0" encoding="UTF-8"?>
    <pmd version="4.2.5" timestamp="2010-08-24T19:02:07.019">
    <file name="D:\satyas\Test.java">
    <violation beginline="5" endline="5" begincolumn="22" endcolumn="22" rule="UnusedLocalVariable" ruleset="Unused Code Rules" class=
    "Test" method="main" variable="i" externalInfoUrl="http://pmd.sourceforge.net/rules/unusedcode.html#UnusedLocalVariable" priority=
    "3">
    Avoid unused local variables such as 'i'.
    </violation>
    <violation beginline="14" endline="14" begincolumn="23" endcolumn="32" rule="UnusedPrivateMethod" ruleset="Unused Code Rules" clas
    s="Test" method="myMethod" externalInfoUrl="http://pmd.sourceforge.net/rules/unusedcode.html#UnusedPrivateMethod" priority="3">
    Avoid unused private methods such as 'myMethod()'.
    </violation>
    </file>
    </pmd>

  • Test Code on iPad

    At my current job, we write a web based application that utilizes C#, .NET, Telerik HTML, and MySQL. One of our primary customers will be accessing the web app through the iPad. Is there any way to test code written in Visual Studio 2010 on the iPad without rolling the application out to production?
    To be clear, I don't need to write any code on the iPad. I essentially need a way to test my current code written in Visual Studio.
    Thanks.

    Sorry, but I'm not quite sure what you are trying to do. If you want to test a web application, why can you not just get an iPad, set up the web app on a test server, and go to the URL of that test system from the iPad's web browser?
    Perhaps someone else will understand better what you wish to do, but you may need to explain further your scenario and what and how you need to test.
    Regards.

  • How can I test IRIG-B'a accuracy using Labview

    We have a GPS source as reference, how can we test second GPS clock with IRIG-B output ?  Can we by using Labview ?

    Most timecode generators work by taking an external input (GPS, IRIG, PPS, or any of a number of other timecodes such as MILA, NASA36, IRIG A, etc) and outputting an on-time signal.
    The most common systems now use a GPS receiver to steer an oscillator to some fixed frequency (10MHz is a favorite) and then use that steered oscillator to generate the outputs.  The one PPS from a GPS receiver is not very smooth and jumps around easily a few hundred nano-seconds every PPS (at least they used to).
    Time codes are usually done by generating an on-time digital signal in which the rising edge of the frame bits is co-incident with the PPS timing.  The digital signal is then sent through some analog magic (op amps and whatever) which delays the output on time.
    In digital signals, the rising edge is considered on time, in analog it is the zero-crossing.
    Good systems will calibrate out the analog delay in the factory by moving back the on-time timing that is fed to the analog so that all on-time marks are co-incident.

  • How can I test (Abap) a session is from type RFC

    Hi ,
    How can I test (Abap) a session is from type RFC ? Field in SY tables ?

    He wants to know if it's possible to tell by the currently running code whether it was called via RFC.
    Transaction SM04 is able to tell about a user session if it is RFC or not... so by analyzing that code, it should be possible.

  • How create a DLL with module python?

    Hello,
    I am a beginner in TestStand,
    I would like to know, how create a DLL with module Python? because for create a sequence, we must own a DLL.
    Thank you for your answer
    Vincent
    Solved!
    Go to Solution.

    Hello,
    I would like use TestStand with Python module. So I believe, we must use a DLL for execute a test, I'm wrong because I can use .exe for realize a test.
    Now I know how use TestStand with Python module but I have a mistake. I wonder which is error 255?
    Whereas I use .exe in Language C, I have no error.
    Thank you for your anwser.
    Vincent
    Attachments:
    Setup_Test.jpg ‏244 KB
    Report.jpg ‏258 KB

  • How to execute javascript code in VBScript?

    I'd like to execute similar javascript code for some particular PDF files(parameters for pagenumber are quite different),such as:
    this.setPageLabels(0, [ "A", "", 3] );
    this.setPageLabels(1, [ "r", "", 1] );
    this.setPageLabels(16, [ "D", "", 1] );
    How to write the code in VBScript?
    Thanks in advance!
    P.S. I try to add code but end up with error messages
    =================================================================
    path = "E:\test.pdf"
    '//Write the first and last pagenumbers and label to a txt.
    set oWs = CreateObject ("Wscript.Shell")
    set fs = CreateObject("Scripting.FileSystemObject")
    oWs.run "Acrobat.exe"
    While not oWs.AppActivate("Adobe Acrobat") : Wscript.Sleep 1000 : Wend
    Set objArgs = WScript.Arguments
    if objArgs.Count = 1 then path = ObjArgs(0)
    Set gApp = CreateObject("AcroExch.App")
    Set AVDoc = CreateObject("AcroExch.AVDoc")
    If (AVDoc.Open(Path,"")) Then
    Set AVDoc = gApp.GetActiveDoc()
    Set PDDoc = AVDoc.GetPDDoc()
    Set JSO = PDDoc.GetJSObject
    '// Write Bookmark JS to a variable
    Ex = " var vTOC = """"; "&vbLF _
    & " var s = """"; "&vbLF _
    & " var i=0; "&vbLF _
    & " p = i+1; "&vbLF _
    & " vTOC += ( this.getPageLabel(i) +""|""); "&vbLF _
    & " i= this.numPages-1 ; "&vbLF _
    & " p = i+1; "&vbLF _
    & " vTOC += ( this.getPageLabel(i) +""|""+p+""|""); "
    ' // Execute the JavaScript
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
    AForm.Fields.ExecuteThisJavaScript EX
    ' // Write Bookmarks to CSV (PageNr;Level;Text)
    Set JSO = PDDoc.GetJSObject '//->renew JSO for some unknown reasons
    xf = jso.vToc
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate("about:blank")
    objIE.document.parentwindow.clipboardData.SetData "text", xf
    objIE.Quit
    CsvFN = left(path, InstrRev(path, ".")-1) &"_page.txt"
    set FL = fs.OpenTextFile(CsvFN, 2, true) '//-> 2=ForWriting
    xWr = split(xf,"|")
    for x=0 to UBound(xWr)
    FL.WriteLine xWr(x)
    next
    FL.Close
    Else
    MsgBox "Failed to Open: " & Path
    End If
    Set JSO = Nothing
    Set PDDoc = Nothing
    Set AVDoc = Nothing
    Set AForm = Nothing
    Set gApp = Nothing

    If I remember right, I wrote this script a while back to demonstrate how java script can be direct executed and how you can get back the results. Didn't I wrote a commentary to that?
    However the parts you need:
    ' // Write JS code from help file or whatever to a VBS variable:
    JsFromHelp = " this.setPageLabels(0, [ ""A"", """", 3] ); "&vbLF _
    & " this.setPageLabels(1, [ ""r"", """", 1] ); "&vbLF _
    & " this.setPageLabels(16, [ ""D"", """", 1] ); "
    ' // Execute the JavaScript
    Set AForm = CreateObject("AFormAut.App") 'from AFormAPI
    AForm.Fields.ExecuteThisJavaScript JsFromHelp
    From the rest keep only:
    end if
    set .. = nothing
    Untested, but should work - as far as you have a little bit more then only Reader.
    HTH, Reinhard

  • How to find bar codes and mails to send clients in smartforms

    HI friends,
        How to find bar codes in smartforms and also how to send mail to the client. I have developed one object in smartforms, but i don't know how to send maill to the client. Pls help me........................
    Thanks in Advance.
    Saradhi.

    Hi!
    Here is the code to send the Smartform to mail as PDF attachment.
    *& Report ZTEST_PDF_MAIL
    REPORT ZTEST_PDF_MAIL.
    Internal Table declarations
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = 'ZTEST'
    IMPORTING
    FM_NAME = V_FORM_NAME
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
    CALL FUNCTION V_FORM_NAME
    EXPORTING
    CONTROL_PARAMETERS = W_CTRLOP
    OUTPUT_OPTIONS = W_COMPOP
    USER_SETTINGS = 'X'
    IMPORTING
    JOB_OUTPUT_INFO = W_RETURN
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I_OTF[] = W_RETURN-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    IMPORTING
    BIN_FILESIZE = V_LEN_IN
    TABLES
    OTF = I_OTF
    LINES = I_TLINE
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    OTHERS = 4.
    IF SY-SUBRC <> 0.
    ENDIF.
    LOOP AT I_TLINE.
    TRANSLATE I_TLINE USING '~'.
    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
    I_RECORD = WA_BUFFER.
    APPEND I_RECORD.
    SHIFT WA_BUFFER LEFT BY 255 PLACES.
    IF WA_BUFFER IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN[] = I_RECORD[].
    Create Message Body Title and Description
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    Attachment (pdf-Attachment)
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = '[email protected]'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    COMMIT_WORK = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    IF SY-SUBRC <> 0.
    WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
    WRITE:/ 'Mail sent'.
    ENDIF.
    If you want to send some text as Body of the Mail then follow this once
    when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
    1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
    2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
    I_OBJPACK-TRANSF_BIN = ' '.
    I_OBJPACK-HEAD_START = 000000000000001.
    I_OBJPACK-HEAD_NUM = 000000000000001.
    I_OBJPACK-BODY_START = 000000000000002
    I_OBJPACK-BODY_NUM = 000000000000010.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    append I_OBJPACK-.
    by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    Regards
    Tamá

  • How do I test a private function with FlexUnit4

    Hi,
    How do I (If it's possible) test a private function of a class i want to test.
    I really don't want to change the function to public only for testing it.
    Any suggestions

    [2 cents better late than never?]
    Instead of "private" to "protected", we tend to use "internal".  Since our tests live in a "test" directory (at sibling-level to "src") and package structure is replicated, tests can access "internal" resources (methods and members).
    If one follows this pattern, it leads to 2 curious consequences:
    one can spot definitely-untested methods by their "private"-ness =
    good (well tested) code never uses "private" =
    I tend to agree with the original author, (sorry mlabriola -- your work is awesome and I never thought I'd find myself disagreeing with you but...) one does need to test private resources.  Java allows one to work around the situation with the horrific kludge of using reflection to access private members.  Sadly / luckily I'm insufficiently au fait with Flex's version to coax something similar.
    Sadly, I'm not sure what alternatives one could have: perhaps a flag that tells the compiler/runtime whether to enforce "private"-ness which one activates during test?
    2c, R.

  • How to know the code error diagnostic hardware (AHT) ?

    I want konw
    How to know the code error when do it Apple Hardware Test.
    Anybody have note the code error (AHT)
    Thank you

    Does this help: http://reviews.cnet.com/8301-13727_7-57352461-263/how-to-invoke-and-interpret-th e-apple-hardware-tests/ ?

Maybe you are looking for

  • Report on Storage Location wise

    Hi Gurus Please let me know if any report exists for the below requirement Input parameters:  Accounting Period                             Plant Output Result:   Material Number                          Materil Description                          S

  • Solution of Inspection Lot creation

    Hi expert, I am newbie in QM module.  I have some question for solution in QM inspetion. sample Production Order created order for 100,000 pcs and goods receipt batch split(2,000 per batch), 50 batch per production order. Then in QM generate 50 inspe

  • VESA adapter for 24" Aluminum iMac, doesn't fit

    I just got my VESA adapter for my new 24" iMac and the mount adapter doesn't fit onto the flange. I got the flange to attach to the iMac fine but the bolt holes on the flange don't line up with the mount adapter they are off my about 1/4". Did I miss

  • Default value for depreciation area

    While running repeat run depreciation, i am facing following error: "Depreciation area 90 in company code IN00 does not have default values" Let me know abt what value it is asking & how to solve the problem Depreciation area 90 is a revaluation depr

  • Copying an object from one vector into another

    I need to get a specified object from vector 1 to vector 2 so its no longer in vector 1 I've created the two vectors, I know how to access, remove, add elements to a vector using the relevant methods Do you use the remove method, then add?