I modified the code of getparam2.o2bas a bit to show the problem. If I remove the comments of line 149 .. 168 the program will only run in 32-bit mode. In 64-bit mode the app will crash.
At first I thought the reason would be param_index in function param_action. But in fact the problem seems to be the function LineFeeds in function IupMessagef. If I use IupMessage then the app will run in 64-bit mode too. My second approach from line 171..186 also only works for 32-bit.
For me the code of Linefeeds looks good and it works for IupGetParam. But maybe there is something missing for IupMessagef in 64-bit? I am surprised that using crlf in my second try does not work in 64-bit neither. If nothing helps then IupMessage can be used in any case.
% filename "getparam2.exe"
'uses rtl32
'uses rtl64
uses console
includepath "../include/"
#ifndef mode64bit
extern lib "../IUP32/iup.dll"
uses "iup.h"
end extern
extern cdecl
#else
extern lib "../IUP64/iup.dll"
uses "iup.h"
end extern
#endif
function LineFeeds(char*fmt) as string
======================================
string s=fmt
sys i=1, le=len(s)
byte bs at strptr fmt
byte bd at strptr s
indexbase 0
do
if i++ > le then exit do
if bs=13
@bs+=2
bd=10
@bd++
le--
else
bd=bs
@bs++
@bd++
end if
end do
return left s,le
end function
/*
function LineFeeds(char*fmt) as string
======================================
string s=fmt
sys i=1, le=len(s)
#cpointer on
byte *bs = strptr *fmt
byte *bd = strptr s
indexbase 0
do
if i++ > le then exit do
if *bs=13
bs+=2
*bd=10
bd++
le--
else
*bd=*bs
'bd[0]=bs[0]
bs++
bd++
end if
end do
#cpointer off
return left s,le
end function
*/
function param_action(sys dialog, int param_index, void* user_data) as sys callback 'int callback
printl "param_index " param_index
select case param_index
case IUP_GETPARAM_INIT
printl "IupGetParam - Init"
case IUP_GETPARAM_BUTTON1
printl "IupGetParam - Button1 (OK)"
case IUP_GETPARAM_BUTTON2
printl "IupGetParam - Button2 (Cancel)"
case IUP_GETPARAM_BUTTON3
printl "IupGetParam - Button3 (Help)"
case else
sys param
string param_str = " PARAM" & param_index
param = IupGetAttribute(dialog, param_str)
printl param_str & ", " IupGetAttribute(param, "VALUE")
end select
return 1
end function
IupOpen(null,null)
'GETPARAM TEST
==============
int pboolean = 1;
int pinteger = 3456;
float preal = 3.543f;
int pinteger2 = 192;
float preal2 = 0.5f;
float pangle = 90;
char pstring[100] = "string text";
char pfont[100] = "Courier, 24";
char pcolor[100] = "255 0 128";
int plist = 2;
int poptions = 1;
char pstring2[200] = "second text" & chr(10) & "second line";
char file_name[500] = "test.jpg";
int retp = IupGetParam("IupGetParamTest", @param_action, 0,
linefeeds(
"Bt %u[, MyCancel, Help!]
Boolean: %b[No,Yes]
Integer: %i
Real 1: %r
Sep1 %t
Integer: %i[0,255]
Real 2: %r[-1.5,1.5,0.05]
Sep2 %t
Angle: %a[0,360]
String: %s
Options: %o|item0|item1|item2|
List: %l|item0|item1|item2|item3|item4|item5|item6|
File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]
Color: %c{Color Tip}
Font: %n
Sep3 %t
Multiline: %m
"),
&pboolean, &pinteger, &preal, &pinteger2, &preal2, &pangle, &pstring,
&poptions, &plist, &file_name, &pcolor, &pfont, &pstring2, NULL)
printl "retp = " retp
string crlf=chr(13,10)
if retp != 0 then
'does not work in 64-bit
/*
IupMessagef("IupGetParam using IupMessagef",
linefeeds(
"Boolean Value: %d
Integer: %d
Real 1: %g
Integer: %d
Real 2: %g
Angle: %g
String: %s
Options Index: %d
List Index: %d
FileName: %s
Color: %s
Font: %s
Multiline: %s
"),
pboolean, pinteger, double preal, pinteger2, double preal2, double pangle, pstring,
poptions, plist, file_name, pcolor, pfont, pstring2)
*/
'does not work neither in 64-bit
/*
IupMessagef("IupGetParam using IupMessagef",
"Boolean Value: %d" + crlf +
"Integer: %d" + crlf +
"Real 1: %g" + crlf +
"Integer: %d" + crlf +
"Real 2: %g" + crlf +
"Angle: %g" + crlf +
"String: %s" + crlf +
"Options Index: %d" + crlf +
"List Index: %d" + crlf +
"FileName: %s" + crlf +
"Color: %s" + crlf +
"Font: %s" + crlf +
"Multiline: %s",
pboolean, pinteger, double preal, pinteger2, double preal2, double pangle, pstring,
poptions, plist, file_name, pcolor, pfont, pstring2)
*/
IupMessage("IupGetParam using IupMessage",
"Boolean Value: " + pboolean + crlf +
"Integer: " + pinteger + crlf +
"Real 1: " + str(preal,2) + crlf +
"Integer: " + pinteger2 + crlf +
"Real 2: " + str(preal2,2) + crlf +
"Angle: " + pangle + crlf +
"String: " + pstring + crlf +
"Options Index: " + poptions + crlf +
"List Index: " + plist + crlf +
"FileName: " + file_name + crlf +
"Color: " + pcolor + crlf +
"Font: " + pfont + crlf +
"Multiline: " + pstring2 + crlf
)
end if
IupClose()
printl "Enter to end..."
waitkey