Sign in to follow this  
Followers 0
Thlitmi

[SOLVED] Weird half-working deleting from array.....

4 posts in this topic

#1 ·  Posted (edited)

#include <file.au3>
$file=""
_FileReadToArray("q3config.cfg", $file)
Dim $qcommands[20]
$qcommands[0]=20
$qcommands[1]="bind F1 "
$qcommands[2]="bind F2 "
$qcommands[3]="bind F3 "
$qcommands[4]="bind F4 "
$qcommands[5]="bind F5 "
$qcommands[6]="bind F6 "
$qcommands[7]="bind F7 "
$qcommands[8]="bind F8 "
$qcommands[9]="bind F9 "
$qcommands[10]="bind F10 "
$qcommands[11]="bind F11 "
$qcommands[12]="bind F12 "
$qcommands[13]="seta r_customheight"
$qcommands[14]="seta r_customwidth"
$qcommands[15]="seta r_fullscreen"
$qcommands[16]="seta com_maxfps"
$qcommands[17]="seta cl_autoRecordDemo "
$qcommands[18]="seta cl_aviFrameRate"
$qcommands[19]="seta s_useOpenAL"


#include <Array.au3>

; Setting number parts

; Return index numbers of values that are found in array
Func searchIndexesOfWordsInArray($array,$arrayOfWhatSearch)
 Dim $srch[_ArrayMax($arrayOfWhatSearch)]
 $p=1
 While $p<$arrayOfWhatSearch[0]
$srch[$p]=_ArraySearch($array, $arrayOfWhatSearch[$p],0,0,0,1)
    $p=$p+1
 WEnd
$srch[0]=UBound($arrayOfWhatSearch)
    Return $srch
EndFunc

$srch=searchIndexesOfWordsInArray($file,$qcommands)

$p=1
While $p<UBound($srch)
    if $srch[$p]=-1  Then
        ;
        ;
        ;
        ;
        ;
        ;
        ; This should delte all numbers -1 !
    _ArrayDelete($srch, $p)
    ;
    ;
    ;
    ;
    EndIf
    $p=$p+1
    WEnd

_ArrayDisplay($srch)

This should delete all values "-1"

