Sign in to follow this  
Followers 0
Xand3r

StringFormat bug?

10 posts in this topic

Here are some examples...

$ss="test"
MsgBox(0 , "" , StringFormat("add % done",$ss))
MsgBox(0 , "" , StringFormat("add %",$ss))
MsgBox(0 , "" , StringFormat("add % n done",$ss))

the output will be:

add 0one
add add
autoit crash(not error... crash)

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites



Here are some examples...

$ss="test"
MsgBox(0 , "" , StringFormat("add % done",$ss))
MsgBox(0 , "" , StringFormat("add %",$ss))
MsgBox(0 , "" , StringFormat("add % n done",$ss))oÝ÷ ÚØ^¢ëiºÜ"VÞr^i×t¢wuÖu«­¢+­«!ãIèµê뢷+jÈx×÷(uïêº^2(!·§¶Ú%¢.¥+kx¢¹¶)íè^(¶­Ê®±è­rëyËeÈÚ-i» jëh×6$ss="test"
MsgBox(0 , "" , StringFormat("add %s done",$ss))
MsgBox(0 , "" , StringFormat("add %s",$ss))
MsgBox(0 , "" , StringFormat("add %s n done",$ss))

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Even tho it was used improperly it should still not crash Autoit. I would think it would throw an error tho.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

If AutoIt is using the low level format function, then it would have to perform it's own validation of the input format before calling the format function.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

These kind of thing is called logical errors and not the function, nor the compiler need to assume or handle it differently. If the compiler for example is able to see:

int nNum = 5/0;

then it can output to the console an error or a warning message depending on the user preferred restrictions. But if it's something like:

int main()
{
    int nNum1, nNum2;
    float fRes;
    cout << "Enter 2 numbers to divide separated by space: ";
    cin >> nNum1 >> nNum2;
    fRes = nNum1 / nNum2;
    cout << "The result is: " << fRes;
   
    return 0;
}

you'll get a run-time error because you didn't check the divisor is not 0. For that reason there is the if(...) ... else(...)... structure or the better C++ or Microsoft SEH structure __try(...)...__except(...)/__finally(...)...

Heh, it's not necessary in AutoIt but it'll be nice to have __try....__finally structure, otherwise, If...EndIf is enough but the scripter has to be more cautious.

Edited by Authenticity

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

AutoIt should never crash, period (DllCall() excluded). That right there is enough to say there is a bug.

Edit: Just to be more clear. There should never be a situation where a crash happens. AutoIt should not crash with the the error dialog from Windows unless it's from DllCall(). AutoIt should never throw an AutoIt error for any run-time event except out-of-memory. AutoIt should not throw an error for properly written script code.

Edited by Valik

Share this post


Link to post
Share on other sites

It's strange, it's crashed only(?) when %n used and there is Type/Precision character in the format after that:

StringFormat("%n f", 1)

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

We know why it happens. We have a private thread where it's discussed.

Share this post


Link to post
Share on other sites

Might want to look up StringFormat in the help so that you use it correctly. Not a bug.

yeah... lol i know how to use it... but it was just a typo in a 4000 line script and the stringformat had about 30 vars...

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

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
Sign in to follow this  
Followers 0