Jump to content

Recommended Posts

Posted (edited)

Func PKANSCORE()
    $pkanscore1=IniRead("OPT.INI","ANSWERS","SCORE","0")
    $pkanscore2=StringSplit($pkanscore1,"")
    GUICreate("Japanese basic training: Kana training",300,250)
    Opt("GuiCoordMode",0)
    GUICtrlCreatePic("Data\Graphics\MGO1.bmp",25,25,250,100)
    GUICtrlCreateLabel("Congratulations! Your score is...",0,120,250,20)
    GUICtrlCreatePic("Data\Graphics\MGN"&$pkanscore2[5]&".bmp",0,150,50,50)
    GUICtrlCreatePic("Data\Graphics\MGN"&$pkanscore2[4]&".bmp",25,0,50,50)
    GUICtrlCreatePic("Data\Graphics\MGN"&$pkanscore2[3]&".bmp",25,0,50,50)
    GUICtrlCreatePic("Data\Graphics\MGN"&$pkanscore2[2]&".bmp",25,0,50,50)
    GUICtrlCreatePic("Data\Graphics\MGN"&$pkanscore2[1]&".bmp",25,0,50,50)
    GUISetState()

    While 1=1
        $pkansc=GUIGetMsg()
        Select
            case $pkansc=$GUI_EVENT_CLOSE
                GUIDelete()
                GUIMainGui()
        EndSelect
        Sleep(5000)
        GUIDelete()
        GUIMainGui()
    WEnd
EndFunc

in this piece of code i need $pkanscore[1] to $pkanscore[5] (or infinity) be 0'ed in advance so they could show MGN0.bmp

i can't do it myself. i tried. help?

Edited by GodForsakenSoul
Posted

For $iCount = 1 to UBound($pkanscore,1)
 $pkanscore[$iCount1] = 0
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

It's good practice to use a for loop to assign any value to multiple elements in an array.

It's quicker, looks nicer, and uses less code.

Posted

In AutoIt you set the size of an array when you define it

Global $Array[10]

When you don't know how many elements the array will have at the end then use

ReDim $Array[Ubound($Array,1)+1]

to extend the array every time you add an element.

How do you want to fill your array?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

my array is supposed to have 5 elements (not including [0]) tops, assuming some weirdo DOES get to 99999.

i'm using stringsplit to split the numbers to show a nice combo of pics instead of a fugly label.

however, i'm testing it (atm) on 10. so that's only two places filled. i want to have the other three filled with zeroes, 00010 <-like so.

Posted (edited)

This should work. It extends the array to 5 elements and fills the "new" elements with "0".

#include <array.au3>

$pkanscore1 = 123
$pkanscore2=StringSplit($pkanscore1,"")
ReDim $pkanscore2[6]
If $pkanscore2[0] < 5 Then
    For $iCount1 = $pkanscore2[0]+1 To 5
        $pkanscore2[$iCount1] = 0
    Next
    $pkanscore2[0] = 5
EndIf
_ArrayDisplay($pkanscore2)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted (edited)

thanks! works like a charm. now i have a new problem. the numbers don't show.

i AM working on solving the problem, however, if anyone find the problem before me, please report ;)

ok! (retarded) idea #1: check if $pkanscore[1] has anything in it. if not, set it as 0.

problem is that i don't know how to say

if $pkanscore[1]=NOTHING then

Edited by GodForsakenSoul

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
×
×
  • Create New...