Jump to content

String Replace Weirdness - Removes my replacement


Recommended Posts

Greetings!!

Short and sweet..

Script recieves string  "POW:AC +2.000000E+01,+3,(@1)" from Sensor. **Line 483**

I use StringReplace to replace the <space> between AC and +2 with a "|" - Works and output is "POW:AC|+2.000000E+01,+3,(@1)"  **Line 484 & 485 **

I use StringReplace to replace the ","'s from the output with "|" so I can StringSplit to and array BUT the output is  "POW:AC +2.000000E+01|+3|(@1)" **Line 486 & 487**

As you can see the 2nd string replace changed the "|" between AC and +2 back into a space.

So any clues why? I need to split the initial string so I can get the info to the right places but if StringReplace keeps putting the space back I have no clue!!!

Thanks in advance!!

Req Code!!  

#include <Array.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GuiButton.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <StaticConstants.au3>
#include <Visa.au3>
#include <WindowsConstants.au3>

; Color Notes ...: Green = Dec("00ff00"), Red = Dec("ff0000"), Blue = Dec("0000ff"), Yellow = Dec("ffff00"), Dark Green = Dec("004c00")
; https://www.color-hex.com/color/cccc00 for color codes
; #include "PowerMeterCommands.au3"

; use AdlibRegister for measurement function

; Presets
; Min = -90
; Max = -56
; Zero = Internal (INT)
; Mode = Average only (AVG only)
; Frequency = 50.0 M
; Averaging Mode = AUTO
; Averaging Count = 4
; Step Detect = Checked
; Unit = dBm
; Trigger = Free Run

; Variables
$symbol = ChrW(9642)
$PowerMeter = "USB0::0x0957::0x2A18::MY54480009::INSTR"
$h_session = 0
$h_instr = _viOpen($PowerMeter)

; Flags
$ChanOffsetFlag = 0
$DutyCycleFlag = 0
$StepDetectFlag = 1 ; 1=enabled, 0=disabled
$SlopeTypeFlag = 0 ; 0=Unknown, 1=POS, 2=NEG
$ZeroTypeFlag = 0 ; 0=INT, 1=EXT
$UnitFlag = 0 ; 0=dBm, 1=Watt
$RelativeFlag = 0 ; 0=Off, 1=On
$EnableAlertsFlag = 0 ; 0=Off, 1=On

;Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=K:\Work\AutoIT Scripts\Mine\Models\PowerMeter\PowerMeter.kxf
$g_Core = GUICreate("Pwer Meter App", 1318, 615, 190, 130)
GUISetBkColor(0x000000)
; ============================== Channel Setup =====================================
$Group1 = GUICtrlCreateGroup("Channel Setup", 16, 48, 369, 369, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER))
; Remove the theme - Thanks Melba23!
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group1), "wstr", 0, "wstr", 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label1 = GUICtrlCreateLabel("Mode:", 26, 90, 48, 24, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label2 = GUICtrlCreateLabel("Range:", 24, 120, 56, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$cb_ChanOffset = GUICtrlCreateCheckbox("", 24, 152, 20, 20, BitOR($BS_AUTORADIOBUTTON, $BS_PUSHLIKE)) ; size can be anything)
GUICtrlSetState($cb_ChanOffset, 4) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
$Label3 = GUICtrlCreateLabel("Chan Offseet (dB):", 48, 152, 137, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$cb_DutyCycle = GUICtrlCreateCheckbox("", 24, 184, 20, 20, BitOR($BS_AUTORADIOBUTTON, $BS_PUSHLIKE)) ; size can be anything))
GUICtrlSetState($cb_DutyCycle, 4) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
$Label4 = GUICtrlCreateLabel("Duty Cycle (%):", 48, 184, 111, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label5 = GUICtrlCreateLabel("Frequency (Hz):", 32, 216, 117, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label6 = GUICtrlCreateLabel("Averaging Mode:", 24, 248, 123, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label7 = GUICtrlCreateLabel("Averaging Count:", 24, 280, 126, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label8 = GUICtrlCreateLabel("Step Detect", 136, 320, 90, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$combo_Mode = GUICtrlCreateCombo("AVG only", 192, 88, 145, 28, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_Mode, "AVG only|Normal")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$cb_StepDetect = GUICtrlCreateCheckbox("", 110, 323, 20, 20, BitOR($BS_AUTORADIOBUTTON, $BS_PUSHLIKE)) ; size can be anything
GUICtrlSetData($cb_StepDetect, $symbol)
GUICtrlSetFont(-1, 25, 400, 0, "Arial")
$combo_Range = GUICtrlCreateCombo("AUTO", 192, 120, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_Range, "AUTO|LOWER|UPPER")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$i_ChanOffset = GUICtrlCreateInput("", 192, 152, 145, 24)
GUICtrlSetState($i_ChanOffset, 2 + 128) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$i_DutyCycle = GUICtrlCreateInput("", 192, 184, 145, 24)
GUICtrlSetState($i_DutyCycle, 2 + 128) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$i_Frequency = GUICtrlCreateInput("0", 192, 216, 121, 24)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$combo_FreqMeas = GUICtrlCreateCombo("kHz", 320, 216, 54, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_FreqMeas, "kHz|MHz|GHz")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$combo_AvgMode = GUICtrlCreateCombo("AUTO", 192, 248, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_AvgMode, "AUTO|MANUAL|OFF")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$i_AvgCount = GUICtrlCreateInput("4", 192, 280, 121, 24)
GUICtrlSetState($i_AvgCount, 2 + 128) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ============================== Measurement Setup =====================================
$Group2 = GUICtrlCreateGroup("Measurement Setup", 992, 40, 305, 377, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER))
; Remove the theme - Thanks Melba23!
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group2), "wstr", 0, "wstr", 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label9 = GUICtrlCreateLabel("Measurement:", 1000, 80, 106, 24, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$combo_Measurement = GUICtrlCreateCombo("1", 1112, 80, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$Label10 = GUICtrlCreateLabel("Unit:", 1008, 112, 37, 24, $SS_CENTER)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$r_dBm = GUICtrlCreateRadio("r_dBm", 1096, 112, 17, 25)
GUICtrlSetState($r_dBm, 1) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
$Label29 = GUICtrlCreateLabel("dBm", 1112, 112, 37, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF) ; White
$r_Watt = GUICtrlCreateRadio("", 1160, 112, 17, 25)
$Watt = GUICtrlCreateLabel("Watt", 1176, 112, 38, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetState($r_Watt, 4) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF) ; White
$cb_Relative = GUICtrlCreateCheckbox("", 1002, 144, 20, 20, BitOR($BS_AUTORADIOBUTTON, $BS_PUSHLIKE)) ; size can be anything))
GUICtrlSetState($cb_Relative, 4) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
$Label11 = GUICtrlCreateLabel("Relative:", 1024, 144, 65, 24, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$b_Rel = GUICtrlCreateButton("Rel", 1096, 144, 51, 25)
GUICtrlSetState($b_Rel, 2 + 128) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x646464)
$out_Rel = GUICtrlCreateInput("", 1160, 144, 113, 24, $ES_READONLY)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$Label12 = GUICtrlCreateLabel("Feed 1", 1008, 208, 54, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$combo_Chan = GUICtrlCreateCombo("A", 1064, 208, 49, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_Chan, "A")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$combo_Gate = GUICtrlCreateCombo("", 1120, 208, 49, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_Gate, "")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$combo_MeasType = GUICtrlCreateCombo("Avg", 1176, 208, 97, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_MeasType, "Avg")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$Label13 = GUICtrlCreateLabel("Chan", 1064, 184, 43, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label14 = GUICtrlCreateLabel("Gate", 1120, 184, 41, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label15 = GUICtrlCreateLabel("Type", 1176, 184, 44, 20, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label16 = GUICtrlCreateLabel("Alert Limits", 1120, 256, 82, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$cb_EnableAlerts = GUICtrlCreateCheckbox("", 1008, 280, 20, 20, BitOR($BS_AUTORADIOBUTTON, $BS_PUSHLIKE)) ; size can be anything))
GUICtrlSetState($cb_EnableAlerts, 4) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
$Label17 = GUICtrlCreateLabel("Enable Alerts", 1032, 280, 99, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label18 = GUICtrlCreateLabel("Upper Limit (dBm):", 1008, 312, 136, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label19 = GUICtrlCreateLabel("Lower Limits (dBm):", 1000, 344, 143, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$i_UpperLimit = GUICtrlCreateInput("+90.00", 1144, 312, 121, 24)
GUICtrlSetState($i_UpperLimit, 2 + 128) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$i_LowerLimit = GUICtrlCreateInput("-90.00", 1144, 344, 121, 24)
GUICtrlSetState($i_LowerLimit, 2 + 128) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF) ; White
GUICtrlSetBkColor(-1, 0x000000) ; Black
GUICtrlCreateGroup("", -99, -99, 1, 1)
$out_IDNQ = GUICtrlCreateInput("out_IDNQ", 280, 8, 809, 28, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
; ============================== Trigger Setup =====================================
$Group3 = GUICtrlCreateGroup("Trigger Setup", 408, 200, 265, 137, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER))
; Remove the theme - Thanks Melba23!
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group3), "wstr", 0, "wstr", 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label20 = GUICtrlCreateLabel("Mode:", 432, 248, 48, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label21 = GUICtrlCreateLabel("Source:", 424, 288, 59, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$combo_TrigMode = GUICtrlCreateCombo("Free Run", 488, 248, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_TrigMode, "Free Run|Single Trig|Cont Trig")
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$combo_TrigSource = GUICtrlCreateCombo("INT", 488, 288, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData($combo_TrigSource, "INT|EXT")
GUICtrlSetState($combo_TrigSource, 128) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$Label26 = GUICtrlCreateLabel("Slope Type:", 424, 311, 87, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF) ; White
$r_POS = GUICtrlCreateRadio("r_POS", 520, 311, 17, 25)
$Label27 = GUICtrlCreateLabel("+POS", 536, 311, 46, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF) ; White
$r_NEG = GUICtrlCreateRadio("r_NEG", 592, 311, 17, 25)
$Label28 = GUICtrlCreateLabel("-NEG", 608, 311, 44, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF) ; White
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ============================== Calibration Setup =====================================
$Group4 = GUICtrlCreateGroup("Calibration", 696, 200, 273, 137, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER))
; Remove the theme - Thanks Melba23!
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group4), "wstr", 0, "wstr", 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Button1 = GUICtrlCreateButton("Zero", 776, 232, 75, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x646464)
$Label22 = GUICtrlCreateLabel("Zero Type:", 744, 272, 79, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$r_INT = GUICtrlCreateRadio("", 840, 272, 17, 25)
GUICtrlSetState($r_INT, 1) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
$Label23 = GUICtrlCreateLabel("INT", 856, 272, 29, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$r_EXT = GUICtrlCreateRadio("", 840, 296, 17, 25)
GUICtrlSetState($r_EXT, 4) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
$Label24 = GUICtrlCreateLabel("EXT", 856, 296, 35, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ============================== SelfTest Setup =====================================
$Group5 = GUICtrlCreateGroup("Self-Test", 408, 338, 561, 81, BitOR($GUI_SS_DEFAULT_GROUP, $BS_CENTER))
; Remove the theme - Thanks Melba23!
DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($Group5), "wstr", 0, "wstr", 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$Label25 = GUICtrlCreateLabel("Timeout (s):", 488, 376, 87, 24, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
$i_Timeout = GUICtrlCreateInput("120", 584, 376, 121, 24)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
$b_SelfTest = GUICtrlCreateButton("Self-Test", 720, 376, 75, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x646464)
GUICtrlCreateGroup("", -99, -99, 1, 1)
; ============================== Measurement / Console =====================================
$e_Measurement = _GUICtrlRichEdit_Create($g_Core, "", 440, 56, 497, 137, _
        BitOR($ES_CENTER, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))
_GUICtrlRichEdit_SetFont($e_Measurement, 50)
$e_Console = _GUICtrlRichEdit_Create($g_Core, "", 408, 424, 561, 177, _
        BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))

_GUICtrlRichEdit_SetSel($e_Console, 0, -1) ; select all
_GUICtrlRichEdit_ChangeFontSize($e_Console, 3) ; change point size
_GUICtrlRichEdit_Deselect($e_Console) ; deselect all

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; ============================= Startup Sequence ============================================
_GUICtrlRichEdit_AppendText($e_Console, "")
_GUICtrlRichEdit_SetCharColor($e_Console, Dec("ff0000")) ; Blue
_GUICtrlRichEdit_AppendText($e_Console, "****Begin Startup Checks****" & @CRLF)
_Startup()
_GUICtrlRichEdit_SetCharColor($e_Console, Dec("ff0000")) ; Blue
_GUICtrlRichEdit_AppendText($e_Console, "****End Startup Checks****" & @CRLF)
; ===========================================================================================

While 1
    $msg = GUIGetMsg()
    Switch $msg

        Case $GUI_EVENT_CLOSE
            _viClose($h_instr)
            Exit
    EndSwitch
WEnd

Func _Startup()
    _viExecCommand($h_instr, "*RST", 4000) ; Places the U2000 Series power sensor in a known state.
    ; *IDN? ---- Identification Check
    $s_IDNQ = _viExecCommand($h_instr, "*IDN?", 10000) ; Allows the U2000 Series power sensor to identify itself.
    If $s_IDNQ = -1073807346 Then
        GUICtrlSetData($out_IDNQ, "*IDN? Error: The given session or object reference is invalid.")
        Return
    Else
        GUICtrlSetData($out_IDNQ, $s_IDNQ)
    EndIf
    ; ----------------
    _viExecCommand($h_instr, "*CLS", 4000) ; Clears Registers
    ; SYST:ERR? ---- System Error Check
    $s_SystErrQ = _viExecCommand($h_instr, "SYST:ERR?", 10000) ; Checks the U2000 Series power sensor system error queue.
    If $s_SystErrQ = -1073807346 Then
        _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Red
        _GUICtrlRichEdit_AppendText($e_Console, "**System Check Error: The given session or object reference is invalid. " & @CRLF)
    Else
        _GUICtrlRichEdit_SetCharColor($e_Console, Dec("004c00")) ; Dark Green
        _GUICtrlRichEdit_AppendText($e_Console, "System Test: " & $s_SystErrQ)
    EndIf
    ; ----------------
    _viExecCommand($h_instr, "*CLS", 4000)
    ; AVER:SDET? ---- Step Detect
    $sys_StepDetect = _viExecCommand($h_instr, "AVER:SDET?", 10000) ; Queries whether step detection is on or off. 1=enabled/0=disabled
    Select
        Case $sys_StepDetect = 0
            GUICtrlSetState($cb_StepDetect, $GUI_UNCHECKED)
            $StepDetectFlag = 0
        Case $sys_StepDetect = 1
            GUICtrlSetState($cb_StepDetect, $GUI_CHECKED)
            $StepDetectFlag = 1
        Case $sys_StepDetect = -1073807346
            _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Red
            _GUICtrlRichEdit_AppendText($e_Console, "**Step Detection ERror: The given session or object reference is invalid." & @CRLF)
    EndSelect

    ; ----------------
    ; FORM:BORD? ---- Byte Order Check
    $sys_FORMBORDQ = _viExecCommand($h_instr, "FORM:BORD?", 10000)
    If $sys_FORMBORDQ = -1073807346 Then
        _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Red
        _GUICtrlRichEdit_AppendText($e_Console, "**Byte Order Error: The given session or object reference is invalid." & @CRLF)
    Else
        _GUICtrlRichEdit_SetCharColor($e_Console, Dec("004c00")) ; Dark Green
        _GUICtrlRichEdit_AppendText($e_Console, "Byte Order: " & $sys_FORMBORDQ) ; Data Format = NORM / SWAP
    EndIf
    ; ----------------
    ; FORM:DATA? ---- Data Format Check
    $sys_FORMDATAQ = _viExecCommand($h_instr, "FORM:DATA?", 10000)
    If $sys_FORMDATAQ = -1073807346 Then
        _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Red
        _GUICtrlRichEdit_AppendText($e_Console, "**Data Format Error: The given session or object reference is invalid." & @CRLF)
    Else
        _GUICtrlRichEdit_SetCharColor($e_Console, Dec("004c00")) ; Dark Green
        _GUICtrlRichEdit_AppendText($e_Console, "Data Format: " & $sys_FORMDATAQ) ; Data Format = ASC<NR3> / REAL
    EndIf
    ; ----------------
    ; CAL:ZERO:TYPE? ---- CAL/ZERO Check
    $sys_CALZEROTYPEQ = _viExecCommand($h_instr, "CAL:ZERO:TYPE?", 10000) ; This query returns the current zeroing type, either “INT” or “EXT”.

    $sl_CALZEROTYPEQ = StringLeft($sys_CALZEROTYPEQ, 3)

    Select
        Case $sl_CALZEROTYPEQ = "INT"
            GUICtrlSetState($r_INT, 1) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
            $ZeroModeFlag = 1
            GUICtrlSetState($r_EXT, 4) ; 1 = Checked, 2 = Indeterminate(Greyed), 4 = Unchecked, 64 = Enabled, 128 = Disabled
        Case $sl_CALZEROTYPEQ = "EXT"
            GUICtrlSetState($r_EXT, 1)
            $ZeroModeFlag = 0
            GUICtrlSetState($r_INT, 4)
        Case Else
            _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Dark Red
            _GUICtrlRichEdit_AppendText($e_Console, "**CAL/Zero Check Error: The given session or object reference is invalid." & @CR)
    EndSelect
    ; ----------------
    ; DET:FUNC? --- Measurement Mode Check - AVERage (chopper-based measurement)or NORMal(sample-based measurement)
    $sys_DETFUNCQ = _viExecCommand($h_instr, "DET:FUNC?", 10000)

    $sys_DETFUNCQ_sl = StringLeft($sys_DETFUNCQ, 4)

    Select
        Case $sys_DETFUNCQ_sl = "AVER"
            GUICtrlSetData($combo_Mode, "AVG only")
        Case $sys_DETFUNCQ_sl = "NORM"
            GUICtrlSetData($combo_Mode, "Normal")
        Case Else
            _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Dark Red
            _GUICtrlRichEdit_AppendText($e_Console, "**Measurement Mode Error: The given session or object reference is invalid." & @CRLF)
    EndSelect
    ; ----------------
    ; INIT:CONT? ---- Single or Continuous Trigger
    $sys_INITCONTQ = _viExecCommand($h_instr, "INIT:CONT?", 10000)
    Select
        Case $sys_INITCONTQ = 0
            GUICtrlSetData($combo_TrigMode, "Single Trig")
        Case $sys_INITCONTQ = 1
            GUICtrlSetData($combo_TrigMode, "Cont Trig")
        Case $sys_INITCONTQ = -1073807346
            _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Dark Red
            _GUICtrlRichEdit_AppendText($e_Console, "**Trigger Mode Error: The given session or object reference is invalid." & @CRLF)
    EndSelect
    ; ----------------
    ; AVER:COUN:AUTO? --- Automatic Filter Length 1=Auto, 0=Manual  **If set to OFF, AVER:COUN:AUTO? returns 0**
    $sys_AVERCOUNAUTOQ = _viExecCommand($h_instr, "AVER:COUN:AUTO?", 10000)
    $sys_AVERCOUNQ = _viExecCommand($h_instr, "AVER:COUN?", 10000)
    Select
        Case $sys_AVERCOUNAUTOQ = 0
            GUICtrlSetData($i_AvgCount, $sys_AVERCOUNQ)
            GUICtrlSetData($combo_AvgMode, "Manual")
        Case $sys_AVERCOUNAUTOQ = 1
            GUICtrlSetData($i_AvgCount, $sys_AVERCOUNQ)
            GUICtrlSetData($combo_AvgMode, "Auto")
        Case $sys_AVERCOUNAUTOQ = -1073807346
            GUICtrlSetData($i_AvgCount, 0)
            _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Dark Red
            _GUICtrlRichEdit_AppendText($e_Console, "**Automatic Filter Length Error: The given session or object reference is invalid." & @CRLF)
        Case Else
            _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Dark Red
            _GUICtrlRichEdit_AppendText($e_Console, $sys_AVERCOUNAUTOQ & @CRLF)
    EndSelect
    ; ----------------
    ; FREQ? ---- Queries Frequency
    $sys_FREQQ = _viExecCommand($h_instr, "FREQ?", 10000)
    If $sys_FREQQ = -1073807346 Then
    _GUICtrlRichEdit_SetCharColor($e_Console, Dec("0000b2")) ; Dark Red
    _GUICtrlRichEdit_AppendText($e_Console, "**Frequency Check Error: The given session or object reference is invalid." & @CRLF)
    Return
    Endif
    $ActFreq = Number($sys_FREQQ)
    $slFreq = StringLen($ActFreq)
    Select
        Case $slFreq < 4
            GUICtrlSetData($i_Frequency, $ActFreq)
        Case $slFreq > 3 And $slFreq < 7
            $CorrectedFreq = StringTrimRight($ActFreq, 3)
            GUICtrlSetData($i_Frequency, $CorrectedFreq)
            GUICtrlSetData($combo_Measurement, "kHz")
        Case $slFreq > 6 And $slFreq < 10
            $CorrectedFreq = StringTrimRight($ActFreq, 6)
            GUICtrlSetData($i_Frequency, $CorrectedFreq)
            GUICtrlSetData($combo_Measurement, "MHz")
        Case $slFreq > 9
            $CorrectedFreq = StringTrimRight($ActFreq, 9)
            GUICtrlSetData($i_Frequency, $CorrectedFreq)
            GUICtrlSetData($combo_Measurement, "GHz")
    EndSelect
    ; ----------------
    $sys_CONFQ = _viExecCommand($h_instr, "CONF?", 10000) ; Returns “<function> <expected_value>,<resolution>,<source list>”
    $sr_CONFQ = StringReplace($sys_CONFQ, " ","|")
    _GUICtrlRichEdit_AppendText($e_Console, "Conf: " & $sr_CONFQ)
    $sr2_CONFQ = StringReplace($sys_CONFQ, ",","|")
    _GUICtrlRichEdit_AppendText($e_Console, "Conf: " & $sr2_CONFQ)



;Temp
    $s_DEVQ = _viExecCommand($h_instr, "TEMP?", 10000)
    $Conv = $s_DEVQ * 1.8 + 32 ; Convert Celsius to Fahrenheit
    $s_DEVQ = StringLeft($Conv, 4)
    _GUICtrlRichEdit_SetCharColor($e_Console, Dec("004c00")) ; Dark Green
    _GUICtrlRichEdit_AppendText($e_Console, "Temp F: " & $s_DEVQ & @CR)
EndFunc   ;==>_Startup


; ******Internal Functions*******
Func _Number_AddSep($iVal, $sSep = -1, $dSep = -1)
    If (Not StringIsInt($iVal)) And (Not StringIsFloat($iVal)) Then Return SetError(1)
    If $sSep = "" Or StringRegExp($sSep, "(?i)-1|default") Then _
            $sSep = RegRead("HKCU\Control Panel\International", "sThousand")
    If $dSep = "" Or StringRegExp($dSep, "(?i)-1|default") Then _
            $dSep = RegRead("HKCU\Control Panel\International", "sDecimal")
    Local $dVal = ""
    If StringIsFloat($iVal) Then
        $dVal = StringMid($iVal, StringInStr($iVal, "."))
        $iVal = Int($iVal)
        $dVal = StringReplace($dVal, ".", $dSep)
    EndIf
    Local $oVal = ""
    $cArray = StringSplit($iVal, "")
    For $I = UBound($cArray) - 3 To 1 Step -3
        $cArray[$I] = $sSep & $cArray[$I]
    Next
    For $I = 1 To UBound($cArray) - 1
        $oVal &= $cArray[$I]
    Next
    If StringLeft($oVal, StringLen($sSep)) = $sSep Then $oVal = _
            StringReplace($oVal, $sSep, "", 1)
    Return $oVal & $dVal
EndFunc   ;==>_Number_AddSep

Func _IsChecked($idControlID)
    Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

 

Link to comment
Share on other sites

What you want to do is use the result from the first replace in the second one, like this:

$sys_CONFQ = "POW:AC +2.000000E+01,+3,(@1)"
$sr_CONFQ = StringReplace($sys_CONFQ, " ","|") 
ConsoleWrite('$sr_CONFQ - '& $sr_CONFQ &@CRLF)
$sr2_CONFQ = StringReplace($sr_CONFQ, ",","|") ;the source string is $sr_CONFQ from the previous replace
ConsoleWrite('$sr2_CONFQ - '& $sr2_CONFQ &@CRLF)

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

We've all been there. ;)

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

As someone said recently, StringRegExp... everywhere  :)

#Include <Array.au3>

$sys_CONFQ = "POW:AC +2.000000E+01,+3,(@1)"

; change both space and comma in one shot
Msgbox(0,"", StringRegExpReplace($sys_CONFQ, '\s|,', "|"))

; or get the array directly, hey why not ?
$a = StringRegExp($sys_CONFQ, '[^\s,]+', 3)
_ArrayDisplay($a)

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...