There stays two of them (

Array srch contains 5 values that are "-1"

And the loop should delete all of them.... but maybe it is broken......

The only reason I could have to explain is, that "-1" is not equal to "-1"

But every matemathic says that, this is false

Does the loop skip it ? I do not think so.

Is my function made with some error ? No because changing $srch in to $srch=StringSplit("20 44 45 46 47 48 49 -1 -1 -1 -1 -1 50 200 201 202 280 299 300 326"," ") does not help.

This is so easy code........... Why do I have such a problems............

Thanks for help :graduated:

//edit:

/

I forgot to uplad file, and I can not find it in edit options

//edit2:

/

File: q3config.cfg

// generated by quake, do not modify
unbindall
bind TAB "+scores"
bind ENTER "+button3"
bind ESCAPE "togglemenu"
bind + "sizeup"
bind - "sizedown"
bind 0 "weapon 10"
bind 1 "weapon 1"
bind 2 "weapon 2"
bind 3 "weapnext"
bind 4 "weapprev"
bind 5 "weapon 5"
bind 6 "weapon 6"
bind 7 "weapon 7"
bind 8 "weapon 8"
bind 9 "weapon 9"
bind = "sizeup"
bind [ "weapon 9"
bind \ "weapon 3"
bind ] "weapon 4"
bind _ "sizedown"
bind ` "toggleconsole"
bind a "+moveleft"
bind d "+moveright"
bind e "+button3"
bind f "+button2"
bind s "+back"
bind t "messagemode2"
bind w "+forward"
bind y "messagemode"
bind ~ "toggleconsole"
bind PAUSE "pause"
bind UPARROW "+forward"
bind DOWNARROW "+back"
bind LEFTARROW "+moveleft"
bind RIGHTARROW "+moveright"
bind ALT "+strafe"
bind CTRL "+movedown"
bind SHIFT "+movedown"
bind DEL "+lookdown"
bind PGDN "+lookup"
bind END "centerview"
bind F1 "vote yes"
bind F2 "vote no"
bind F3 "ui_teamorders"
bind F4 "g_syncronousClients 1"
bind F5 "record"
bind F6 "stoprecord"
bind F12 "screenshot"
bind MOUSE1 "+attack"
bind MOUSE2 "+moveup"
bind MOUSE3 "+zoom"
bind MWHEELDOWN "weapprev"
bind MWHEELUP "weapnext"
seta cg_trueLightning "0.0"
seta cg_oldPlasma "1"
seta cg_oldRocket "1"
seta cg_oldRail "1"
seta ui_bigFont "0.4"
seta ui_smallFont "0.25"
seta cg_noProjectileTrail "0"
seta cg_noTaunt "0"
seta cg_smoothClients "0"
seta cg_scorePlums "1"
seta cg_cameraOrbitDelay "50"
seta cg_noVoiceText "0"
seta cg_noVoiceChats "0"
seta cg_teamChatsOnly "0"
seta cg_drawFriend "1"
seta cg_drawTeamOverlay "0"
seta cg_deferPlayers "1"
seta cg_forceModel "0"
seta cg_teamChatHeight "0"
seta cg_teamChatTime "3000"
seta cg_bobroll "0.002"
seta cg_bobpitch "0.002"
seta cg_bobup "0.005"
seta cg_runroll "0.005"
seta cg_runpitch "0.002"
seta cg_railTrailTime "400"
seta cg_lagometer "1"
seta cg_simpleItems "0"
seta cg_crosshairY "0"
seta cg_crosshairX "0"
seta cg_crosshairHealth "1"
seta cg_crosshairSize "24"
seta cg_drawRewards "1"
seta cg_drawAttacker "1"
seta cg_drawAmmoWarning "1"
seta cg_drawIcons "1"
seta cg_draw3dIcons "1"
seta cg_drawSnapshot "0"
seta cg_drawFPS "0"
seta cg_drawTimer "0"
seta cg_drawStatus "1"
seta cg_draw2D "1"
seta cg_gibs "1"
seta cg_stereoSeparation "0"
seta cg_fov "90"
seta cg_zoomfov "22.5"
seta cg_drawGun "1"
seta cg_shadows "1"
seta g_allowVote "1"
seta g_filterBan "1"
seta g_banIPs ""
seta g_logSync "0"
seta g_log "games.log"
seta g_warmup "20"
seta g_teamForceBalance "0"
seta g_teamAutoJoin "0"
seta g_friendlyFire "1"
seta capturelimit "0"
seta g_maxGameClients "0"
seta cm_playerCurveClip "1"
seta net_socksPassword ""
seta net_socksUsername ""
seta net_socksPort "1080"
seta net_socksServer ""
seta net_socksEnabled "0"
seta net_noipx "0"
seta net_noudp "0"
seta server16 ""
seta server15 ""
seta server14 ""
seta server13 ""
seta server12 ""
seta server11 ""
seta server10 ""
seta server9 ""
seta server8 ""
seta server7 ""
seta server6 ""
seta server5 ""
seta server4 ""
seta server3 ""
seta server2 ""
seta server1 ""
seta cg_marks "0"
seta cg_drawCrosshairNames "0"
seta cg_drawCrosshair "9"
seta cg_brassTime "1250"
seta ui_browserShowEmpty "1"
seta ui_browserShowFull "1"
seta ui_browserSortKey "3"
seta ui_browserGameType "0"
seta ui_browserMaster "2"
seta g_spSkill "1"
seta g_spVideos "\tier8\1\tier7\1\tier6\1\tier5\1\tier4\1\tier3\1\tier2\1\tier1\1"
seta g_spAwards "\a4\1029\a2\141\a1\42\a5\23\a0\7\a3\1"
seta g_spScores5 "\l0\1\l2\2\l24\2"
seta g_spScores4 "\l0\1\l20\3\l18\2\l21\1\l6\2\l5\1\l4\1\l1\1\l2\1\l3\2"
seta g_spScores3 "\l0\1\l2\1\l17\1\l22\1\l13\1\l11\1\l10\1\l6\1"
seta g_spScores2 ""
seta g_spScores1 "\l5\1\l6\1\l13\1\l25\1\l23\1\l22\1\l21\1\l20\1\l19\1\l18\1\l17\1\l16\1\l15\1\l14\1\l12\1\l10\2\l9\1\l8\1\l7\1\l0\1\l3\1\l24\1"
seta ui_ctf_friendly "0"
seta ui_ctf_timelimit "0"
seta ui_ctf_capturelimit "8"
seta ui_team_friendly "1"
seta ui_team_timelimit "0"
seta ui_team_fraglimit "100"
seta ui_tourney_timelimit "15"
seta ui_tourney_fraglimit "0"
seta ui_ffa_timelimit "0"
seta ui_ffa_fraglimit "40"
seta com_soundMegs "8"
seta s_mixPreStep "0.05"
seta s_mixahead "0.2"
seta s_khz "11"
seta s_doppler "1"
seta s_separation "0.5"
seta s_musicvolume "0.537500"
seta s_volume "0.850000"
seta vid_ypos "14"
seta vid_xpos "1"
seta r_lastValidRenderer "GeForce FX 5500/PCI/SSE/3DNOW!"
seta r_primitives "0"
seta r_railSegmentLength "32"
seta r_railCoreWidth "6"
seta r_railWidth "16"
seta r_facePlaneCull "1"
seta r_gamma "1"
seta r_swapInterval "0"
seta r_textureMode "GL_LINEAR_MIPMAP_LINEAR"
seta r_finish "0"
seta r_dlightBacks "1"
seta r_dynamiclight "0"
seta r_drawSun "0"
seta r_fastsky "0"
seta r_ignoreGLErrors "1"
seta r_flares "0"
seta r_lodbias "0"
seta r_lodCurveError "250"
seta r_ignoreFastPath "1"
seta r_smp "0"
seta r_subdivisions "4"
seta r_vertexLight "1"
seta r_simpleMipMaps "1"
seta r_customaspect "1"
seta r_customheight "1024"
seta r_customwidth "1600"
seta r_fullscreen "1"
seta r_mode "6"
seta r_ignorehwgamma "0"
seta r_overBrightBits "1"
seta r_depthbits "0"
seta r_stencilbits "0"
seta r_stereo "0"
seta r_colorbits "0"
seta r_texturebits "32"
seta r_detailtextures "1"
seta r_roundImagesDown "1"
seta r_picmip "0"
seta r_ext_texture_env_add "1"
seta r_ext_compiled_vertex_array "1"
seta r_ext_multitexture "1"
seta r_ext_gamma_control "1"
seta r_ext_compressed_textures "0"
seta r_allowExtensions "1"
seta r_glDriver "libGL.so.1"
seta cg_viewsize "100"
seta cg_predictItems "1"
seta cl_anonymous "0"
seta sex "male"
seta handicap "100"
seta color2 "5"
seta color1 "4"
seta g_blueTeam ""
seta g_redTeam ""
seta team_headmodel "uriel/blue"
seta team_model "uriel/blue"
seta headmodel "uriel/blue"
seta model "uriel/blue"
seta snaps "20"
seta rate "25000"
seta name "Doomig"
seta cl_maxPing "800"
seta m_filter "1"
seta m_side "0.25"
seta m_forward "0.25"
seta m_yaw "0.022"
seta m_pitch "0.022000"
seta cg_autoswitch "0"
seta r_inGameVideo "1"
seta cl_allowDownload "1"
seta cl_freelook "1"
seta cl_mouseAccel "0"
seta sensitivity "7.600000"
seta cl_run "1"
seta cl_packetdup "1"
seta cl_maxpackets "30"
seta cl_pitchspeed "140"
seta cl_yawspeed "140"
seta sv_master5 ""
seta sv_master4 ""
seta sv_master3 ""
seta sv_master2 ""
seta sv_floodProtect "1"
seta sv_maxPing "0"
seta sv_minPing "0"
seta sv_maxRate "0"
seta sv_maxclients "8"
seta sv_hostname "noname"
seta timelimit "0"
seta fraglimit "15"
seta dmflags "0"
seta vm_ui "2"
seta vm_game "2"
seta vm_cgame "2"
seta joy_threshold "0.150000"
seta in_joyBallScale "0.02"
seta in_joystick "0"
seta in_mouse "1"
seta in_mididevice "0"
seta in_midichannel "1"
seta in_midiport "1"
seta in_midi "0"
seta com_introplayed "1"
seta com_blood "1"
seta com_maxfps "999"
seta com_hunkMegs "56"
seta cl_timeNudge "0"
seta cg_delag "1"
seta cg_cmdTimeNudge "0"
seta cg_projectileNudge "0"
seta cg_optimizePrediction "1"
seta in_logitechbug "0"
seta sv_punkbuster "0"
seta sv_lanForceRate "1"
seta sv_strictAuth "1"
seta cl_punkbuster "0"
seta com_altivec "0"
seta com_ansiColor "0"
seta com_maxfpsUnfocused "0"
seta com_maxfpsMinimized "0"
seta sv_minRate "0"
seta sv_dlURL ""
seta cl_timedemoLog ""
seta cl_autoRecordDemo "0"
seta cl_aviFrameRate "25"
seta cl_aviMotionJpeg "1"
seta cl_cURLLib "libcurl-3.dll"
seta cl_lanForcePackets "1"
seta cl_guidServerUniq "1"
seta cl_consoleKeys "~ ` 0x7e 0x60"
seta cl_useMumble "0"
seta cl_mumbleScale "0.0254"
seta cl_voipGainDuringCapture "0.2"
seta cl_voipCaptureMult "2.0"
seta cl_voipUseVAD "0"
seta cl_voipVADThreshold "0.25"
seta cl_voipShowMeter "1"
seta cl_voip "1"
seta r_ext_texture_filter_anisotropic "0"
seta r_ext_max_anisotropy "2"
seta r_customPixelAspect "1"
seta r_stereoEnabled "0"
seta r_greyscale "0"
seta r_zproj "64"
seta r_stereoSeparation "64"
seta r_anaglyphMode "0"
seta in_keyboardDebug "0"
seta in_nograb "0"
seta in_joystickThreshold "0.15"
seta s_muteWhenMinimized "0"
seta s_useOpenAL "1"
seta s_alPrecache "1"
seta s_alGain "1.0"
seta s_alSources "96"
seta s_alDopplerFactor "1.0"
seta s_alDopplerSpeed "2200"
seta s_alDriver "OpenAL32.dll"
seta s_alDevice "DirectSound Software"
seta s_alCapture "1"
seta net_enabled "3"
seta net_mcast6addr "ff04::696f:7175:616b:6533"
seta net_mcast6iface "0"
seta com_zoneMegs "16"

//edit3:

/

I can short whole code to:

#include <Array.au3>
$srch=StringSplit("20 44 45 46 47 48 49 -1 -1 -1 -1 -1 50 200 201 202 280 299 300 326"," ")
$p=1
While $p<UBound($srch)
    if $srch[$p]=-1  Then
    _ArrayDelete($srch, $p)
    EndIf
    $p=$p+1
    WEnd
_ArrayDisplay($srch)
!

//edit4:

I can fix it by:

$pp=0
While $pp<3

    $p=1
    While $p<UBound($srch)
        if $srch[$p]=-1  Then
        _ArrayDelete($srch, $p)
        EndIf
        $p=$p+1
    WEnd
    $pp=$pp+1
WEnd

But I think, this is very unpractical. It will only work if I manually look how many -1 there is.... :( Even if I would not have to and make this "look" automatic, it is still a bad habit to write programs like that . . . ..

Edited by Thlitmi

Share this post


Link to post
Share on other sites



Study this version:

#include <Array.au3>
$srch = StringSplit("20 44 45 46 47 48 49 -1 -1 -1 -1 -1 50 200 201 202 280 299 300 326", " ")
$p = 1
While $p < UBound($srch)
    If $srch[$p] = -1 Then
        _ArrayDelete($srch, $p)
    Else
        $p = $p + 1
    EndIf
WEnd
_ArrayDisplay($srch)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

> Jos

Oh my goodness......... !

It is changing indexes... !

Once I delete it, I can not p+1 !

oh my... oh myy...........

[solved]

Share this post


Link to post
Share on other sites

Another way of doing it would be to start from the end of the array and count down to the beginning of the array.

#include <Array.au3>
$srch=StringSplit("20 44 45 46 47 48 49 -1 -1 -1 -1 -1 50 200 201 202 280 299 300 326"," ")
$p=Ubound($srch) -1
While $p > 0
    if $srch[$p]=-1  Then
    _ArrayDelete($srch, $p)
    EndIf
    $p=$p-1
WEnd
_ArrayDisplay($srch)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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